Synthesis of MP4 and MP3

Source: Internet
Author: User

Target to synthesize the sounds in the MP3 into the MP4.

Third-party libraries in use: Mp4parser,

Muxing Audio/video

The API and the process is Straight-forward:

  1. You wrap the raw format file into a appropriate track object. 

     h264trackimpl H 264Track = new h264trackimpl (new Span class= "Pl-smi" >filedatasourceimpl ( "Video.h264  aactrackimpl aactrack = new  Aactrackimpl (new filedatasourceimpl ( aac               
  2. These track object is then added to a Movie object

    Movie ();addtrack (H264track); movie. Addtrack (aactrack)  ;
  3. The Movie object is a fed into a mp4builder to create the container.

    Defaultmp4builder (). Build (movie);
  4. Write the container to an appropriate sink.

    FileOutputStream (File ("Output.mp4")). Getchannel (); Mp4file. Writecontainer (FC); FC. Close ();     

Requires. h264 files and AAC files as "input" and output to MP4 format.

Test: Use Mediarecorder to generate a file with a suffix of. H264. The test can be played on the phone side. Use the above method to synthesize with an AAC file. Error:

Java.lang.NullPointerException:Attempt to read from field ' int com.googlecode.mp4parser.h264.model.PictureParameterSet.seq_parameter_set_id ' on a null object reference

New H264trackimpl (new Filedatasourceimpl ("/storage/emulated/0/dcim/testcamera/vid_2016.h264")); // Error Line

Construction failed. Google has no effect on this issue.

View Mp4parser's Issues:

Combine a music.m4a on a video.mp4 overwrite my video audio

Mp4parser's author replies:

"Basically want to merge," audio tracks to one. Players won ' t play with audio tracks at the same time. This is a with case, which requires decoding, then merging and encoding to one audio track again. The Mp4parser cannot do. I guess you'll need to use ffmpeg or the Mediacodec API. "

In a word, mp4parser can't do it.

Synthesis of MP4 and MP3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.