IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
mp4 album song extraction, extract individual songs without re-encoding from mp4 albums
GwaiTsi
post Apr 16 2014, 14:09
Post #1





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



some years ago i encoded all my albums into single m4a files with cover art and chapter info.
Works really great on foobar2000 but unfortunately, after some 7 years they still haven't added chapter support into linux and none of the commercial media products support it either.

Best i guest is to re-split the albums into individual songs and directories, but i would like to duplicate the album art into each song and retain the chapter / album info.

Does anyone know of a component or a way to achieve this? preferably in batch form

thanks to all in advance

Go to the top of the page
+Quote Post
romor
post Apr 16 2014, 16:29
Post #2





Group: Members
Posts: 668
Joined: 16-January 09
Member No.: 65630



Had same problem...

Unfortunately only program that I thought is capable of doing such thing - mp4box, while having so many flags and options, none available to split mp4 by chapters automatically

I solved it with a little Python script: https://gist.github.com/2879fb5b95ded50a9e09
It splits the file by chapters, and names the files according chapter name.

It's a Python script, and was easiest way to me at the moment.
I know not every Windows user got it, but maybe you have it.

You'll have to point the variable on line 1 to mp4box path, and It won't run on Linux, unless you remove Message box thing on lines 51-52

This post has been edited by romor: Apr 16 2014, 16:31


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
GwaiTsi
post Apr 30 2014, 16:17
Post #3





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



hi romor,

tried your script, but i am afraid nothing happens.

I have MP4Box installed and is accessible from /usr/bin/
i have python 2.7 and have change mp4box path in script and removed 51 and 52.

unfortunately nothing happens and i don't have any skills to debug.

using ubuntu 14.04

cheers
Go to the top of the page
+Quote Post
romor
post Apr 30 2014, 19:33
Post #4





Group: Members
Posts: 668
Joined: 16-January 09
Member No.: 65630



Can you check if:

CODE
mp4box --info <some-m4a-file>


outputs to stdout or strerr?

I tried the script on latest 64bit nightly build and it seems like there is a bug and they output info to stderr instead stdout.
If that's the case, try this version: https://gist.github.com/0ecf83eda9b713048827


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
GwaiTsi
post May 1 2014, 22:57
Post #5





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



hi romor,

Thanks, that helped get it working sort of. I had one successful album so far, but for most i get the following errors are the first track

Warning: track ID 1 has references to a track not imported
Setting up iTunes/iPod file...
Saving 01 - xxxxxx.m4a: 0.500 secs Interleaving
Error cloning track 2 sample 2
Unknown input file type
Unknown input file type
Error importing 02 - xxxxx.m4a#1: Requested URL is not valid or cannot be found
Command '['MP4Box', '-add', '02 - xxxx.m4a#1', '-new', '02 - xxxx.m4a']' returned non-zero exit status 1

any ideas?
thanks again
Go to the top of the page
+Quote Post
romor
post May 2 2014, 02:54
Post #6





Group: Members
Posts: 668
Joined: 16-January 09
Member No.: 65630



I didn't have any problems while splitting my albums, so I don't have idea what's wrong there

You can perhaps run `mp4box --info <problematic-m4a-file>` and paste the result here


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
GwaiTsi
post May 4 2014, 01:00
Post #7





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



Hi, here is the MP4Box Info

* Movie Info *
Timescale 1000 - Duration 00:43:40.909
2 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand mp42 - version 0
Created: GMT Sat Jan 23 21:55:51 2010

File has no MPEG4 IOD/OD

Chapters:
Chapter #1 - 00:00:00.059 - "X"
Chapter #2 - 00:04:05.781 - "X"
Chapter #3 - 00:07:47.601 - "X"
Chapter #4 - 00:12:02.100 - "X"
Chapter #5 - 00:16:26.133 - "X"
Chapter #6 - 00:20:54.974 - "X"
Chapter #7 - 00:24:40.425 - "X"
Chapter #8 - 00:28:03.358 - "X"
Chapter #9 - 00:32:45.181 - "X"
Chapter #10 - 00:38:51.824 - "X"

iTunes Info:
Artist: X
Album: Talkie X
Comment: France
Writer: X
Album Artist: X
Genre: Electronic
Created: 2004
Encoder Software: Nero AAC codec / 1.3.3.0
Cover Art: JPEG File

Track # 1 Info - TrackID 1 - TimeScale 44100 - Media Duration 00:43:40.909
Media Info: Language "Undetermined" - Type "soun:mp4a" - 112874 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Self-synchronized

Track # 2 Info - TrackID 2 - TimeScale 1000 - Media Duration 00:43:40.909
Track is disabled
Media Info: Language "Undetermined" - Type "text:text" - 10 samples
3GPP/MPEG-4 Timed Text - Size 0 x 0 - Translation X=0 Y=0 - Layer 0

here is the script output for the same file

Extracting chunk 01 - X.m4a - duration 245.72s (0.06s->245.78s)
[3GPP convert] Setting major brand to 3GPP V5 file
IsoMedia import 01 - X.m4a - track ID 1 - Audio (SR 44100 - 2 channels)
Warning: track ID 1 has references to a track not imported
Setting up iTunes/iPod file...
Saving 01 - X.m4a: 0.500 secs Interleaving
Error cloning track 2 sample 2
Unknown input file type
Unknown input file type
Error importing 02 - X.m4a#1: Requested URL is not valid or cannot be found
Command '['MP4Box', '-add', '02 - X.m4a#1', '-new', '02 - X']' returned non-zero exit status 1

Go to the top of the page
+Quote Post
GwaiTsi
post May 4 2014, 01:06
Post #8





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



Hi again, this is the info for a file that actually worked and i can see the difference.
All the ones that fail, seem to have a second track. Probably related to a failed attempt to get my Nero files recognised as an apple m4a a long time ago.

* Movie Info *
Timescale 90000 - Duration 00:56:03.178
1 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand mp42 - version 0
Created: GMT Wed Oct 9 11:11:21 2013

File has no MPEG4 IOD/OD

Chapters:
Chapter #1 - 00:00:00.059 - "X"
Chapter #2 - 00:04:28.512 - "X"
Chapter #3 - 00:07:07.539 - "X"
Chapter #4 - 00:10:51.139 - "X"
Chapter #5 - 00:13:30.112 - "X"
Chapter #6 - 00:17:19.752 - "X"
Chapter #7 - 00:19:23.326 - "X"
Chapter #8 - 00:22:46.459 - "X"
Chapter #9 - 00:25:49.899 - "X"
Chapter #10 - 00:28:37.912 - "X"
Chapter #11 - 00:32:02.859 - "X"
Chapter #12 - 00:35:02.859 - "X"
Chapter #13 - 00:38:31.459 - "X"
Chapter #14 - 00:41:49.672 - "X"
Chapter #15 - 00:45:31.192 - "X"
Chapter #16 - 00:49:22.552 - "X"
Chapter #17 - 00:53:57.659 - "X"

iTunes Info:
Artist: X
Album: X
Comment: Portugal
Album Artist: X
Genre: Fado
Created: 2000
Encoder Software: Nero AAC codec / 1.5.4.0
Cover Art: JPEG File

Track # 1 Info - TrackID 1 - TimeScale 44100 - Media Duration 00:56:03.178
Media Info: Language "Undetermined" - Type "soun:mp4a" - 144840 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Self-synchronized
Go to the top of the page
+Quote Post
GwaiTsi
post May 4 2014, 01:17
Post #9





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



p.s. another thing i noticed on the files that do work, the script doesn't copy the meta data back to the file i.e. album, artist, etc
Go to the top of the page
+Quote Post
GwaiTsi
post May 4 2014, 02:25
Post #10





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



Hi Romor, to fix/clean the files i have to do this:

mp4chaps -x -N file.m4a
mp4chaps -r file.m4a
mp4chaps -i -N file.m4a

The convert function doesn't work.
Go to the top of the page
+Quote Post
romor
post May 4 2014, 08:53
Post #11





Group: Members
Posts: 668
Joined: 16-January 09
Member No.: 65630



GwaiTsi, I can't read your last comment but let me say that I make various automation scripts for myself, and if I decide that script is generally usable I share it, but I don't offer support service, although I'm willing to help any honest complain I can solve in my spare time.
I didn't ever mention that 50 line script is capable or transferring metadata, but just that it splits m4a file and then names the files according chapter names.
That was my quest back in time, and at that time mp4box outputted info to stdout as expected, instead stderr as it currently does, which is a bug and they'll hopefully solve it in another release.

Then, you ask this question in foobar2000 forum that's native Windows application and you seem to want Linux solution while you have no basic Python knowledge - that's beyond me.
Meta-imagining, I'll offer your new script on same link: https://gist.github.com/0ecf83eda9b713048827

But if that also doesn't work for you, I'd suggest you do it manually or pay some nice guy a beer or two, to do it for you.


Cheers

This post has been edited by romor: May 4 2014, 08:54


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
GwaiTsi
post May 4 2014, 16:49
Post #12





Group: Members
Posts: 33
Joined: 29-October 06
Member No.: 36908



QUOTE (romor @ May 4 2014, 02:53) *
GwaiTsi, I can't read your last comment but let me say that I make various automation scripts for myself, and if I decide that script is generally usable I share it, but I don't offer support service, although I'm willing to help any honest complain I can solve in my spare time.
I didn't ever mention that 50 line script is capable or transferring metadata, but just that it splits m4a file and then names the files according chapter names.
That was my quest back in time, and at that time mp4box outputted info to stdout as expected, instead stderr as it currently does, which is a bug and they'll hopefully solve it in another release.

Then, you ask this question in foobar2000 forum that's native Windows application and you seem to want Linux solution while you have no basic Python knowledge - that's beyond me.
Meta-imagining, I'll offer your new script on same link: https://gist.github.com/0ecf83eda9b713048827

But if that also doesn't work for you, I'd suggest you do it manually or pay some nice guy a beer or two, to do it for you.


Cheers


Hi romor,
i really appreciate what you have done. I can live without the meta data as i can put that back via foobar2000 based on the original one.
originally i started with foobar2000 on windows, but a few years ago i moved my machines to ubuntu cause i was sick of the long startup and slow operation of windows. your script works super with the correction to it.

The issue i have is not from your script, but some years ago i tried using mp4chaps to convert from nero chapters to quicktime chapters. This is what is causing the conversions to fail with your script. the chapters have to be re-converted back to nero format and then your script works.

i tried to modify your script add the cleanup tasks, but it didn't work, so i just made a separate shell script to do the cleanup stuff first.

Thanks again for this great script as it really saves me heaps.

cheers



Go to the top of the page
+Quote Post
nu774
post May 5 2014, 10:01
Post #13





Group: Developer
Posts: 514
Joined: 22-November 10
From: Japan
Member No.: 85902



I have wrote a tiny CLI tool named m4acut that supports chapter splitting mode:
https://github.com/nu774/m4acut
https://sites.google.com/site/qaacpage/cabinet

Point of this tool:
- Portable (Pre-compiled win32 binary is on the qaac cabinet page).
- Perfectly gapless (at least for AAC LC, and when player supports gapless playback using iTunSMPB tag).
- Allows arbitrary cut points (not restricted to AAC frame boundary).
- Copies all tag from input. On chapter mode, it automatically generates output file name, title, track number/total tag from chapters.
- Chapter mode supports both of QuickTime and Nero style chapters.

For splitting by chapters, the following should work:
CODE
m4acut -c foo.m4a

Go to the top of the page
+Quote Post
romor
post May 8 2014, 10:05
Post #14





Group: Members
Posts: 668
Joined: 16-January 09
Member No.: 65630



Good job @nu774, thanks for making it.

CODE
cmd /c "\path-to\m4acut.exe -c "%path%" && del "%path%""

This foo_run action takes care of everything if your program is to be used from foobar.

I wasn't that lucky, to have the program while I did chapter splitting, and perhaps it should have it's dedicated thread?

IIRC, I created playlist will all M4A files with chapters, then after processing another playlist to copy the tags and recalculate ReplayGain. Creating and matching both playlists wasn't trivial as it may seem. But with your program even ReplayGain is transferred.


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 2nd August 2014 - 06:43