Here is the code for extracting frames from a MP4
video.
ffmpeg -i above_marathon_250.mp4 images%03d.bmp
But the same code does not work for YUV
format video.
Does anyone knows how it is possible to extract frame(s) from YUV
format video?
3 Answers
It's not working because yuv files have no header, so ffmpeg doesn't know what size/pixfmt the file is. You need to specify resolution and pixmt manually:
ffmpeg -video_size 1920x1080 -r 25 -pixel_format yuv422p -i file.yuv output-%d.png
And then adjust size/pixfmt to match your particular video.
[edit] I'd also suggest to post such questions on superuser in the future, this has nothing to do with programming.

- 10,828
- 26
- 47
-
It works perfectly. Thanks @Ronald Also, i am new in StackOverflow, so i need to know about superuser. i will do. thanks – mrana Aug 14 '15 at 07:58
The command given in ffmpeg.org is
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
This will extract one video frame per second from the video and will output them in files named foo-001.jpeg, foo-002.jpeg, etc. Images will be rescaled to fit the new WxH values.
In your case you can modify the above command to
ffmpeg -i inputfile.yuv -r 1 -f image2 images%05d.png
where r is frame rate which should be set to 1, to extract single frame from yuv

- 856
- 1
- 10
- 26
-
setting `r=1` ffmpeg -i inputfile.yuv -1 1 -f image2 images%05d.png It does not work. – mrana Aug 13 '15 at 10:27
-
r is already having a value 1 in the above command so use the command as it is – shri Aug 13 '15 at 10:59
-
It does not create any image and this is the message on command line: `[rawvideo @ 0x7fef6880da00] Could not find codec parameters for stream 0 (Video:rawvideo (I420 / 0x30323449), yuv420p, -4 kb/s):unspecified size Consider increasing the value for the 'analyzeduration' and'probesize' options above_marathon_250.yuv: could not find codec parameters Input #0,rawvideo, from 'above_marathon_250.yuv': Duration:N/A,bitrate:n/a Stream #0:0:Video:rawvideo(I420 / 0x30323449), yuv420p, -4 kb/s, 25 tbr, 25 tbn,25 tbc Output #0,image2,to'images%05d.png': Output file #0 does not contain any stream` – mrana Aug 13 '15 at 14:21
-
Pl. find the below link http://stackoverflow.com/questions/11659267/ffmpeg-10-04-could-not-find-codec-parameters where it is mentioned that The files I was testing were in fact damaged. But if anyone faces this problem, setting -probesize and -analyzeduration to 100 and 10000000 for example might help. – shri Aug 13 '15 at 15:50
-
You have to specify the video size -video_size
and frame rate -r
so use the following script:
ffmpeg.exe -video_size 720x576 -r 25 -ss 00:00:00 -i video_input_720x576_25.yuv -vframes 1 -q:v 1 frame_output_720x576_25.jpg
In case you want to specify input video format include -pixel_format yuv420p
or any other format except yuv420p
.

- 4,427
- 14
- 70
- 112