lisamelton / video-transcoding-scripts

Utilities to transcode, inspect and convert videos.
MIT License
603 stars 76 forks source link

Multiple main audio tracks (multi-language transcoding) #7

Closed t089 closed 9 years ago

t089 commented 9 years ago

Hi Don,

First off: Thank you for your great work! The scripts are truly awesome and a pleasure to work/play with.

I often want to include multiple languages in my transcodings. For each language I'd like to have both the AC-3 and AAC version (iTunes does the same thing for multi-language files). Please correct me if I am wrong, but I couldn't figure out a way to achieve this with the existing --add-audio option. So I've changed transcode_video.sh to support multiple main audio tracks with the --audio option.

Basically instead of accepting a single main audio track, --audio now takes an array of tracks (separated by ,). Each track is handled by your existing code and the result is appended to the audio_track_list, audio_track_name_list, audio_encoder_list, and audio_bitrate_list.

I believe my changes won't break other options, though I haven't yet tested all scenarios. Maybe you can take a look and tell me what you think? Additionally, I'm afraid convert_video.sh will not work with multi-main-audio-track files, as it expects a single main audio track, right?

Thanks you! Best Tobias

hdready commented 9 years ago

Done something similar in my fork for multiple audio tracks (using the batch-file): https://github.com/hdready/video-transcoding-scripts

But convert-video remains a mystery to me...

lisamelton commented 9 years ago

Tobias,

Glad you like the scripts and find them useful! And that you're willing to submit suggestions and patches. That's marvelous. Thank you!

Yes, you are correct, there's currently no way to add dual-format audio tracks with the --add-audio option. And I didn't realize how many people wanted a feature like this until recently. What a stupid I am, as they say. (Or, more accurately, what a mostly mono-lingual and typically unaware American I am.) My apologies.

The good news is that I'm already working on patch to do this. If there's any bad news, at least for your particular patch, it's that I don't plan to add the feature by modifying the original --audio option.

Let me explain why.

I've tried carefully since including the --add-audio option to educate users about the difference between the main audio track and auxiliary optional audio tracks. Especially how all these tracks are treated by software or hardware players. Meaning that only one of these audio tracks is played by default. And that's either the first track in the input or the one explicitly identified by the --audio option.

Semantics are important. Especially when it comes to understanding and using a command line tool. And the semantics of transcode-video.sh are that extra audio tracks are created with the --add-audio option.

Also, I don't want to overload --audio by specifying multiple tracks in a comma-separated list. This is the same design mistake the HandBrake team made with their command line interface for audio options. What do I mean by that?

Consider the --aname option for specifying audio track names with HandBrakeCLI. It's also a comma-separated list. It has to be because the HandBrake team overloaded their --audio option to specify multiple tracks, much like your patch.

And because their track names comma are comma-separated list, none of those names can contain commas. It's an unnecessary limitation due to a poor design. One that I've went to great lengths to work around in version 5.0 of my script.

You'll also notice that every time the HandBrake team needs to add another control attribute for an audio track, they have to add another option that takes a comma-seprated list.

This is exactly why I designed the interface to my script with --add-audio, --add-subtitle, etc. options. That way all of a specific track's attributes are in one argument for easy implementation and, more importantly, easy understanding by the user.

Here's the interface of my current design for your feature:

    --add-audio [double,]TRACK[,NAME]
                    add audio track in AAC format
                         with optional "double" flag to include AC-3 format
                         with optional name
                        (can be used multiple times)

And by calling the flag "double," I mirror the nomenclature I've already introduced to optionally limit main audio to a "single" track.

Let me know if this works for you.

BTW, you are also correct that convert-video.sh currently doesn't handle unusual audio track layouts very well. And I'm in the process of re-writing it (again) to do so.

I'm closing this particular pull request but that doesn't mean I won't add this feature. It'll probably be at least a week before I land my version because testing the code is even harder than writing it. :)

Thanks again for your input!

lisamelton commented 9 years ago

Tobias,

If I can be so bold to ask... What's your Twitter account so I can make sure we stay in touch? It's not on your GitHub page.

Also, feel free to open an issue for the pending feature.

t089 commented 9 years ago

Don,

Thanks for your feedback! I think you are right, adding this functionality to --add-audio is probably a better approach. I first thought of this as well, but than found that adding a simple loop around your code for the main audio track basically does the trick with --audio. So, I went for it... lazy scientist...

I'm looking forward to testing your solution!

Best Tobias Twitter: @tobi089

lisamelton commented 9 years ago

Followed! Just like Martin, who also commented.

Hey, sometimes lazy is good so don't worry about it. :)

I'll send you guys a message when it's ready.

lisamelton commented 9 years ago

OK, version 5.4 is in with the new feature. Let me know if I broke anything. :)

t089 commented 9 years ago

Awesome! I will try a new transcoding tomorrow and test the script! Best T

Am 10.01.2015 um 23:08 schrieb Don Melton notifications@github.com:

OK, version 5.4 is in with the new feature. Let me know if I broke anything. :)

— Reply to this email directly or view it on GitHub.