I have a bunch of .m3u8 files that contain video tracks in different resolutions and bitrates, and audio tracks in different laguages. I want to select the highest quality video stream and if available the audio track in a specified language.
I know how to select the audio track, currently I use
-map 0:m:language:en?
like this
ffmpeg -re -protocol_whitelist file,http,https,tcp,tls -i .\some_file.m3u8 -codec:a aac -c:v copy -f flv -map 0:m:language:en? rtmp://foo.com:1935/live/xyz
With that I only stream audio if the specified audio language is available, or audio and video in the default configuration if it's not.
I want to stream the best video track (the one ffmpeg picks by default) in both cases.
Typically, this needs chained ffmpeg commands,
ffmpeg -protocol_whitelist file,http,https,tcp,tls -i .\some_file.m3u8 -c copy -map 0:v -map 0:m:language:en? -f mpegts - | ffmpeg -re -f mpegts -i - -c:v copy -c:a aac -f flv rtmp://foo.com:1935/live/xyz