Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th December 2013, 15:11   #1  |  Link
malikcis
Registered User
 
Join Date: Sep 2007
Posts: 50
muxing h.264 and aac in MP4

Hi,

Is there a way (library, framework, source code etc...) to multiplex H.264 and AAC in a MP4 file format on a frame by frame and audio chunk by audio chunk basis?
There are tons of libraries but they are all file based.
Thanks,

malikcis
malikcis is offline   Reply With Quote
Old 6th December 2013, 15:35   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Quote:
Originally Posted by malikcis View Post
on a frame by frame and audio chunk by audio chunk basis
Please explain what this means.
Guest is offline   Reply With Quote
Old 6th December 2013, 16:08   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
What about those?
* https://github.com/silverfilain/L-SMASH
* http://sourceforge.net/projects/gpac/

For usage example, see here:
http://git.videolan.org/?p=x264.git;...t/mp4_lsmash.c
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 6th December 2013 at 16:14.
LoRd_MuldeR is offline   Reply With Quote
Old 6th December 2013, 16:16   #4  |  Link
malikcis
Registered User
 
Join Date: Sep 2007
Posts: 50
Quote:
Originally Posted by neuron2 View Post
Please explain what this means.
The basic idea is to mux an audio/video stream as follows:

initialize_mp4_muxer("file.mp4");
initialize_hw_framegrabber();

while(1)
{
get_h264_frame(pVidBuffer);
get_aac_audio_chunk(pAudChunk);
mp4_mux(pVidBuffer, pAudChunk);
}
close_all_resources();
malikcis is offline   Reply With Quote
Old 6th December 2013, 16:33   #5  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Did you check out the above links?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 6th December 2013, 16:54   #6  |  Link
malikcis
Registered User
 
Join Date: Sep 2007
Posts: 50
Quote:
Originally Posted by LoRd_MuldeR View Post
Did you check out the above links?
LoRd_MuldeR,

Ok I see. however write_frame() from mp4_lsmash.c only shows how to mux h.264 frame but not AAC audio.


Malikcis

Last edited by malikcis; 6th December 2013 at 17:10.
malikcis is offline   Reply With Quote
Old 7th December 2013, 13:57   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by malikcis View Post
LoRd_MuldeR,

Ok I see. however write_frame() from mp4_lsmash.c only shows how to mux h.264 frame but not AAC audio.
Indeed, the write_frame() method in x264 does not write AAC audio, because x264 doesn't mess with audio. But the code should give you the idea how to do it

Obviously, you would need to setup two tracks rather than a single one (cf. set_param() method) and then append the audio and video samples to the audio and video track, respectively (cf. write_frame() method).
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 7th December 2013, 21:50   #8  |  Link
VFR maniac
Spinner of yarns
 
VFR maniac's Avatar
 
Join Date: May 2009
Posts: 164
Quote:
Originally Posted by malikcis View Post
LoRd_MuldeR,

Ok I see. however write_frame() from mp4_lsmash.c only shows how to mux h.264 frame but not AAC audio.


Malikcis
Official x264's repo omits some features for convenience.
About muxing both audio and video, x264_L-SMASH may be helpful, though it's somewhat old.
https://github.com/silverfilain/x264...h/output/mp4.c

x264_L-SMASH writes audio frames for each write_frame().
The code is asymmetry.
L-SMASH muxes chunk by chunk internally from input frames unless exceeding max_async_tolerance.
You can append video frames and audio frames in arbitrary timing as L-SMASH muxer app does.
http://repo.or.cz/w/L-SMASH.git/blob/HEAD:/muxer.c#l976

If you want to interleave each video frame and each audio chunk, set duration of video frame to max_chunk_duration.
__________________
僕と契約して、L-SMASH developerになってよ!
L-SMASH | L-SMASH Works | Opus-in-ISOBMFF specification and reference software

Last edited by VFR maniac; 7th December 2013 at 22:24. Reason: typo
VFR maniac is offline   Reply With Quote
Old 9th December 2013, 18:23   #9  |  Link
malikcis
Registered User
 
Join Date: Sep 2007
Posts: 50
Quote:
Originally Posted by VFR maniac View Post
Official x264's repo omits some features for convenience.
About muxing both audio and video, x264_L-SMASH may be helpful, though it's somewhat old.
https://github.com/silverfilain/x264...h/output/mp4.c

x264_L-SMASH writes audio frames for each write_frame().
The code is asymmetry.
L-SMASH muxes chunk by chunk internally from input frames unless exceeding max_async_tolerance.
You can append video frames and audio frames in arbitrary timing as L-SMASH muxer app does.
http://repo.or.cz/w/L-SMASH.git/blob/HEAD:/muxer.c#l976

If you want to interleave each video frame and each audio chunk, set duration of video frame to max_chunk_duration.

Thank you,
This indeed seems to be a possible way.
The hard part (implementation) remains though...
malikcis is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.