ffmepg处理yuv视频的系列之三
最近发现数据集里的yuv大部分是8bit,但是有一部分是10bit或者16bit的,默认的yuv播放器打不开,也不利于数据集制作。所以就想用ffmpeg进行处理,记录一下方法。10bit能够容纳更多的色彩,获得更好的动态范围。
ffmpeg里面yuv的格式定义了很多种,比如下面:
PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
我们平时常见的yuv默认的是yuv420p,是8bit。我看有人问如何从10bit转8bit,查了一下网上没有写。结果我发现ffmpeg默认420p就是8bit。
例如我想将一个分辨率为1920x1080,名字为“test_444p_10bit.yuv”转换为420p 8bit的格式,方法如下:
ffmpeg -s 1920x1080 -pix_fmt yuv444p10le -i test_444p_10bit.yuv -pix_fmt yuv420p test_420p_8bit.yuv
那如果是yuv420p test_420p_8bit.yuv转换为444p 10bit,方法如下:
ffmpeg -s 1920x1080 -pix_fmt yuv420p -i test_420p_8bit.yuv -pix_fmt yuv444p10be test_444p_10bit.yuv
不清楚yuv是10be还是10le,可以用下面这个播放器(能够播放10bit的yuv)鉴别:https://sourceforge.net/projects/raw-yuvplayer/
————————————————
版权声明:本文为CSDN博主「学EE的粒粒」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/baoyongshuai1509/article/details/83927538
来源:https://blog.csdn.net/coloriy/article/details/100766526