0

I am curious about how to use FFmpeg in order to extract the first frame of the first video stream from a multi-video stream file. What I have so far is:

ffmpeg -i {mediaFile} -ss 0 -map 0:v -vframes 1 -f image2 firstFrame.jpeg.

I am not sure about the -map part. How can be certain that I work on the first video stream? Is there a way to first filter streams by codec type, then select the first and then extract the frame?

Thanks.

Radu
  • 984
  • 2
  • 10
  • 33

1 Answers1

1
ffmpeg -i {mediaFile} -map 0:v:0 -frames:v 1 firstFrame.jpeg

Add an input stream index to your -map as shown in the example above. 0:v:0 is input #0:video:stream #0. Note that ffmpeg starts counting from 0. If you wanted video stream #3, it would be 0:v:2.

I removed the superfluous options from your command.

Also see

llogan
  • 105,293
  • 25
  • 200
  • 219