How to extract frames(or a perticular frame) from

2019-05-22 18:18发布

问题:

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 YUVformat video?

回答1:

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.



回答2:

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



回答3:

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.



标签: video ffmpeg yuv