简体   繁体   English

如何使用ffmpeg将mp4转换为YUV文件?

[英]How to convert mp4 to YUV file using ffmpeg?

I cannot play yuv file properly after converting it from mp4 format to YUV 420 format. 从mp4格式转换为YUV 420格式后,我无法正确播放yuv文件。 I have programmed the width and height of the video when I play it. 播放视频时,我已经对视频的宽度和高度进行了编程。 Is the following converting command for ffmpeg correct? ffmpeg的以下转换命令正确吗?

ffmpeg -i sample.mp4 -c:v rawvideo -pix_fmt yuv420p out.yuv

Almost all video decodes to YCbCr 4:2:0, aka IYUV ( fourcc ), hence 几乎所有视频都解码为YCbCr 4:2:0,也就是IYUV( fourcc ),因此

ffmpeg -i sample.mp4 out.yuv

is sufficient. 足够了。

To view it you can eg use, ffplay , display from imagemagick, my own tool , or vooya . 要查看它,您可以使用ffplay ,通过imagemagick进行display我自己的工具vooya

Some examples: 一些例子:

# Using ffmpeg
ffplay -s WxH file.yuv

# Using imagemagick and display to look at first frame
display -size WxH -depth 8 -colorspace sRGB 'file.yuv[1]'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM