Create mp4 with h264 video and mp3 audio

755 views
Skip to first unread message

Roman Elizarov

unread,
Oct 16, 2013, 5:11:14 PM10/16/13
to mp4parser-...@googlegroups.com
Hello. I have raw h264 and mp3 samples. ffmpeg combines them into a playable mp4 container. I'd like to be able to do the same via mp4parser, so that I can do it on the fly in my java code. There is a "H264Example" that works just fine to mux my particular h264 file (after I've converted it to Annex B format). However, I see only AC3 and AAC track implementations for audio. Any chance to get MP3 tracks supported, too? 

Sebastian Annies

unread,
Oct 16, 2013, 5:19:48 PM10/16/13
to mp4parser-...@googlegroups.com

Hi,

AFAIK there is no specification for MP3 in MP4 containers. Do you know where it is specified? If it is specified I might be able to implement it.

Regards,

Sebastian

--
You received this message because you are subscribed to the Google Groups "mp4parser-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Roman Elizarov

unread,
Oct 16, 2013, 5:33:35 PM10/16/13
to mp4parser-...@googlegroups.com
I have not seen it. ffmpeg produces it just fine (ffmpeg -i data.h264 -i data.mp3 -vcodec copy -acodec copy data.mp4) where .h264 is Annex B h264 and .mp3 is a raw sequence of 209 byte mp3 frames (no tags, no header, no IDv3). The resulting file plays normally in Windows Media Player, in VLC player, and in JavaFX media. I can inspect it with mp4 inspector -- it works just fine. I can drop source .h264/.mp3 and/or resulting .mp4 files for you.


--
You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mp4parser-discussion/Sp-AJxaJyRo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.

Sebastian Annies

unread,
Oct 16, 2013, 5:39:47 PM10/16/13
to mp4parser-...@googlegroups.com

Yes, please send me input and output. Perhaps I can create an Mp3TrackImpl easily.

Roman Elizarov

unread,
Oct 17, 2013, 3:43:04 AM10/17/13
to mp4parser-...@googlegroups.com
I've did some extra works and created a sample from the creative commons content, so that you can freely use/distribute it if you want to. It is based on http://www.bigbuckbunny.org/

I'm basically interested in converting h264+MP3 FLV container to mpeg4 in Java, so I've created a BigBuckBunny_320x180_44100.flv with h264 and mp3 of exactly the kind I'm interested in. I have my own FLV demuxer in Java (that's simple) that extracts from it Annex B h264 stream (BigBuckBunny_320x180_44100.flv.h264) and raw mp3 samples stream (BigBuckBunny_320x180_44100.flv.mp3). Then I'm using ffmpeg to mux them into mp4 ("ffmpeg -i BigBuckBunny_320x180_44100.flv.h264 -i BigBuckBunny_320x180_44100.flv.mp3 -acodec copy -vcodec copy BigBuckBunny_320x180_44100.mp4") and the result is "BigBuckBunny_320x180_44100.mp4". mp4inspector happily sees it contents and this .mp4 file plays to my pleause in Windows Media Player, in VLC Player, and in JavaFX Media. Now, the trick is to be able to do the same muxing via mp4parser. I can contribute my simple FLV demuxer code to you codebase, so that you can have FLV to MP4 converter as one of examples in mp4parser library.


Sincerely,
Roman Elizarov


Roman Elizarov

unread,
Oct 18, 2013, 4:39:13 AM10/18/13
to mp4parser-...@googlegroups.com
Sebastian, 

I've already implemented MP3TrackImpl. It works like a charm. There's a small small patch to DecoderConfigDescriptor so that it can serialize itself properly when audioSpecificInfo is null. How can I contribute my code to your library? 

So now I can convert H264+MP3 FLV to fragmented MP4. My next stemp is to be able to do the same trick on-the-fly while receiving live FLV stream and writing live fragmented MP4. This will likely require much more improvements to mp4parser code. It will require some architectural changes in mp4parser code, though. I'll carry them in my local local and see if they can be merged with mp4parser code.

Sincerely,
Roman Elizarov

Roman Elizarov

unread,
Oct 18, 2013, 11:53:38 AM10/18/13
to mp4parser-...@googlegroups.com
Here is my patch (attached). 
MP3TrackImpl.patch

Sebastian Annies

unread,
Oct 26, 2013, 4:32:56 PM10/26/13
to mp4parser-...@googlegroups.com

Hi Roman,

 

Thank you so much for your code. The code is now in trunk. I assume you are ok with publishing it under Apache License v2?

 

Best Regards,

Roman Elizarov

unread,
Oct 27, 2013, 1:30:52 AM10/27/13
to mp4parser-...@googlegroups.com, <mp4parser-discussion@googlegroups.com>
Of course. 
Reply all
Reply to author
Forward
0 new messages