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.

Replace Audio of a Video with diff AAC audio

See original GitHub issue

Hey nice lib, I want to replace the audio of a mp4 video with other aac audio(which i have recorded using phones mic) in Android.

                    String accFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recording.acc";
                    String videoFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myvid.mp4";

                    Movie m = MovieCreator.build( new FileDataSourceImpl(videoFileName));
                    List<Track> nuTracks = new ArrayList<>();
                    for (Track t : m.getTracks()) {
                        // Re-use all tracks besides the audio track
                        if (!"soun".equals(t.getHandler())) {
                            nuTracks.add(t);
                        }
                    }
                    Track nuAudio = new AACTrackImpl(new FileDataSourceImpl(accFileName));
                      //giving error on the above line "Expected Start Word 0xfff"
                    nuTracks.add(nuAudio); // add the new audio track
                    m.setTracks(nuTracks);
                    String outputFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/output.mp4";
                    Container c = new DefaultMp4Builder().build(m);
                    c.writeContainer(new FileOutputStream(outputFileName).getChannel());

And what is diffrence btwn raw aac and normal aac ? @sannies

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sanniescommented, Jan 10, 2016

It’s as expected. It’s an MPEG4 container and no raw file. Use the MovieCreator.build() and simply use the first track. That should do the trick.

2016-01-09 21:07 GMT+01:00 Priyank Agrawal notifications@github.com:

General Complete name : C:\Users\Priyank\Desktop\recording.acc Format : MPEG-4 Format profile : 3GPP Media Release 4 Codec ID : 3gp4 (isom/3gp4) File size : 11.9 KiB Duration : 5s 888ms Overall bit rate mode : Constant Overall bit rate : 16.5 Kbps Encoded date : UTC 2016-01-09 09:59:19 Tagged date : UTC 2016-01-09 09:59:19

Audio ID : 1 Format : AAC Format/Info : Advanced Audio Codec Format profile : LC Codec ID : 40 Duration : 5s 888ms Bit rate mode : Constant Bit rate : 12.3 Kbps Nominal bit rate : 96.0 Kbps Channel(s) : 1 channel Channel positions : Front: C Sampling rate : 8 000 Hz Frame rate : 7.813 fps (1024 spf) Compression mode : Lossy Stream size : 8.83 KiB (74%) Title : SoundHandle Language : English Encoded date : UTC 2016-01-09 09:59:19 Tagged date : UTC 2016-01-09 09:59:19

On Sun, Jan 10, 2016 at 1:24 AM, Sebastian Annies < notifications@github.com>

wrote:

http://lmgtfy.com/?q=mediainfo

2016-01-09 20:50 GMT+01:00 Priyank Agrawal notifications@github.com:

hey how do i get that ? is that some class or wat ?

On Sun, Jan 10, 2016 at 1:01 AM, Sebastian Annies < notifications@github.com>

wrote:

3gp is most likely not raw aac, but an MP4 container. Please paste the mediainfo output.

2016-01-09 20:29 GMT+01:00 Priyank Agrawal <notifications@github.com :

I am using android device to capture this audio. Using output format as 3gp and audio encoder as aac. On Jan 10, 2016 12:51 AM, “priyank agrawal” < mr.priyankagrawal@gmail.com

wrote:

There you On Jan 10, 2016 12:44 AM, “Sebastian Annies” < notifications@github.com

wrote:

Could you make an example file available? (Very short please as I only got mobile internet at the moment)

2016-01-09 20:12 GMT+01:00 Priyank Agrawal < notifications@github.com :

Hi it is adts On Jan 10, 2016 12:34 AM, “Sebastian Annies” < notifications@github.com> wrote:

Hi, could you check what kind of AAC you recorded. There are two variant of ‘raw’ AAC:

  • fltp or (aac version 4) which is very uncommon in my eyes (not supported!)
  • and ADTS Could you use mediainfo on your file to see what it is?

— Reply to this email directly or view it on GitHub <

https://github.com/sannies/mp4parser/issues/149#issuecomment-170270052

.

— Reply to this email directly or view it on GitHub <

https://github.com/sannies/mp4parser/issues/149#issuecomment-170271172

.

— Reply to this email directly or view it on GitHub <

https://github.com/sannies/mp4parser/issues/149#issuecomment-170271284

.

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

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

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

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

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

1reaction
sanniescommented, Jan 9, 2016

http://lmgtfy.com/?q=mediainfo

2016-01-09 20:50 GMT+01:00 Priyank Agrawal notifications@github.com:

hey how do i get that ? is that some class or wat ?

On Sun, Jan 10, 2016 at 1:01 AM, Sebastian Annies < notifications@github.com>

wrote:

3gp is most likely not raw aac, but an MP4 container. Please paste the mediainfo output.

2016-01-09 20:29 GMT+01:00 Priyank Agrawal notifications@github.com:

I am using android device to capture this audio. Using output format as 3gp and audio encoder as aac. On Jan 10, 2016 12:51 AM, “priyank agrawal” < mr.priyankagrawal@gmail.com

wrote:

There you On Jan 10, 2016 12:44 AM, “Sebastian Annies” < notifications@github.com

wrote:

Could you make an example file available? (Very short please as I only got mobile internet at the moment)

2016-01-09 20:12 GMT+01:00 Priyank Agrawal < notifications@github.com :

Hi it is adts On Jan 10, 2016 12:34 AM, “Sebastian Annies” < notifications@github.com> wrote:

Hi, could you check what kind of AAC you recorded. There are two variant of ‘raw’ AAC:

  • fltp or (aac version 4) which is very uncommon in my eyes (not supported!)
  • and ADTS Could you use mediainfo on your file to see what it is?

— Reply to this email directly or view it on GitHub <

https://github.com/sannies/mp4parser/issues/149#issuecomment-170270052

.

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

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

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

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

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Step-by-step Guide to Replace Audio in Video on Mac/Windows
This tutorial explains 4 easy ways to replace audio in video file for free. Thus, you can remove or replace audio track in...
Read more >
ffmpeg - replace audio in video - Super User
If the audio is longer than the video, you will want to add -shortest before the output file name. Not specifying an audio...
Read more >
How to Change Audio Format of a Video Quickly?
Open Parameter settings below the format image. Next, go to Audio settings and click the Encoder drop-down list. Select your needed audio codec, ......
Read more >
Easiest way to "replace audio in video"? - Gearspace.com
264 encoder twice. Doing it any other way with QT Player Pro will recompress the movie. You will have to encode the audio...
Read more >
Replacing video audio using ffmpeg - Ochre
Replacing video audio using ffmpeg · -i precedes the file you wish to strip the audio from. · -codec copy is to send...
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