littleblank / mp4v2

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

Mp4 writing a mulaw audio as mp4audio #87

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:30

GoogleCodeExporter commented 8 years ago
I have the very similar problem.
Any help will be highly appreciated.

Original comment by leon.pol...@gmail.com on 12 Mar 2011 at 10:51

GoogleCodeExporter commented 8 years ago
Issue 86 has been merged into this issue.

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

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

Original comment by kid...@gmail.com on 17 Mar 2011 at 10:36

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

Original comment by aswin.pa...@gmail.com on 18 Mar 2011 at 4:59

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

Original comment by leon.pol...@gmail.com on 23 Mar 2011 at 8:18

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

Original comment by aswin.pa...@gmail.com on 24 Mar 2011 at 8:01

Attachments:

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

Original comment by kid...@gmail.com on 27 Mar 2011 at 4:13

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

Original comment by aswin.pa...@gmail.com on 27 Mar 2011 at 4:49

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

Original comment by kid...@gmail.com on 26 Apr 2011 at 8:11

GoogleCodeExporter commented 8 years ago
Hi, 

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

Best regards
Sergio

Original comment by sergio.g...@gmail.com on 12 May 2011 at 2:13

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

Original comment by leon.pol...@gmail.com on 13 May 2011 at 12:58

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

Original comment by kid...@gmail.com on 13 May 2011 at 6:18

GoogleCodeExporter commented 8 years ago
I manually figured out the diff and applied it--this should be in r463.

Original comment by kid...@gmail.com on 14 May 2011 at 11:28

GoogleCodeExporter commented 8 years ago
Ups! I planned to do this today!
Sorry to be late.
Kidjan, thank you really!

Original comment by leon.pol...@gmail.com on 15 May 2011 at 6:58

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

Original comment by aswin.pa...@gmail.com on 17 May 2011 at 5:57

GoogleCodeExporter commented 8 years ago
No problem--next time I can help you make a patch.  Thanks for the contribution.

Original comment by kid...@gmail.com on 18 May 2011 at 3:44

GoogleCodeExporter commented 8 years ago
Replicated for Alaw

Original comment by sergio.g...@gmail.com on 22 Jun 2011 at 3:15

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the patch--should be in r476

Original comment by kid...@gmail.com on 24 Jun 2011 at 3:45