Log in

View Full Version : Splitting TrueHD stream into separate songs


staygroovy
7th May 2016, 16:20
Apologies if this is a dumb question that's already been answered.

I just managed to successfully extract TrueHD multichannel audio stream (24bit/96kHz 5.1) from a BD disc image of an audio album release, but as one continuous file.

When scanning the mounted image, eac3to did say 1: Chapters, 10 Chapters
This matches the number of songs on this album.

Is there a way to extract each of those songs into individual audio files according to the playlist/chapter information embedded in this disc, or is this something that has to be done manually afterwards? :confused:

I have been looking on the wiki and tried searching for this, but not managed to find any answers with much success so far.

Thanks in advance.

nautilus7
7th May 2016, 16:45
If there are separate playlist files for each song, then you can extract each song at a time. This is the only way.

staygroovy
7th May 2016, 17:06
If there are separate playlist files for each song, then you can extract each song at a time. This is the only way.

So in my case all I could see was one playlist (.mpls file) made of seamlessly joining the m2ts segments.

1) /BDMV/PLAYLISTS/00001.mpls, 0:39:21
[0+1+12+13+14+15+16+17+18+19].m2ts
- Chapters, 10 chapters

But these segments themselves are not accessible, right?

Boulder
7th May 2016, 17:11
You can use eac3to on those m2ts files, they are probably separate songs each.

staygroovy
7th May 2016, 17:42
You can use eac3to on those m2ts files, they are probably separate songs each.
I am terribly sorry but I am unable to find any example of such commands to specifically extract .m2ts files in the wiki, and searching the thread takes me to a lot of dead ends.

And the random questions to be able to post are making me feel like I am being scolded by some sadistic headmaster.

Boulder
7th May 2016, 17:47
You should get rid of the random questions soon enough if not already :)

If I'm not mistaken, you can use eac3to "path\to\the\m2ts\file.m2ts" and then use the info to process the file.

There's also tsMuxerGUI which can open m2ts files and you can remux them as you like.

staygroovy
7th May 2016, 17:59
If I'm not mistaken, you can use eac3to "path\to\the\m2ts\file.m2ts" and then use the info to process the file.


Yes, it does indeed work. I should have been a bit more inquisitive in exploring the folder structure. Thank you so much! :thanks:

Am I correct in assuming that this will have to be one song file at a time, and that there is no real way to process 'all of the separated tracks at once' via the command line?

Which leads me to the next question, do any of the GUI versions support such batch extractions from a group of .m2ts sources to distinct, separate output files? (this being an audio BD, surely with none of the level of complexity found in movies with different language streams, subtitles and the likes)

Boulder
7th May 2016, 18:06
The only way I can think of is using the "for" command in the command prompt.

Which means something like for %f in (*.m2ts) do "path\to\eac3to\eac3to.exe" "%f" 3: "path\to\destination\folder\%~nf.thd" if you are in the directory where the m2ts files are. This would extract the track number 3 from each m2ts file and use the same name as the m2ts file but with the extension .thd.

staygroovy
7th May 2016, 18:22
The only way I can think of is using the "for" command in the command prompt.

Which means something like for %f in (*.m2ts) do "path\to\eac3to\eac3to.exe" "%f" 3: "path\to\destination\folder\%~nf.thd" if you are in the directory where the m2ts files are. This would extract the track number 3 from each m2ts file and use the same name as the m2ts file but with the extension .thd.

I could sense there was a Jedi Knight in the room wielding that script foo magic. :D

This being a mounted read-only disc image I'd wager I would probably have to copy it first.

But it's very intriguing to see this can be done. Was there any particular reason you picked an output of ".thd", or only for the sake of the example?

Thanks again for taking time out to lend a hand! I did get rid of the annoying questions before being able to post, and BTW the reason I haven't posted a lot is because most of the time I've been using eac3to for reasonably simple extractions, and it's always worked without a hitch. Extraction from BD images seems a bit more challenging.

Boulder
7th May 2016, 18:30
Just set the path after the track selection and there's no need to have the source copied. I usually convert lossless audio tracks to FLAC, with TrueHD it saves quite a few bits because it throws away the embedded AC3 track. Thd was just an example of an extension.

So if you want to extract the files marked as track 3 to FLAC-encoded ones to c:\temp, you would change to the m2ts folder and then call for %f in (*.m2ts) do "path\to\eac3to\eac3to.exe" "%f" 3: "c:\temp\%~nf.flac" .

staygroovy
7th May 2016, 19:07
Just set the path after the track selection and there's no need to have the source copied.

Yes, of course. I did and it worked flawlessly right out of the box. :thanks:

I am in your debt, thank you so very much for taking time out and showing me this, I am not experienced at shell scripting so it's pretty fascinating. Does the nf part in "%~nf.flac" mean "generate new file" ?

And I guess the 'for' statement automatically terminates once it's recursively gone through the list of .m2ts file without any explicit need to have any sort of 'end' statement (implied)?

Boulder
7th May 2016, 19:15
No problem, just goes to show you that even with new OS's, the command line is a powerful tool :)

In for, ~n means "filename only" and the f comes from the beginning of the command (%f). So it basically means, take the file that is being processed (%f) and use only the filename and not the extension part (because we want to change it). And yes, for simply parses the directory and ends when it doesn't find any more files. You can also make it run through subfolders with the /s parameter.

This is somewhat off-topic for this thread, so tebasuna51 may want to move the posts to a new thread if it's more appropriate.

tebasuna51
7th May 2016, 22:04
This is somewhat off-topic for this thread, so tebasuna51 may want to move the posts to a new thread if it's more appropriate.

Done.

staygroovy
7th May 2016, 22:33
Done.

Will keep that in mind next time I have a question, sorry for giving you extra stuff to do.

Music Fan
7th May 2016, 23:36
Am I correct in assuming that this will have to be one song file at a time, and that there is no real way to process 'all of the separated tracks at once' via the command line?
Maybe not with eac3to, but once you extracted the thd track with eac3to, you can try to divide it in chapters with MKVmerge ; load the thd, go in the Global tab, splitting, and select Split Before Chapters.
Or choose "split by parts based on timecodes" and type manually the chapters timecodes.
I don't know if it can work directly with the THD file, you may need to mux it in MKV first (or actually mka as there is no video), but it's quick.
Then load this mka and split it, you will get several mka files.

StainlessS
8th May 2016, 03:11
staygroovy,
You can in a command prompt window, type "for /?" to get the entire syntax for 'for' statement.
"cmd /?" for general assistance on cmd.exe.

EDIT: "help for" would also work. (might be easier to remember)

staygroovy
8th May 2016, 04:20
staygroovy,
You can in a command prompt window, type "for /?" to get the entire syntax for 'for' statement.
"cmd /?" for general assistance on cmd.exe.

EDIT: "help for" would also work. (might be easier to remember)
Thanks, and yeah it probably wouldn't hurt for me to familiarize myself a bit more with MS shell scripting. I'm actually used bash under Linux/OS-X a bit more, but since most of these tools here seem to be the exclusive province of Windows....

So far the thing that's frustrated me the most is that MS's command line window doesn't seem to allow me to copy text from its output. Whereas with bash I can definitely do that, select a bit of the output and do whatever I want with it.

staygroovy
8th May 2016, 04:23
Maybe not with eac3to, but once you extracted the thd track with eac3to, you can try to divide it in chapters with MKVmerge ; load the thd, go in the Global tab, splitting, and select Split Before Chapters.
Or choose "split by parts based on timecodes" and type manually the chapters timecodes.
I don't know if it can work directly with the THD file, you may need to mux it in MKV first (or actually mka as there is no video), but it's quick.
Then load this mka and split it, you will get several mka files.
This got me thinking, unfortunately I am not so familiar with the byzantine structure of the way Blu-Ray files are organized, but I was wondering where the meta-data was kept. Besides the 'chapter.txt' file I can output from one of the streams, there has to be some other area where the tagging data for the chapters might be residing.

staygroovy
8th May 2016, 04:29
Done.

One thing, I am pretty sure the stuff Boulder posted could really be useful for many other users besides myself, it could be good to expand the wiki to include a small section on scripting examples from the command line.

This stuff seems to be so powerful, and well worth documenting with practical applications for some common tasks. Surely I can't be the only one wanting to extract audio from a BD disc in that manner?

Anyway, you guys truly rock! I feel blessed to have this community available to thoughtfully provide these kinds of focused and precise answers.

Music Fan
8th May 2016, 08:11
This got me thinking, unfortunately I am not so familiar with the byzantine structure of the way Blu-Ray files are organized, but I was wondering where the meta-data was kept. Besides the 'chapter.txt' file I can output from one of the streams, there has to be some other area where the tagging data for the chapters might be residing.
Why do you need anything else than the chapters file to use chapters timecodes ?

So far the thing that's frustrated me the most is that MS's command line window doesn't seem to allow me to copy text from its output.
You can : right click on the top border (where you see "command prompt" or something like that), go to modify, select (or select all), make your selection with the mouse (except if you chose select all), right click again on the top border, modify, copy. Then go in a text file and paste.

r0lZ
8th May 2016, 09:24
So far the thing that's frustrated me the most is that MS's command line window doesn't seem to allow me to copy text from its output. Whereas with bash I can definitely do that, select a bit of the output and do whatever I want with it.
You can : right click on the top border (where you see "command prompt" or something like that), go to modify, select (or select all), make your selection with the mouse (except if you chose select all), right click again on the top border, modify, copy. Then go in a text file and paste.
I prefer this:
Click on the icon in the top left corner of the command prompt window to open the menu. Select properties. In the first tab "Options", tick QuickEdit Mode and Insert Mode. OK the dialog.
Now, you can simply select what you want to copy with the mouse. Press Enter to copy the selected text to the clipboard. (Control-C doesn't work.)
You can also paste the content of the clipboard at the cursor location with a right-click. (Again, Control-V doesn't work.)
The good thing is that the properties are saved and reused each time you will open the Command Prompt, so you don't have to go in the menu any more.
Take care however. When some text is selected in the command prompt window, no more text can be printed by the running program. Therefore, it is blocked until you press Return. (BTW, it's an handy trick to pause a program doing frequent outputs on the command prompt window, like an encoder.)

tebasuna51
8th May 2016, 11:27
One thing, I am pretty sure the stuff Boulder posted could really be useful for many other users besides myself, it could be good to expand the wiki to include a small section on scripting examples from the command line.

Of course, but use CLI (Command Line Interface (https://en.wikipedia.org/wiki/Command-line_interface)) need a big section to explain how work to new users than use only GUI's (Graphical User Interface (https://en.wikipedia.org/wiki/Graphical_user_interface)).

For old users, like me, than begin using CP/M (https://en.wikipedia.org/wiki/CP/M), after MS-DOS (https://en.wikipedia.org/wiki/MS-DOS) and finally Windows (all versions) is easy to do and know all the problems than a new user can have with CLI.

A brief list than can be developed:

- Open CLI or run batch files like Administrator
- MS-DOS commands (at least FOR, SET, CALL, DEL, ECHO, GOTO, HELP, IF, PAUSE, REM, ...)
- Filenames: short/full paths, quoted or not, warning with foreing Charsets, warning with long names.
- Explorer.exe. File explorer in mode Details, disable hide extensions.
- Batch files (.bat or .cmd)
- Notepad.exe (or other text editor). Recommended write in code ANSI.
- Pipe commands. Redirect output to other program or file.
- Capture text from Command window.
...

A generic usage of a CLI program is:

Program Input_file Output_file Parameters

But each CLI Program need a specific order and a specific sintax than, most the times, is showed executing Program without parameters. Or with: /?, /h, -help, ...

tebasuna51
8th May 2016, 12:40
I prefer this:
Click on the icon in the top left corner of the command prompt window to open the menu. Select properties. In the first tab "Options", tick QuickEdit Mode and Insert Mode. OK the dialog.
Now, you can simply select what you want to copy with the mouse.

Well maybe the procedure can change between OS version.

I'm using W 7 and change the Insert Mode to ON/OFF only modify how edit a command line (like others editors) but don't allow me select directly text with the mouse.

Also don't need, like Music Fan, go to "right click on the top border, go to Modify -> Select (or select all)"

I need (Insert Mode ON or OFF) right click inside the command window and Select (or select all, without the Modify pass).

After select the desired text press Enter is enough for me to copy text to clipboard, like you say, don't need go to top border for a new right click.

r0lZ
8th May 2016, 16:01
I'm on Win7 too. It's the QuickEdit option that allows you to select text with the mouse.
The Insert mode changes the default overwrite mode to insert (and shift subsequent characters), much more useful IMO. In both cases, you can use the right mouse button to insert the text from the clipboard.

tebasuna51
8th May 2016, 20:15
@r0lZ
Ok, I don't check QuickEdit.

staygroovy
8th May 2016, 20:56
Of course, but use CLI (Command Line Interface (https://en.wikipedia.org/wiki/Command-line_interface)) need a big section to explain how work to new users than use only GUI's (Graphical User Interface (https://en.wikipedia.org/wiki/Graphical_user_interface)).


Hello Tebasuna,

Thank you for considering what I posted.

I personally feel that it shouldn't be the forum's responsibility or focus to get users up to speed on the basics of using CLI. Surely a couple of links to some known sites that have well-written tutorials would be enough.

But given how tricky some of these Blu-Ray situations are for example, it would seem quite positive for some experienced members of the community to share some examples of methods they use to accomplish some of these repetitive tasks with eac3to.exe and other tools like sox.

I also feel that given different styles and approaches to shell programming it could give an opportunity for the more advanced users out there to compare notes on which methods are time-savers, have a more elegant approach, guidelines for scripting and so on...

So yeah, if such an idea was to ever be considered, I'd be totally happy for it to only cover the practical side of it, and leave learning the basics to the readers on their own.

staygroovy
8th May 2016, 21:01
I prefer this:
Click on the icon in the top left corner of the command prompt window to open the menu. Select properties. In the first tab "Options", tick QuickEdit Mode and Insert Mode. OK the dialog.
Now, you can simply select what you want to copy with the mouse. Press Enter to copy the selected text to the clipboard. (Control-C doesn't work.)
You can also paste the content of the clipboard at the cursor location with a right-click. (Again, Control-V doesn't work.)
The good thing is that the properties are saved and reused each time you will open the Command Prompt, so you don't have to go in the menu any more.
Take care however. When some text is selected in the command prompt window, no more text can be printed by the running program. Therefore, it is blocked until you press Return. (BTW, it's an handy trick to pause a program doing frequent outputs on the command prompt window, like an encoder.)
World of possibilities right there... thanks indeed to both you and Music Fan. :thanks: