bentasker / HLS-Stream-Creator

Simple Bash Script to take a media file, segment it and create an M3U8 playlist for serving using HLS
BSD 3-Clause "New" or "Revised" License
273 stars 101 forks source link

Audio Bitrate Switch Missing #33

Open vineetmultitv opened 5 years ago

vineetmultitv commented 5 years ago

The script seems great though missing audio bitrate control switches while encoding for Adaptive streams, Along with Video bitrates, audio can also be scaled down, is it missing or intentional?

bentasker commented 5 years ago

It's been omitted purely on the basis that it hasn't been needed yet. I'm more than happy to accept a pull implementing it though.

vineetmultitv commented 5 years ago

Sure, It can be done by leveraging existing bitrate switch -b [AudioBitrate]-[VideoBitrate]-[width]x[height]

bentasker commented 5 years ago

That's one of the options I considered when I raised the FR (HLS-34) earlier.

It's the simplest option to implement, but also the least flexible.

Breaking the audio out into seperate tracks is harder to do, but allows a lot more flexibility (as it's a step on the path to being able to have alternative audio tracks - for multilanguage support - as well as things like having audio only adaptive streams - for radio streams).

However, because it's potentially that much harder (particularly if it's to be supported in linear streams too) I'm more than happy to accept a pull request which implements the simpler approach of passing into -b. I don't currently have the time to implement this myself.

What I would say though, is it would be prudent to have a different delimiter to denote audio, as it reduces the need to worry about what order things have been specified in (reducing the scope for operator error).

So something like -b [VideoBW]-[width]x[height]:[audiobw] rather than splitting with a hyphen. It doesn't have to be a colon specifically.

Denoder commented 4 years ago

@bentasker here's a guide created recently, i not sure how well it could be integrated with this script: https://www.martin-riedl.de/2020/05/31/using-ffmpeg-as-a-hls-streaming-server-part-9-multiple-audio-languages/

bentasker commented 4 years ago

Thanks, but splitting the audio out with ffmpeg itself isn't too challenging, the challenge really is in how you turn that into sensible command line arguments to pass into HLS-Stream-Creator.

Taking that post as an example, doing it with ffmpeg directly is "simply" a case of mapping streams

-map a:0 -map a:1 -c:a aac -b:a 128k -ac 2 \

.... -var_stream_map "a:0,agroup:audio128,language:GER a:1,agroup:audio128,language:ENG v:0,agroup:audio128 v:1,agroup:audio128"

Which is fine if you know the layout of your input, or how to discover it. If you don't, then it's almost completely incomprehensible.

Under the hood, we'd end up building a command not dissimilar to that, but the challenge really lies in how you best present the option to users in a simplified manner.