[FFmpeg-user] clipping samples to broadcast range in an mpeg2video output

Paul B Mahol onemda at gmail.com
Fri Feb 5 22:07:22 CET 2016


On 2/5/16, Dave Rice <dave at dericed.com> wrote:
> Hi all,
> I am having trouble creating an mpeg2video output that conforms to 16-235
> broadcast range. I'd like to find a way to have an input which is yuv420p
> but has luma values out of broadcast range but clip to broadcast range while
> encoding to mpeg2.
>
> To demonstrate the issue, I generate a yuv420p file with samples in the out
> of broadcast range via:
>
> ffmpeg -f lavfi -i
> "nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128"
> -c:v ffv1 -t 10 sample.mkv
>
> I can then clip the samples using clipval in the lut filter and see the
> clipped values in a waveform with:
>
> ffmpeg -i sample.mkv -vf lut=y=clipval:u=clipval:v=clipval -c:v ffv1 -f nut
> - | ffplay - -vf waveform
> The waveform shows the values clipped at 16 and 235.
>
> However I need the output to use mpeg2video. When I change lossless ffv1 to
> mpeg2video with:
>
> ffmpeg -i sample.mkv -vf lut=y=clipval:u=clipval:v=clipval -c:v mpeg2video
> -f nut - | ffplay - -vf waveform
>
> The output shows many sample values above 235. The lossy mpeg2video encoding
> seems to place values above 235 while the lossless ffv1 doesn't. Is there a
> way to encode in mpeg2video without having values over 235 in the output?

Appears to be mpeg2video bug, can others confirm?


More information about the ffmpeg-user mailing list