[FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

Dixit, Vishwanath vdixit at akamai.com
Tue Jan 9 11:28:33 EET 2018



On 1/9/18 2:41 PM, 刘歧 wrote:
>>>
>>
>> If only copy command of the document, it’s ok,
>> If input string by myself, It’s have problem, cannot be used.
>>
>>
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 1000k -b:a 64k -a53cc 1 -f hls  -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en"   -master_pl_name master.m3u8  live/out.m3u8
>> ffmpeg version N-89757-g42a5fe340f Copyright (c) 2000-2018 the FFmpeg developers
>>  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
>>  configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --cc='ccache gcc' --enable-nonfree --enable-videotoolbox
>>  libavutil      56.  7.100 / 56.  7.100
>>  libavcodec     58.  9.100 / 58.  9.100
>>  libavformat    58.  3.100 / 58.  3.100
>>  libavdevice    58.  0.100 / 58.  0.100
>>  libavfilter     7. 11.101 /  7. 11.101
>>  libswscale      5.  0.101 /  5.  0.101
>>  libswresample   3.  0.101 /  3.  0.101
>>  libpostproc    55.  0.100 / 55.  0.100
>> Input #0, lavfi, from 'color=red':
>>  Duration: N/A, start: 0.000000, bitrate: N/A
>>    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
>> Stream mapping:
>>  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
>> Press [q] to stop, [?] for help
>> [libx264 @ 0x7fadae801600] using SAR=1/1
>> [libx264 @ 0x7fadae801600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
>> [libx264 @ 0x7fadae801600] profile High, level 2.0
>> [libx264 @ 0x7fadae801600] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=25 keyint_min=2 scenecut=40 intra_refresh=0 rc_lookahead=25 rc=abr mbtree=1 bitrate=1000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
>> [hls @ 0x7fadae81ec00] Opening 'live/out0.ts' for writing
>> Output #0, hls, to 'live/out.m3u8':
>>  Metadata:
>>    encoder         : Lavf58.3.100
>>    Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 1000 kb/s, 25 fps, 90k tbn, 25 tbc
>>    Metadata:
>>      encoder         : Lavc58.9.100 libx264
>>    Side data:
>>      cpb: bitrate max/min/avg: 0/0/1000000 buffer size: 0 vbv_delay: -1
>> [hls @ 0x7fadae81ec00] Opening 'live/out1.ts' for writingte=N/A speed=0.514x
>> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
>> [hls @ 0x7fadae81ec00] Opening 'live/master.m3u8' for writing
>> [hls @ 0x7fadae81ec00] Opening 'live/out2.ts' for writingte=N/A speed=0.71x
>> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
>> [hls @ 0x7fadae81ec00] Opening 'live/out3.ts' for writingte=N/A speed=0.794x
>> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
>> [hls @ 0x7fadae81ec00] Opening 'live/out4.ts' for writingte=N/A speed=0.809x
>> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
>> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
>> frame=  202 fps= 25 q=-1.0 Lsize=N/A time=00:00:08.00 bitrate=N/A speed=0.99x
>> video:5kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
>> [libx264 @ 0x7fadae801600] frame I:9     Avg QP: 0.44  size:    72
>> [libx264 @ 0x7fadae801600] frame P:49    Avg QP: 0.14  size:    22
>> [libx264 @ 0x7fadae801600] frame B:144   Avg QP: 0.36  size:    16
>> [libx264 @ 0x7fadae801600] consecutive B-frames:  5.0%  0.0%  0.0% 95.0%
>> [libx264 @ 0x7fadae801600] mb I  I16..4: 100.0%  0.0%  0.0%
>> [libx264 @ 0x7fadae801600] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
>> [libx264 @ 0x7fadae801600] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%
>> [libx264 @ 0x7fadae801600] final ratefactor: -27.54
>> [libx264 @ 0x7fadae801600] 8x8 transform intra:0.0%
>> [libx264 @ 0x7fadae801600] coded y,uvDC,uvAC intra: 0.0% 0.3% 0.0% inter: 0.0% 0.0% 0.0%
>> [libx264 @ 0x7fadae801600] i16 v,h,dc,p: 93%  0%  7%  0%
>> [libx264 @ 0x7fadae801600] i8c dc,h,v,p: 100%  0%  0%  0%
>> [libx264 @ 0x7fadae801600] Weighted P-Frames: Y:0.0% UV:0.0%
>> [libx264 @ 0x7fadae801600] kb/s:4.05
>>
>>
>>
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 1000k -b:a 64k -a53cc 1 -f hls  -cc_stream_map "closecgroup:cc,instreamid:CC1,language:en"   -master_pl_name master.m3u8  live/out.m3u8
>> ffmpeg version N-89757-g42a5fe340f Copyright (c) 2000-2018 the FFmpeg developers
>>  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
>>  configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --cc='ccache gcc' --enable-nonfree --enable-videotoolbox
>>  libavutil      56.  7.100 / 56.  7.100
>>  libavcodec     58.  9.100 / 58.  9.100
>>  libavformat    58.  3.100 / 58.  3.100
>>  libavdevice    58.  0.100 / 58.  0.100
>>  libavfilter     7. 11.101 /  7. 11.101
>>  libswscale      5.  0.101 /  5.  0.101
>>  libswresample   3.  0.101 /  3.  0.101
>>  libpostproc    55.  0.100 / 55.  0.100
>> Input #0, lavfi, from 'color=red':
>>  Duration: N/A, start: 0.000000, bitrate: N/A
>>    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
>> Stream mapping:
>>  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
>> Press [q] to stop, [?] for help
>> [libx264 @ 0x7fb463005800] using SAR=1/1
>> [libx264 @ 0x7fb463005800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
>> [libx264 @ 0x7fb463005800] profile High, level 2.0
>> [libx264 @ 0x7fb463005800] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=25 keyint_min=2 scenecut=40 intra_refresh=0 rc_lookahead=25 rc=abr mbtree=1 bitrate=1000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
>> [hls @ 0x7fb46383bc00] Invalid keyval closecgroup:cc
>> [hls @ 0x7fb46383bc00] Variant stream info update failed with status ffffffea
>> Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
>> Error initializing output stream 0:0 --
>> [libx264 @ 0x7fb463005800] final ratefactor: 17.61
>> Conversion failed!
>> liuqideMacBook-Pro:xxx liuqi$
>>
>>
>
>
> I cannot sure use -cc_stream_map_ccgroup option is ok, because the ccgroup string is not standard, maybe it can be defined bu user.
> Maybe two ways:
> 1. use -cc_stream_map_ccgroup ? this way is defined the name by ffmpeg, cannot modify.
> 2. parse the closed captions group string by KeyValue way? maybe this is better.

Actually, these requirements have been already handled. The parsing is happening based on key value pairs. The keys are ‘ccgroup’, ‘instreamid’, ‘language’. The values for these keys can be set after ‘:’ as given the examples in the patch. 
I am assuming you are trying to set ccgroup name as closecgroup. In that case, please modify the command as below. Because, the string ‘ccgroup’ is a key value, whatever string that comes after ‘ccgroup:’ is the cc group name.  
./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 1000k -b:a 64k -a53cc 1 -f hls  -cc_stream_map "ccgroup:closecgroup,instreamid:CC1,language:en"   -master_pl_name master.m3u8  live/out.m3u8

To clarify further, consider user wants to set cc group name as ‘mycaptions’, instream id as ‘SERVICE60’ language as Spanish, in that case, the map string would be
-cc_stream_map "ccgroup:mycaptions,instreamid:SERVICE60,language:sp"  

>
> Thanks
>
> Steven
>
>
>






More information about the ffmpeg-devel mailing list