Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert format from yuvj420p to yuv420p

Tags:

video

yuv

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.

like image 222
F.bernal Avatar asked Jun 08 '15 08:06

F.bernal


1 Answers

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
like image 198
J Griffiths Avatar answered Oct 07 '22 05:10

J Griffiths