convert format from yuvj420p to yuv420p

99封情书 提交于 2020-07-17 06:54:18

问题


i'm trying to perform an algorithm to convert from yuvj420p to yuv420p. The difference between both formats are the range values.

yuvj420p [0-255] and yuv420p [16-239]

I want to know how to adapt the values to the new range.


回答1:


A bit late to this, but for future reference, in case it helps anyone, here is how to deal with this problem with FFmpeg.

When exporting, say, an uncompressed AVI from After Effects, sometimes the FFmpeg conversion seems to lack contrast, as if the range was being compressed. Adding

-pix_fmt yuvj420p

...to the command, when encoding with libx264, can fix this. However, on formats like webm (VP8) which don't support this pixel format, I've found options of the scale filtergraph have allowed me to adjust the range, while remaining in yuv420p, which might be more helpful in your case, and in any case where yuvj420p might not be supported. Try adding this flag:

-vf "in_range=mpeg:out_range=full"

From the docs:

in_range, out_range: Set in/output YCbCr sample range.

This allows the autodetected value to be overridden as well as allows forcing a specific value used for the output and encoder. If not specified, the range depends on the pixel format.

So, in my case, the entire command ended up looking like this:

ffmpeg -i master.mp4 -c:v libvpx -crf 12 -vf "scale=300:-1:in_range=mpeg:out_range=full, crop=300:168" -b:v 1M -c:a libvorbis -b:a 64k -ac 1 output_from_mp4_ranged.webm


来源:https://stackoverflow.com/questions/30703987/convert-format-from-yuvj420p-to-yuv420p

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