Answers.Body: <p>There are two basic ways to do this:</p>
  
  <p>1) feed file as multiple inputs and extract one image from each input</p>
  
  <pre><code>ffmpeg -ss 280 -i sample.mp4 -ss 300 -i sample.mp4 -ss 302 -i sample.mp4
  -map 0 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out1.jpg
  -map 1 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out2.jpg
  -map 2 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out3.jpg
  </code></pre>
  
  <p>This method can get unwieldy with many targets or if the input is read from over a network.</p>
  
  <p>2) feed it as one input but only decode keyframes and output as one stream.</p>
  
  <pre><code>ffmpeg -skip_frame nokey -i sample.mp4 -vf "select='lt(abs(t-280),0.2)+lt(abs(t-300),0.2)+lt(abs(t-302),0.2)'" -aspect 1.7777777777778 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p -vsync 0 out%d.jpg
  </code></pre>
  
  <p>This allows a leeway of 0.2 seconds in identified keyframe timings.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-02T14:53:37.807Z
Answers.LastActivityDate: 2020-04-02T14:53:37.807Z
Answers.UserDisplayName: Gyan
Body: <p>I'm trying to get multiple snapshots of a single input file using <a href="https://trac.ffmpeg.org/wiki/Seeking" rel="nofollow noreferrer">Input Seeking</a>.
  I want to seek to different keyframes and save each to different output images.</p>
  
  <p>I can use this using multiple calls:</p>
  
  <pre><code>ffmpeg -ss 280 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out1.jpg
  ffmpeg -ss 300 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out2.jpg
  ffmpeg -ss 302 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out3.jpg
  </code></pre>
  
  <p>Unfortunately I have to call ffmpeg programmatically using exec. Is there a way to batch process the tasks above? <strong>It has to use input seeking</strong>. Thanks.</p>
  
Tags: <ffmpeg>
Title: FFmpeg Single Input, Seek to Multiple Outputs
UserDisplayName: shesharp
ThreadText: # FFmpeg Single Input, Seek to Multiple Outputs
  
  (Asked by: username_0 on 2020-04-02)
  
  I'm trying to get multiple snapshots of a single input file using [Input Seeking](https://trac.ffmpeg.org/wiki/Seeking).
  I want to seek to different keyframes and save each to different output images.
  
  I can use this using multiple calls:
  
  ```
  ffmpeg -ss 280 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out1.jpg
  ffmpeg -ss 300 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out2.jpg
  ffmpeg -ss 302 -i sample.mp4 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out3.jpg
  
  ```
  
  Unfortunately I have to call ffmpeg programmatically using exec. Is there a way to batch process the tasks above? **It has to use input seeking**. Thanks.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-04-02. Score: 1
  
  There are two basic ways to do this:
  
  1) feed file as multiple inputs and extract one image from each input
  
  ```
  ffmpeg -ss 280 -i sample.mp4 -ss 300 -i sample.mp4 -ss 302 -i sample.mp4
  -map 0 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out1.jpg
  -map 1 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out2.jpg
  -map 2 -aspect 1.7777777777778 -vframes 1 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p out3.jpg
  
  ```
  
  This method can get unwieldy with many targets or if the input is read from over a network.
  
  2) feed it as one input but only decode keyframes and output as one stream.
  
  ```
  ffmpeg -skip_frame nokey -i sample.mp4 -vf "select='lt(abs(t-280),0.2)+lt(abs(t-300),0.2)+lt(abs(t-302),0.2)'" -aspect 1.7777777777778 -qmax 9 -qmin 8 -bt 10000000 -y -pix_fmt yuv420p -vsync 0 out%d.jpg
  
  ```
  
  This allows a leeway of 0.2 seconds in identified keyframe timings.
  
  
  ---
  
  