streamlinevideo / streamline

A reference system for end to end live streaming video. Capture, encode, package, uplink, origin, CDN, and player.
MIT License
748 stars 87 forks source link

Question: -g missing from -map #15

Closed vaage closed 5 years ago

vaage commented 5 years ago

Why in the code below is -map '[8out].... the only one with out a -g value? All other ffmpeg commands in the file, following a similar structure, have a -g value for each -map entry.

...

# If the input is 4k then encode with 4k encoding settings

elif [ "${res}" == "2160" ] || [ "${roundedfps}" == "25" ]
then
    ffmpeg \
    -hide_banner \
    -queue_size 4294967296 \
    -f decklink \
    -i "$device" \
    -filter_complex \
    "[0:v]format=yuv420p,split=8[1][2][3][4][5][6][7][8]; \
    [1]hwupload_cuda,scale_npp=-1:288:interp_algo=super,hwdownload[1out]; \
    [2]hwupload_cuda,scale_npp=-1:360:interp_algo=super,hwdownload[2out]; \
    [3]hwupload_cuda,scale_npp=-1:432:interp_algo=super,hwdownload[3out]; \
    [4]hwupload_cuda,scale_npp=-1:540:interp_algo=super,hwdownload[4out]; \
    [5]hwupload_cuda,scale_npp=-1:720:interp_algo=super[5out]; \
    [6]hwupload_cuda,scale_npp=-1:1080:interp_algo=super[6out]; \
    [7]hwupload_cuda,scale_npp=-1:1440:interp_algo=super[7out]; \
    [8]null[8out]" \
    -map '[1out]' -c:v:0 ${x264enc} -g 50 -b:v:0 400k \
    -map '[2out]' -c:v:1 ${x264enc} -g 50 -b:v:1 800k \
    -map '[3out]' -c:v:2 ${x264enc} -g 50 -b:v:2 1100k \
    -map '[4out]' -c:v:3 ${x264enc} -g 50 -b:v:3 2200k \
    -map '[5out]' -c:v:4 ${nvenc} -g 50 -b:v:4 3300k \
    -map '[6out]' -c:v:5 ${nvenc} -g 50 -b:v:5 6000k \
    -map '[7out]' -c:v:6 ${nvenc} -g 50 -b:v:6 12000k \
    -map '[8out]' -c:v:7 ${nvenc} -b:v:7 20000k \
    -c:a:0 aac -b:a 128k -map 0:a \
    ${hlsargs} \
    -var_stream_map "a:0,agroup:teh_audio \
    v:0,agroup:teh_audio \
    v:1,agroup:teh_audio \
    v:2,agroup:teh_audio \
    v:3,agroup:teh_audio \
    v:4,agroup:teh_audio \
    v:5,agroup:teh_audio \
    v:6,agroup:teh_audio \
    v:7,agroup:teh_audio" \
    http://${1}/${vid}_%v.m3u8 >/dev/null 2>~/streamline/logs/encode.log &

...
colleenkhenry commented 5 years ago

Just a bug :). I'll fix it.

On Fri, Nov 23, 2018, 11:48 AM Aaron Vaage <notifications@github.com wrote:

Why in the code below is -map '[8out].... the only one with out a -g value? All other ffmpeg commands in the file, following a similar structure, have a -g value for each -map entry.

...

If the input is 4k then encode with 4k encoding settings

elif [ "${res}" == "2160" ] || [ "${roundedfps}" == "25" ] then ffmpeg \ -hide_banner \ -queue_size 4294967296 \ -f decklink \ -i "$device" \ -filter_complex \ "[0:v]format=yuv420p,split=8[1][2][3][4][5][6][7][8]; \ [1]hwupload_cuda,scale_npp=-1:288:interp_algo=super,hwdownload[1out]; \ [2]hwupload_cuda,scale_npp=-1:360:interp_algo=super,hwdownload[2out]; \ [3]hwupload_cuda,scale_npp=-1:432:interp_algo=super,hwdownload[3out]; \ [4]hwupload_cuda,scale_npp=-1:540:interp_algo=super,hwdownload[4out]; \ [5]hwupload_cuda,scale_npp=-1:720:interp_algo=super[5out]; \ [6]hwupload_cuda,scale_npp=-1:1080:interp_algo=super[6out]; \ [7]hwupload_cuda,scale_npp=-1:1440:interp_algo=super[7out]; \ [8]null[8out]" \ -map '[1out]' -c:v:0 ${x264enc} -g 50 -b:v:0 400k \ -map '[2out]' -c:v:1 ${x264enc} -g 50 -b:v:1 800k \ -map '[3out]' -c:v:2 ${x264enc} -g 50 -b:v:2 1100k \ -map '[4out]' -c:v:3 ${x264enc} -g 50 -b:v:3 2200k \ -map '[5out]' -c:v:4 ${nvenc} -g 50 -b:v:4 3300k \ -map '[6out]' -c:v:5 ${nvenc} -g 50 -b:v:5 6000k \ -map '[7out]' -c:v:6 ${nvenc} -g 50 -b:v:6 12000k \ -map '[8out]' -c:v:7 ${nvenc} -b:v:7 20000k \ -c:a:0 aac -b:a 128k -map 0:a \ ${hlsargs} \ -var_stream_map "a:0,agroup:teh_audio \ v:0,agroup:teh_audio \ v:1,agroup:teh_audio \ v:2,agroup:teh_audio \ v:3,agroup:teh_audio \ v:4,agroup:teh_audio \ v:5,agroup:teh_audio \ v:6,agroup:teh_audio \ v:7,agroup:tehaudio" \ http://${1}/${vid}%v.m3u8 >/dev/null 2>~/streamline/logs/encode.log &

...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/streamlinevideo/streamline/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/ACdZabW2buMN4PW77eFXr_xwD6S69NMoks5uyFEJgaJpZM4YxEmx .

vaage commented 5 years ago

Since most of these ffmpeg commands follow the same structure, could I suggest that it be converted to a function so that small issues like this can be avoided? Something like:

descriptive_name() {
    local what_ever_g_really_means=${1}
    // other params....

  ffmpeg -hide_banner ...
}

Doing something like this will make it easier for new readers to understand what all is happening since the high-level descriptions will give us a better idea of "what is happening" without needing to understand the "how it's happpening".

colleenkhenry commented 5 years ago

I'm open to changing it however people think it will be the most readable for people trying to learn. :)

On Fri, Nov 23, 2018, 11:55 AM Aaron Vaage <notifications@github.com wrote:

Since most of these ffmpeg commands follow the same structure, could I suggest that it be converted to a function so that small issues like this can be avoided? Something like:

descriptive_name() { local what_ever_g_really_means=${1} // other params....

ffmpeg -hide_banner ... }

Doing something like this will make it easier for new readers to understand what all is happening since the high-level descriptions will give us a better idea of "what is happening" without needing to understand the "how it's happpening".

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/streamlinevideo/streamline/issues/15#issuecomment-441310489, or mute the thread https://github.com/notifications/unsubscribe-auth/ACdZaaZ8X2Dd0c6KfXT3w2lCOtLi9JZTks5uyFLLgaJpZM4YxEmx .

colleenkhenry commented 5 years ago

@vaage I added in the extra -g