[FFmpeg-user] multiple HLS outputs with different stream maps

Viorel Dehelean synologic at gmail.com
Sat Jul 20 01:20:27 EEST 2019


Answering to myself, in my previous attempt, the second hls output expects
a separate set of transcode process, hence the unable to map stream error.

The better solution would be to use tee to send to multiple outputs,
however the latest git seems to be suffering from this
https://trac.ffmpeg.org/ticket/7907

For my usecase, i need two ABR outputs, one with separate audio renditions
(for the test case, just one) and one output with embedded audio.
The problem i am facing now with the latest git is as follows, with one
audio track encode process, the separate audio rendition output works well,
however the second ABR which needs to embed audio onto 4 video variants,
crashes with:

[hls @ 0x55f35ecd1000] Same elementary stream found more than once in two
different variant definitions #0 and #1

which seems to indicate that it does not like to use the same audio stream
into multiple variants, which led me to actually create 3 more audio
encodes, as audio encoding is not that expensive CPU wise, but now the
separate audio rendition output crashes with

[hls @ 0x55b804de5300] Unable to find mapping variant stream

which seems to indicate that the muxer has found some streams that are not
used in that output. It would be nice to not crash here :)

I will post a comment to 7907, however, maybe somebody has a better idea.

Here's what i tried (with 4 audio encodes)

./ffmpeg -ignore_unknown -async 1 -probesize 1M -analyzeduration 1000000 \
    -i "udp://<udp group>:1234?fifo_size=5000000&overrun_nonfatal=1"
-threads 0 -fflags +genpts \
    -filter_complex
"[0:v]yadif=0:-1:0[deinterlaced];[deinterlaced]split=4[v1][v2][v3][v4];[v1]copy[v1out];[v2]scale=w=1280:h=720:force_original_aspect_ratio=disable[v2scale];[v2scale]pad=width=1280:height=720:x=(ow-iw)/2:y=0:color=black[v2out];[v3]scale=w=800:h=450:force_original_aspect_ratio=disable[v3scale];[v3scale]pad=width=800:height=450:x=(ow-iw)/2:y=0:color=black[v3out];[v4]scale=w=480:h=270:force_original_aspect_ratio=disable[v4scale];[v4scale]pad=width=480:height=270:x=(ow-iw)/2:y=0:color=black[v4out]"
\
    -map [v1out] -x264opts:v:0 keyint=15:min-keyint=15:no-scenecut
-flags:v:0 +cgop -c:v:0 libx264 -profile:v:0 high -level 4.0 -preset
superfast -b:v:0 8000k -maxrate:v:0 10000k -minrate:v:0 4000k \
    -map [v2out] -x264opts:v:1 keyint=15:min-keyint=15:no-scenecut
-flags:v:1 +cgop -c:v:1 libx264 -profile:v:1 high -level 4.0 -preset
superfast -b:v:1 3000k -maxrate:v:1 3000k -minrate:v:1 1350k \
    -map [v3out] -x264opts:v:2 keyint=15:min-keyint=15:no-scenecut
-flags:v:2 +cgop -c:v:2 libx264 -profile:v:2 main -level 3.1 -preset
superfast -b:v:2 900k -maxrate:v:2 900k -minrate:v:2 450k \
    -map [v4out] -x264opts:v:3 keyint=15:min-keyint=15:no-scenecut
-flags:v:3 +cgop -c:v:3 libx264 -profile:v:3 baseline -level 3.0 -preset
superfast -b:v:3 450k -maxrate:v:3 450k -minrate:v:3 150k \
    -map a:0 -c:a:0 libfdk_aac -b:a:0 128k -metadata:s:a:0 language=ron \
    -map a:0 -c:a:1 libfdk_aac -b:a:1 128k -metadata:s:a:1 language=ron \
    -map a:0 -c:a:2 libfdk_aac -b:a:2 128k -metadata:s:a:2 language=ron \
    -map a:0 -c:a:3 libfdk_aac -b:a:3 128k -metadata:s:a:3 language=ron \
    "[f=hls:onfail=ignore:var_stream_map=\'v:0,agroup:audio
v:1,agroup:audio v:2,agroup:audio v:3,agroup:audio
a:0,agroup:audio,language:ron,default:yes\':use_localtime=1:hls_allow_cache=0:hls_flags=discont_start+delete_segments+omit_endlist+second_level_segment_index+second_level_segment_size+second_level_segment_duration+program_date_time:\

hls_start_number_source=datetime:hls_time=6:hls_list_size=10:hls_segment_filename=/origin/35f4574f4aed42d083de1087851f8712/%v_stream_%%04d_%%08s_%%013t.ts:master_pl_name=playlist.m3u8]/origin/35f4574f4aed42d083de1087851f8712/variant_%v_manifest.m3u8|\
    [f=hls:var_stream_map=\'v:0,a:0 v:1,a:1 v:2,a:2
v:3,a:3\':use_localtime=1:hls_allow_cache=0:hls_flags=discont_start+temp_file+delete_segments+omit_endlist+second_level_segment_index+second_level_segment_size+second_level_segment_duration+program_date_time:\

hls_start_number_source=datetime:hls_time=6:hls_list_size=10:hls_segment_filename=/origin/35f4574f4aed42d083de1087851f8712/mux/%v_stream2_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts:master_pl_name=playlist2.m3u8]/origin/35f4574f4aed42d083de1087851f8712/mux/variant2_%v_manifest.m3u8"

Thanks,
Viorel


On Fri, Jul 19, 2019 at 9:50 PM Viorel Dehelean <synologic at gmail.com> wrote:

> Slight different command line, i'm trying to produce 2 separate abr
> streams with different stream map structures, as well as doing transcoding
> but that should not be of any circumstance:
>
> ./ffmpeg -ignore_unknown -async 1 -probesize 1M -analyzeduration 1000000 \
>     -i "udp://<udp group>:1234?fifo_size=5000000&overrun_nonfatal=1"
> -threads 0 -fflags +genpts \
>     -filter_complex
> "[0:v]yadif=0:-1:0[deinterlaced];[deinterlaced]split=4[v1][v2][v3][v4];[v1]copy[v1out];[v2]scale=w=1280:h=720:force_original_aspect_ratio=disable[v2scale];[v2scale]pad=width=1280:height=720:x=(ow-iw)/2:y=0:color=black[v2out];[v3]scale=w=800:h=450:force_original_aspect_ratio=disable[v3scale];[v3scale]pad=width=800:height=450:x=(ow-iw)/2:y=0:color=black[v3out];[v4]scale=w=480:h=270:force_original_aspect_ratio=disable[v4scale];[v4scale]pad=width=480:height=270:x=(ow-iw)/2:y=0:color=black[v4out]"
> \
>     -map [v1out] -x264opts:v:0 keyint=15:min-keyint=15:no-scenecut
> -flags:v:0 +cgop -c:v:0 libx264 -profile:v:0 high -level 4.0 -preset
> superfast -b:v:0 8000k -maxrate:v:0 10000k -minrate:v:0 4000k \
>     -map [v2out] -x264opts:v:1 keyint=15:min-keyint=15:no-scenecut
> -flags:v:1 +cgop -c:v:1 libx264 -profile:v:1 high -level 4.0 -preset
> superfast -b:v:1 3000k -maxrate:v:1 3000k -minrate:v:1 1350k \
>     -map [v3out] -x264opts:v:2 keyint=15:min-keyint=15:no-scenecut
> -flags:v:2 +cgop -c:v:2 libx264 -profile:v:2 main -level 3.1 -preset
> superfast -b:v:2 900k -maxrate:v:2 900k -minrate:v:2 450k \
>     -map [v4out] -x264opts:v:3 keyint=15:min-keyint=15:no-scenecut
> -flags:v:3 +cgop -c:v:3 libx264 -profile:v:3 baseline -level 3.0 -preset
> superfast -b:v:3 450k -maxrate:v:3 450k -minrate:v:3 150k \
>     -map a:0 -c:a:0 libfdk_aac -b:a:0 128k -metadata:s:a:0 language=ron \
>     -f hls \
>     -var_stream_map "v:0,agroup:audio v:1,agroup:audio v:2,agroup:audio
> v:3,agroup:audio a:0,agroup:audio,name:Romanian,language:ron,isdefault:yes"
> \
>     -use_localtime 1 -hls_allow_cache 0 -hls_flags
> delete_segments+omit_endlist+second_level_segment_index+second_level_segment_size+second_level_segment_duration+program_date_time
> \
>     -hls_start_number_source datetime -hls_time 6 -hls_list_size 10
> -hls_segment_filename
> /origin/35f4574f4aed42d083de1087851f8712/%v_stream_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts
> \
>     -master_pl_name playlist.m3u8
> /origin/35f4574f4aed42d083de1087851f8712/variant_%v_manifest.m3u8 \
>     -var_stream_map "v:0,a:0 v:1,a:0 v:2,a:0 v:3,a:0" \
>     -use_localtime 1 -hls_allow_cache 0 -hls_flags
> delete_segments+omit_endlist+second_level_segment_index+second_level_segment_size+second_level_segment_duration+program_date_time
> \
>     -hls_start_number_source datetime -hls_time 6 -hls_list_size 10
> -hls_segment_filename
> /origin/35f4574f4aed42d083de1087851f8712/mux/%v_stream2_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts
> \
>     -master_pl_name playlist2.m3u8
> /origin/35f4574f4aed42d083de1087851f8712/mux/variant2_%v_manifest.m3u8
>
>
> and i'm getting:
>
>
> [hls @ 0x561859fcf900] Unable to map stream at v:1
> [hls @ 0x561859fcf900] Variant stream info update failed with status
> ffffffea
> Could not write header for output file #1 (incorrect codec parameters ?):
> Invalid argument
> Error initializing output stream 1:0 --
>
> On Fri, Jul 19, 2019 at 5:34 PM andrei ka <andrei.k.gml at gmail.com> wrote:
>
>> oups, i had extra space in command line, actually it works fine with 2nd
>> stream_map
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
>


More information about the ffmpeg-user mailing list