jaeguly / mp4v2

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

Generate mp4 file.Can't play by media player. #180

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

I use mp4v2 to generate mp4 file.
vlc can play.
But media player can't play it.

m_pAviFile = MP4CreateEx("test.mp4", 0xFFFFFFFF, 1, 0, 0, 0, 0); // 
創建mp4文件  1.mp4 ,存在會蓋過去

if(m_pAviFile==MP4_INVALID_FILE_HANDLE)
    return false;

 MP4SetTimeScale(m_pAviFile, 90000 );

   //添加h264 track

 m_video = MP4AddH264VideoTrack(m_pAviFile, 90000 , 90000 / 30 , 600 , 480 ,
     0x64 , // sps[1] AVCProfileIndication 
     0x00 , // sps[2] profile_compat 
     0x1f , // sps[3] AVCLevelIndication 
     3 ); // 4 bytes length before each NAL 

if (m_video == MP4_INVALID_TRACK_ID) //ok return video:1
{
    MP4Close(m_pAviFile);
    m_pAviFile=NULL;
    m_video=0;
    m_audio=0;
    return false;
}

MP4SetVideoProfileLevel(m_pAviFile, 0x7F);

//add audio
m_audio = MP4AddAudioTrack(m_pAviFile, 8000, 1024, MP4_MPEG4_AUDIO_TYPE);

if (m_audio == MP4_INVALID_TRACK_ID) 
{
    MP4Close(m_pAviFile);
    m_pAviFile=NULL;
    m_video=0;
    m_audio=0;
    return false;
}

MP4SetAudioProfileLevel(m_pAviFile, 0x2);

Original issue reported on code.google.com by gn01887...@gmail.com on 24 Jul 2015 at 7:30