[FFmpeg-user] a -vf for broadcast safe

Dave Rice dave at dericed.com
Wed Dec 30 18:58:18 CET 2015


> On Dec 30, 2015, at 12:51 PM, Dave Rice <dave at dericed.com> wrote:
> 
> 
>> On Feb 12, 2014, at 4:43 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
>> 
>> Jim Shupert <jshupert <at> pps-inc.com> writes:
>> 
>>> input a unCompressed  yuv avi and get a second 
>>> Uncompressed yuv avi or mov and it would be 
>>> 'broadcast safe'.
>> 
>> Rereading your original post:
>> Could you provide an uncompressed yuv avi that 
>> needs the filter you have in mind?
>> (One frame is probably enough.)
> 
> Responding late, as I find myself in need of this filter as well.
> 
> A sample that needs the filter can be generated via:
> 
> ffmpeg -f lavfi -i color=gray:s=256x256 -vf format=yuv444p,geq=lum=X,scale=out_range=tv -vframes 1 -pix_fmt yuv444p -c:v rawvideo -y needsbroadcastsafe.nut
> ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
>  built with Apple LLVM version 7.0.2 (clang-700.1.81)
>  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libfaac --enable-libass --enable-ffplay --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-nonfree --enable-vda
>  libavutil      54. 31.100 / 54. 31.100
>  libavcodec     56. 60.100 / 56. 60.100
>  libavformat    56. 40.101 / 56. 40.101
>  libavdevice    56.  4.100 / 56.  4.100
>  libavfilter     5. 40.101 /  5. 40.101
>  libavresample   2.  1.  0 /  2.  1.  0
>  libswscale      3.  1.101 /  3.  1.101
>  libswresample   1.  2.101 /  1.  2.101
>  libpostproc    53.  3.100 / 53.  3.100
> Input #0, lavfi, from 'color=gray:s=256x256':
>  Duration: N/A, start: 0.000000, bitrate: N/A
>    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256 [SAR 1:1 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
> Output #0, nut, to 'needsbroadcastsafe.nut':
>  Metadata:
>    encoder         : Lavf56.40.101
>    Stream #0:0: Video: rawvideo (444P / 0x50343434), yuv444p, 256x256 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 51200 tbn, 25 tbc
>    Metadata:
>      encoder         : Lavc56.60.100 rawvideo
> Stream mapping:
>  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
> Press [q] to stop, [?] for help
> frame=    1 fps=0.0 q=-0.0 Lsize=     192kB time=00:00:00.04 bitrate=39382.2kbits/s    
> video:192kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.154114%
> 
> The result of `ffmpeg -i needsbroadcastsafe.nut -vf broadcastsafe nowbroadcastsafe.nut` would result in the output containing luma values only between 16-235 inclusively (8 bit) and 16-240 for chroma planes.

Here’s an ugly method using the geq filter to force all Y samples to a 16-235 range and all U/V samples to a 16-240 range.

ffmpeg -i needsbroadcastsafe.nut -vf "geq=lum=if(gt(lum(X\,Y)\,235)\,235\,if(lt(lum(X\,Y)\,16)\,16\,lum(X\,Y))):cb=if(gt(lum(X\,Y)\,240)\,240\,if(lt(lum(X\,Y)\,16)\,16\,lum(X\,Y)))" -y nowbroadcastsafe.nut
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libfaac --enable-libass --enable-ffplay --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-nonfree --enable-vda
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, nut, from 'needsbroadcastsafe.nut':
  Metadata:
    encoder         : Lavf56.40.101
  Duration: 00:00:00.36, start: 0.000000, bitrate: 43703 kb/s
    Stream #0:0: Video: rawvideo (444P / 0x50343434), yuv444p, 256x256, SAR 1:1 DAR 1:1, 25 fps, 25 tbr, 51200 tbn, 51200 tbc
    Metadata:
      encoder         : Lavc56.60.100 rawvideo
Output #0, nut, to 'nowbroadcastsafe.nut':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 256x256 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 51200 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.60.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
frame=   10 fps=0.0 q=2.0 Lsize=       4kB time=00:00:00.40 bitrate=  91.3kbits/s    
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.206121%

I’ll leave it to Kieran to complain if this is the wrong way to do this.

Dave Rice



More information about the ffmpeg-user mailing list