Radu
Radu

Reputation: 1104

Extract first frame of multi video streams video

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.

Upvotes: 0

Views: 311

Answers (1)

llogan
llogan

Reputation: 133743

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

Upvotes: 1

Related Questions