I work with FFMpeg and process some .mkv videos that can have more than one videostream. How I can extract frame from other videostream (not from primary)? I want to extract one frame from each videostream using FFMPeg. Any ideas?
            Asked
            
        
        
            Active
            
        
            Viewed 330 times
        
    1
            
            
        - 
                    You may want to look at: [FFmpeg's **Map** guide](https://trac.ffmpeg.org/wiki/Map). You likely want: `ffmpeg -i yourfile.mkv -map 0:1 -c copy output.mkv`. See if that gets the second stream. – VC.One Sep 16 '20 at 17:59
- 
                    Yes, it really works. Many thanks! – Fedor Zhilkin Sep 16 '20 at 19:39
1 Answers
4
            Example input file layout:
- video #0:0
- video #0:1
- video #0:2
- audio #0:3
- audio #0:4
Example: Output screenshot from video #0:2
From 30 second timestamp (-ss 30).
Absolute map
ffmpeg -ss 30 -i input.mkv -map 0:2 -frames:v 1 output.jpg
Relative map
Same result as above with this particular input. 0:v:1 is translated as "from input #0 choose video stream #1". Note that ffmpeg starts counting from 0, so video stream #1 is actually the 2nd video stream.
ffmpeg -ss 30 -i input.mkv -map 0:v:1 -frames:v 1 output.jpg
I prefer using this method because you can be lazy and not have to know the actual stream map numbers.
Example: Output a screenshot from each video stream
ffmpeg -ss 30 -i input.mkv -map 0:v:0 -frames:v 1 output0.jpg -map 0:v:1 -frames:v 1 output1.jpg -map 0:v:2 -frames:v 1 output2.jpg
Also see
 
    
    
        llogan
        
- 121,796
- 28
- 232
- 243
