clzhan / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 1 forks source link

Mp4 writing a mulaw audio as mp4audio #86

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

Original issue reported on code.google.com by aswin.pa...@gmail.com on 12 Mar 2011 at 2:29

GoogleCodeExporter commented 8 years ago

Original comment by kid...@gmail.com on 12 Mar 2011 at 8:18

GoogleCodeExporter commented 8 years ago
You should use API "MP4AddULawAudioTrack" because "MP4AddAudioTrack" set audio 
format "mp4a" in mp4v2 source code.
Also, I'm trying this and encountering some problem about 
"MP4SetTrackIntegerProperty" fail.
If you have good result, maybe we can discuss it, thx!!

Original comment by rub...@gmail.com on 7 Jul 2015 at 2:23