question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Merge two audio mp4 file ?

See original GitHub issue

I try to merge one audio mp4 file to another audio mp4 file.

Code:

String audio1 = path + “audio1.mp4”; String audio2 = path + “audio2.mp4”; String outputVideo = path + “audio_output.mp4”;

    Movie[] inMovies = new Movie[]{
            MovieCreator.build(audio1),
            MovieCreator.build(audio2),
    };

    List<Track> audioTracks = new LinkedList<Track>();

    for (Movie m : inMovies) {
        for (Track t : m.getTracks()) {
            if (t.getHandler().equals("soun")) {
                audioTracks.add(t);
            }
        }
    }

    Movie result = new Movie();

    if (audioTracks.size() > 0) {
        result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
    }

    Container out = new DefaultMp4Builder().build(result);
    out.writeContainer(new FileOutputStream(outputVideo).getChannel());

Exception:

java.io.IOException: Cannot merge AudioSampleEntry{bytesPerSample=0, bytesPerFrame=0, bytesPerPacket=0, samplesPerPacket=0, packetSize=0, compressionId=0, soundVersion=0, sampleRate=44100, sampleSize=16, channelCount=2, boxes=[com.googlecode.mp4parser.boxes.mp4.ESDescriptorBox@0]} and AudioSampleEntry{bytesPerSample=0, bytesPerFrame=0, bytesPerPacket=0, samplesPerPacket=0, packetSize=0, compressionId=0, soundVersion=0, sampleRate=8000, sampleSize=16, channelCount=1, boxes=[com.googlecode.mp4parser.boxes.mp4.ESDescriptorBox@0]}

Is there any solution ?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sanniescommented, Jan 29, 2016

So codec settings need to be the same: Same sample rate, same number of channels and so on. In the first mail I can see that Durim is trying to append 44.1KHz Stereo with 8KHz Mono. That cannot work. The basic properties

2016-01-28 8:54 GMT+02:00 yanchengdeng notifications@github.com:

I have this problem too,please help me!

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/155#issuecomment-176019851.

0reactions
rohit101211993commented, Jan 1, 2019

Can you suggest i want to merge audio at middle of first file (for example after 5 second of first audio) Audio 1 = 1111111111 Audio 2 = 0000000000 Output= 11111 000000000011111

Read more comments on GitHub >

github_iconTop Results From Across the Web

Online Audio Joiner — Merge Audio Files for Free - Clideo
The Online Audio Merger allows you to combine MP3, WAV, OGG and other files into one soundtrack. It works on any device: Mac,...
Read more >
How to Merge Video and Audio Online Free
Steps on how to merge audio and video using VLC ... Step 1: Launch the VLC Media Player app on your system and...
Read more >
How to merge songs (mp3, m4a, wav)? - Audio Joiner
Open Online Audio Joiner website. · Add audio tracks · Set the order of playback · Adjust the intervals · Select the mode...
Read more >
How to merge the audio and video of separate files into one ...
Yes, you can combine separate audio and video files into a single mp4. You do that by importing each file into a video...
Read more >
Merge Audio, join and combine multiple audio files
Select two or more audio files (such as *.mp3, *.ogg, *.midi, *.mid, *.m4a, *.wma, *.amr, *.flac, *.aiff, *.wav and more). · Click button...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found