{"action":"created","issue":{"url":"https://api.github.com/repos/gpac/gpac/issues/358","labels_url":"https://api.github.com/repos/gpac/gpac/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/gpac/gpac/issues/358/comments","events_url":"https://api.github.com/repos/gpac/gpac/issues/358/events","html_url":"https://github.com/gpac/gpac/issues/358","id":123273028,"number":358,"title":"Demuxing ALAC audio tracks from .mp4 using mp4box","user":{"login":"Foaly","id":1014762,"avatar_url":"https://avatars.githubusercontent.com/u/1014762?v=3","gravatar_id":"","url":"https://api.github.com/users/Foaly","html_url":"https://github.com/Foaly","followers_url":"https://api.github.com/users/Foaly/followers","following_url":"https://api.github.com/users/Foaly/following{/other_user}","gists_url":"https://api.github.com/users/Foaly/gists{/gist_id}","starred_url":"https://api.github.com/users/Foaly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foaly/subscriptions","organizations_url":"https://api.github.com/users/Foaly/orgs","repos_url":"https://api.github.com/users/Foaly/repos","events_url":"https://api.github.com/users/Foaly/events{/privacy}","received_events_url":"https://api.github.com/users/Foaly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-21T12:44:30Z","updated_at":"2015-12-22T15:47:19Z","closed_at":null,"body":"Hello! I encountered a problem, when extracting audio tracks from a *.mp4 container, that looks like a bug. I have an *.mp4 file that contains multiple audio tracks. The audio tracks are encoded using the ALAC codec. I want to extract those into seperate audio files using mp4box.\r\n\r\nWhat I've tryed so far for extracting a track is this:\r\n\r\n    mp4box -single 1 \"inputfile.mp4\" -out \"outputfile.m4a\"\r\n\r\nWhat happens is, it works as that a `outputfile.m4a` is created, but something with the header/codec/file info seems to be malformated. I can open and play the file in VLC, but it fails to open with Windows Media Player/Windows Media Foundation (which I need). So either I am doing something wrong during the extraction or mp4box puts the file in a weird format.\r\n\r\nThe output of `mp4box -info -v \"outputfile.mp4\"` looks like this:\r\n\r\n    [iso file] Current top box start before parsing 0\r\n    [iso file] Read Box type ftyp size 20 start 0\r\n    [iso file] Current top box start before parsing 20\r\n    [iso file] Read Box type mdat size 8555577 start 20\r\n    [iso file] Current top box start before parsing 8555597\r\n    [iso file] Read Box type free size 75 start 8555597\r\n    [iso file] Current top box start before parsing 8555672\r\n    [iso file] Read Box type moov size 4895 start 8555672\r\n    [iso file] Read Box type mvhd size 108 start 8555680\r\n    [iso file] Read Box type trak size 4779 start 8555788\r\n    [iso file] Read Box type tkhd size 92 start 8555796\r\n    [iso file] Read Box type mdia size 4679 start 8555888\r\n    [iso file] Read Box type mdhd size 32 start 8555896\r\n    [iso file] Read Box type hdlr size 55 start 8555928\r\n    [iso file] Read Box type minf size 4584 start 8555983\r\n    [iso file] Read Box type smhd size 16 start 8555991\r\n    [iso file] Read Box type dinf size 36 start 8556007\r\n    [iso file] Read Box type dref size 28 start 8556015\r\n    [iso file] Read Box type url  size 12 start 8556031\r\n    [iso file] Read Box type stbl size 4524 start 8556043\r\n    [iso file] Read Box type stsd size 108 start 8556051\r\n    [iso file] Read Box type alac size 92 start 8556067\r\n    [iso file] Read Box type stts size 24 start 8556159\r\n    [iso file] Read Box type stsc size 40 start 8556183\r\n    [iso file] Read Box type stsz size 3936 start 8556223\r\n    [iso file] Read Box type stco size 408 start 8560159\r\n    [iso file] Read Box type alac size 36 start 28\r\n    [iso file] Read Box type btrt size 20 start 64\r\n    * Movie Info *\r\n            Timescale 600 - 1 track\r\n            Computed Duration 00:01:30.928 - Indicated Duration 00:01:30.928\r\n            Fragmented File: no\r\n            File Brand isom - version 1\r\n            Created: GMT Thu Dec 17 14:35:48 2015\r\n            Modified: GMT Thu Dec 17 14:35:48 2015\r\n\r\n    File has no MPEG4 IOD/OD\r\n\r\n    Track # 1 Info - TrackID 1 - TimeScale 44100\r\n    Media Duration 00:01:30.929 - Indicated Duration 00:01:30.929\r\n    Media Info: Language \"und (und)\" - Type \"soun:alac\" - 979 samples\r\n    Audio Track - Sample Rate 44100 - 2 channel(s)\r\n    [ISOM Tools] codec parameters not known - setting codecs string to default value \"alac\"\r\n            RFC6381 Codec Parameters: alac\r\n            All samples are sync\r\n\r\nI also tryed extracting the audio tracks using the `-raw` flag like this:\r\n\r\n    mp4box -raw 1 \"inputfile.mp4\"\r\n\r\nIt creates a `inputfile.mp4_track1.alac` file, which I can't open in any player (not even VLC). Looking at it in a HEX editor it looks like the raw data segment (which makes sense I guess), but I can't get mp4box to put it back into a .m4a which I can play.\r\n\r\nHere is a small python script to reproduce the above error:\r\n```python\r\nimport os\r\nimport subprocess\r\n\r\ndef combineIntoOneMP4():\r\n    executionDir = os.path.dirname(os.path.realpath(__file__))\r\n    inputFile = os.path.join(executionDir, \"TechTalk_CC_music.m4a\")\r\n    outputFile = os.path.join(executionDir, \"testout.mp4\")\r\n\r\n    # main track not disabled\r\n    callArgs = [\"mp4box\", \"-add\", inputFile + \"#ID=Z\", outputFile]\r\n\r\n    for i in range(0, 4):\r\n        # other tracks disabled\r\n        callArgs.extend([\"-add\", inputFile + \"#ID=Z:disable\"])\r\n\r\n    #print(callArgs)\r\n    subprocess.check_call(callArgs)\r\n    print(\"Combined 5 tracks into one MP4 file: \" + os.path.basename(outputFile))\r\n\r\ndef extractAudioTracks():\r\n    executionDir = os.path.dirname(os.path.realpath(__file__))\r\n    inputFile = os.path.join(executionDir, \"testout.mp4\")\r\n\r\n    for i in range(0, 5):\r\n        outputFile = os.path.join(executionDir, \"extractedTrack_\" + str(i + 1) + \".m4a\")\r\n        callArgs = [\"mp4box\", \"-single\", str(i + 1), inputFile, \"-out\", outputFile]\r\n        #print(callArgs)\r\n        subprocess.check_call(callArgs)\r\n\r\n    print(\"Extracted tracks into seperate files.\")\r\n\r\n# call functions\r\ncombineIntoOneMP4()\r\nextractAudioTracks()\r\n```\r\n\r\nHere is a zip file containing the `TechTalk_CC_music.m4a` track that I used for testing and in the example: [Mp4Box Test.zip](https://github.com/gpac/gpac/files/68442/Mp4Box.Test.zip)\r\n\r\nSo I guess the question is am I doing anything wrong? Am I maybe missing some flag while extracting? Or is mp4box simply producing wrong results? I hope somebody can point me in the right direction. Thanks in advance!"},"comment":{"url":"https://api.github.com/repos/gpac/gpac/issues/comments/166652224","html_url":"https://github.com/gpac/gpac/issues/358#issuecomment-166652224","issue_url":"https://api.github.com/repos/gpac/gpac/issues/358","id":166652224,"user":{"login":"Foaly","id":1014762,"avatar_url":"https://avatars.githubusercontent.com/u/1014762?v=3","gravatar_id":"","url":"https://api.github.com/users/Foaly","html_url":"https://github.com/Foaly","followers_url":"https://api.github.com/users/Foaly/followers","following_url":"https://api.github.com/users/Foaly/following{/other_user}","gists_url":"https://api.github.com/users/Foaly/gists{/gist_id}","starred_url":"https://api.github.com/users/Foaly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foaly/subscriptions","organizations_url":"https://api.github.com/users/Foaly/orgs","repos_url":"https://api.github.com/users/Foaly/repos","events_url":"https://api.github.com/users/Foaly/events{/privacy}","received_events_url":"https://api.github.com/users/Foaly/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T15:47:19Z","updated_at":"2015-12-22T15:47:19Z","body":"yep that one is playing without problems."}}