How to extract frames(or a perticular frame) from a YUV video using ffmpeg

大憨熊 提交于 2019-12-09 19:36:44

问题


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.



来源:https://stackoverflow.com/questions/31981455/how-to-extract-framesor-a-perticular-frame-from-a-yuv-video-using-ffmpeg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!