Export to GitHub

mp4v2 - issue #87

Mp4 writing a mulaw audio as mp4audio


Posted on Mar 12, 2011 by Swift Camel

Hi,

i'm trying to write the audio sample to the mp4 container by setting the audio type as MULAW with 8000hz as sample and mono channel.

when i try to play using vlc or any other player, i dont hear a thing and vlc shows the audio format as mp4a.

can anybody let me know what i have done wrong.

here is the code snippet.

MP4FileHandle mp4_file = MP4Create("out.mp4", 0);//

MP4TrackId mp4_video_track = MP4AddH264VideoTrack (mp4_file, 50000, 2500, 704, 576,
                                                   0x64,     //sps[1] AVCProfileIndication  
                                                   0x00,     //sps[2] profile_compat        
                                                   0x1f,     //sps[3] AVCLevelIndication    
                                                   3 );      // 4 bytes length before each NAL unit  
MP4SetVideoProfileLevel(mp4_file, 1);// 0x7F);


MP4TrackId mp4_audio_track = MP4AddAudioTrack( mp4_file, 44100, 
                                              MP4_INVALID_DURATION, 
                                              MP4_ULAW_AUDIO_TYPE);
if( mp4_audio_track == MP4_INVALID_TRACK_ID ) {
    cout << "MP4AddAudioTrack error" << endl;
    return false;
}
//MP4SetAudioProfileLevel( mp4_file, 0x0f ); //??

bool  a = MP4SetTrackIntegerProperty( mp4_file,  mp4_audio_track,
                                     "mdia.minf.stbl.stsd.mp4a.channels", 1);  //Set a single audio channel 


int ac =   MP4GetTrackAudioChannels(mp4_file,  mp4_audio_track); // only check
u_int8_t tes= MP4GetTrackAudioMpeg4Type(mp4_file,mp4_audio_track);

.

. . . if( !MP4WriteSample( mp4_file, mp4_audio_track, audio, alen, 5000, 0, false ) ) { cout << "WARNING: MP4WriteSample failed" << endl; break; }

Thanks Aswin

Comment #1

Posted on Mar 12, 2011 by Massive Kangaroo

I have the very similar problem. Any help will be highly appreciated.

Comment #2

Posted on Mar 12, 2011 by Happy Lion

Issue 86 has been merged into this issue.

Comment #3

Posted on Mar 17, 2011 by Happy Lion

I tried to get this working once before, but I wasn't sure how either. Definitely if you figure it out, let me know so I can document it somewhere.

Comment #4

Posted on Mar 18, 2011 by Swift Camel

Kidjan,

do you mean to say that it is a know problem with the code or you are not sure about how to write the audio sample in to the file.

could you let us know how i need to address this problem.

Thanks, Aswin.N.Paranji

Comment #5

Posted on Mar 23, 2011 by Massive Kangaroo

Hello, all. May be (well,sure!) I do not understand something, but we a\have the following situation: We add the audio track and describe it U-LOW as described above. The created file is fine and played back by MPlayer fine, except that instead of U-LOW it plays audio as RAW. We checked this by providing RAW data instead of U-LOW, and the sound was perfect.

So, now the only question is - what is the correct way to define the U-LOW stream, which is now understood as RAW.

Many thanks ahead.

Comment #6

Posted on Mar 24, 2011 by Swift Camel

kidjan, i have added support for the ulaw. could you please validate and let me know the status.

Thanks, Aswin

File: include/track/mp4v2/track.h added a function 'MP4AddULawAudioTrack'

File: src/mp4.cpp implemented the function MP4AddULawAudioTrack

File: src/mp4file.h added function AddULawAudioTrack inside the class MP4File

File: src/mp4file.cpp implemented the function AddULawAudioTrack

Attachments

Comment #7

Posted on Mar 27, 2011 by Happy Lion

Aswin,

Thanks for that--could you give me a brief description of the format of the track? And I'll try and get those changes in sometime this week.

Comment #8

Posted on Mar 27, 2011 by Swift Camel

Kidjan, the format of the audio is MuLaw, mono channel with sample rate of 8000 hz. the video is h264 format. i believe the same code can be used to write a-law audio too, for which the atom has to be changed. i haven't tried with a law audio.

Comment #9

Posted on Apr 26, 2011 by Happy Lion

Is there any chance I could get you to supply this as a diff file against trunk? If I have to, I can figure out what changes you made myself, but a diff is a lot easier for me.

Comment #10

Posted on May 12, 2011 by Happy Panda

Hi,

I am highly interested in this topic, is there anything I can do to help (develop or debug)?

Best regards Sergio

Comment #11

Posted on May 13, 2011 by Massive Kangaroo

For now it seems working in the form Aswin proposed. There was not notification from Kidjan about his efforts to incorporate this into main source tree...:-(

Comment #12

Posted on May 13, 2011 by Happy Lion

@leon

I did notify about my efforts--the changes were not supplied as a patch file, but just modified files, which makes it difficult to put into trunk. I asked for patch files.

I'll attempt to do it without, but if someone--anyone--could supply working patch files against trunk, that would make this change happen much quicker.

Comment #13

Posted on May 14, 2011 by Happy Lion

I manually figured out the diff and applied it--this should be in r463.

Comment #14

Posted on May 15, 2011 by Massive Kangaroo

Ups! I planned to do this today! Sorry to be late. Kidjan, thank you really!

Comment #15

Posted on May 17, 2011 by Swift Camel

Kidjan,

sorry i did not know how to create a patch against the trunk. hence i attached the whole working file. thank you for the effort.

Aswin

Comment #16

Posted on May 18, 2011 by Happy Lion

No problem--next time I can help you make a patch. Thanks for the contribution.

Comment #17

Posted on Jun 22, 2011 by Happy Panda

Replicated for Alaw

Attachments

Comment #18

Posted on Jun 24, 2011 by Happy Lion

Thanks for the patch--should be in r476

Status: Fixed

Labels:
Type-Other Priority-Medium