简体   繁体   English

如何从YUV文件中提取帧?

[英]How to extract frames from a YUV file?

I have a YUV file and I want to obtain each frame in the form of a BMP file, how to go by doing this ? 我有一个YUV文件,我想以BMP文件的形式获取每个帧,怎么做呢? I have FFMPEG and MPlayer at my disposal. 我可以使用FFMPEG和MPlayer。

i would suggest u to first convert the .yuv file to .mp4 format by using this code. 我建议您首先使用此代码将.yuv文件转换为.mp4格式。

ffmpeg -s 640x480 -i input.yuv -ss 00:00:00 -c:v libx264 -s:v 640x480 -preset slow -t 00:00:20 output.mp4

now extract the images from output.mp4 to .bmp format by using this code 现在使用此代码将图像从output.mp4提取为.bmp格式

ffmpeg -i output.mp4 images%03d.bmp

this will work. 这将起作用。

a little explanantion of the above codes so that u can change the code according to ur needs. 以上代码略有解释,以便您可以根据自己的需要更改代码。

-s 640x480 sets the resolution of the mp4 (u can change it to ur requirements) -s 640x480设置mp4的分辨率(您可以将其更改为您的要求)
-c:v libx264 sets the encoder to do encoding in libx264 -c:v libx264将编码器设置为在libx264中进行编码
-preset slow (this again change it to ur requirements ultrafast, medium etc) -预设慢(这又将其更改为您对超快,中等等的要求)
-t sets the output file time. -t设置输出文件时间。 here i have set it 20 seconds.(remember format is hh:mm:ss.ms where ms is milliseconds) 在这里我将其设置为20秒。(记住格式为hh:mm:ss.ms,其中ms为毫秒)

image%03d.bmp is given as output. image%03d.bmp作为输出给出。 so this means the output files will be saved as image001.bmp,image002.bmp ... 因此这意味着输出文件将另存为image001.bmp,image002.bmp ...

or just image%d.bmp outputs as image1.bmo,image2.bmp and so on 或只是image%d.bmp输出为image1.bmo,image2.bmp等

hope this helps 希望这可以帮助

You can use the following command: 您可以使用以下命令:

ffmpeg -s widthxheight -i input.yuv image%05d.bmp

Please make sure to define the widht and height in pixels. 请确保以像素为单位定义宽度和高度。 For example for Full HD it would be -s 1920x1080 , this is needed because the yuv format doesn't store any metadata for the video itself and you need to specify the resolution of the yuv file. 例如,对于Full HD,它将是-s 1920x1080 ,这是必需的,因为yuv格式不存储视频本身的任何元数据,并且您需要指定yuv文件的分辨率。

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

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