Body: <p>I have a remote MP4 file that is short (1 minute) but large (~450mb), something like this:</p>
  
  <p><a href="https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4" rel="nofollow">https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4</a></p>
  
  <p>I'd like to extract frames every n seconds (where n is >0.5, probably 1 or 2) in the most bandwidth-efficient way possible - i.e. without downloading the whole video. I care less about getting a specific frame than I do about getting one in the general area with the smallest amount of bandwidth usage.</p>
  
  <p>I've found I can get the keyframe list like this:</p>
  
  <pre><code>ffprobe -select_streams v -show_frames \
  -show_entries frame=pict_type \
  -of csv https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 \
  | grep -n I | cut -d ':' -f 1
  </code></pre>
  
  <p>But this involves downloading the entire video.</p>
  
  <p>I can also download the actual keyframes:</p>
  
  <pre><code>ffmpeg -i \
  https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 \
  -vf select='eq(pict_type\,I)',setpts='N/(239.76*TB)' out%09d.jpg
  </code></pre>
  
  <p>But again, this downloads the whole video.</p>
  
  <p>I've also found I can download specific frames:</p>
  
  <pre><code>ffmpeg -noaccurate_seek -ss 00:00:01 -i https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 -frames:v 1 frame-1s.jpg
  </code></pre>
  
  <p>But this seems to use a lot of data for each frame (>5mb).</p>
  
  <p>Is there a way to achieve this with minimal bandwidth usage?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-14T12:48:41.653Z
Comments.Text: Are you able to manipulate the file on the remote server? Create new files?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-14T12:55:53.797Z
Comments.Text: Sadly not - the "remote server" is actually a GoPro camera, accessed over wifi...
Comments.UserDisplayName: awidgery
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-14T13:04:06.620Z
Comments.Text: Then I don't see a way to do it with off-the-shelf s/w. Basic method would be to download the MOOV box from the MP4, read the STSS box to get the list of keyframes, then fetch those packets only. But to do this, you'll have to code in C. There may be some paid s/w that does this, but not aware of any.
Comments.UserDisplayName: Gyan
Tags: <ffmpeg>
Title: ffmpeg: Quickly get frames every n seconds from a remote file, downloading as little data as possible
UserDisplayName: awidgery
ThreadText: # ffmpeg: Quickly get frames every n seconds from a remote file, downloading as little data as possible
  
  (Asked by: username_0 on 2016-06-14)
  
  I have a remote MP4 file that is short (1 minute) but large (~450mb), something like this:
  
  <https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4>
  
  I'd like to extract frames every n seconds (where n is >0.5, probably 1 or 2) in the most bandwidth-efficient way possible - i.e. without downloading the whole video. I care less about getting a specific frame than I do about getting one in the general area with the smallest amount of bandwidth usage.
  
  I've found I can get the keyframe list like this:
  
  ```
  ffprobe -select_streams v -show_frames \
  -show_entries frame=pict_type \
  -of csv https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 \
  | grep -n I | cut -d ':' -f 1
  
  ```
  
  But this involves downloading the entire video.
  
  I can also download the actual keyframes:
  
  ```
  ffmpeg -i \
  https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 \
  -vf select='eq(pict_type\,I)',setpts='N/(239.76*TB)' out%09d.jpg
  
  ```
  
  But again, this downloads the whole video.
  
  I've also found I can download specific frames:
  
  ```
  ffmpeg -noaccurate_seek -ss 00:00:01 -i https://s3-eu-west-1.amazonaws.com/worm-web-assets-prod/GOPR7775.MP4 -frames:v 1 frame-1s.jpg
  
  ```
  
  But this seems to use a lot of data for each frame (>5mb).
  
  Is there a way to achieve this with minimal bandwidth usage?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Are you able to manipulate the file on the remote server? Create new files?  
  > **username_0**: Sadly not - the "remote server" is actually a GoPro camera, accessed over wifi...  
  > **username_1**: Then I don't see a way to do it with off-the-shelf s/w. Basic method would be to download the MOOV box from the MP4, read the STSS box to get the list of keyframes, then fetch those packets only. But to do this, you'll have to code in C. There may be some paid s/w that does this, but not aware of any.  
  
  ---
  
  ## 0 answers
  
  