- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello i have a monochrom (gray only) video.
Witch i can encode to a h264 video with the umc_video_enc_con without problems( VLC-Player plays it well ).
But i want a mp4 viedo witch can be played by Quicktime (and others).
So i found out that i have to Mux the H264 data into a mp4 Container.
And that is my Problem.
I readed the "umc-manual.pdf" an tried to adapt the sampel code so that it works for me.
The program runs nice and it writes a mp4 file to the Harddrive.
But i could not oben that mp4-file with any player.
I downloaded a programm called MediaInfo witch gives me follwing Information:
So here is the code is use for creating the mp4 file:
Initialization:
Why is the mp4-file not playable?
greetings maxi
Witch i can encode to a h264 video with the umc_video_enc_con without problems( VLC-Player plays it well ).
But i want a mp4 viedo witch can be played by Quicktime (and others).
So i found out that i have to Mux the H264 data into a mp4 Container.
And that is my Problem.
I readed the "umc-manual.pdf" an tried to adapt the sampel code so that it works for me.
The program runs nice and it writes a mp4 file to the Harddrive.
But i could not oben that mp4-file with any player.
I downloaded a programm called MediaInfo witch gives me follwing Information:
[bash]Allgemein Format : MPEG-4 Format profile : Base Media / Version 1 Codec ID : mp41 File size : 129 MiB Duration : 8s 300ms Overall bit rate : 131 Mbps Video ID : 1 Codec ID : 0 Duration : 8s 300ms Bit rate mode : konstant Bit rate : 4 821 Kbps Nominal bit rate : 705 Mbps Width : 320 Pixel Height : 220 Pixel Display aspect ratio : 3:2 Frame rate mode : konstant Frame rate : 30,000 FPS Bits/(Pixel*Frame) : 2.283 Stream size : 4,79 MiB (4%)[/bash]The video should have a playtime from 3min 36sek but the info says its only 8sek long.
So here is the code is use for creating the mp4 file:
Initialization:
[cpp]//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Initialize Encoder
pEncoder = new UMC::H264VideoEncoder();
pEncoderParams = new UMC::H264EncoderParams;
pEncoderParams->info.clip_info.height = height;
pEncoderParams->info.clip_info.width = widht;
pEncoderParams->info.bitrate = bitRate;
pEncoderParams->info.framerate = frameRate;
pEncoderParams->numFramesToEncode = maxNumFrames;
pEncoderParams->chroma_format_idc = 0; //chroma_format_idc (0 - monochrom, 1 - 420, 2 - 422)
pEncoderParams->info.color_format = GRAY;
pEncoderParams->numThreads = 1;
if ((status = pEncoder->Init(pEncoderParams)) != UMC::UMC_OK)
return;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Initialize file writer
pWriter = new UMC::FileWriter();
UMC::FileWriterParams writerParams;
vm_char dstFileName[MAX_FILELEN];
vm_char *ext;
vm_string_strcpy( dstFileName, srcFileName );
ext = vm_string_strrchr( dstFileName, '.' );
ext++;
vm_string_strcpy( ext , "mp4" );
writerParams.m_portion_size = 0;
vm_string_strcpy(writerParams.m_file_name, dstFileName);
if ((status = pWriter->Init(&writerParams)) != UMC::UMC_OK)
return;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Initialize Muxer
pMuxer = new UMC::MP4Muxer();
UMC::MuxerParams MuxerParams;
MuxerParams.m_lpDataWriter = pWriter;
MuxerParams.m_SystemType = UMC::MPEG4_SYSTEM_STREAM;
MuxerParams.m_lFlags = UMC::FLAG_FRAGMENTED_AT_I_PICTURES;
MuxerParams.m_nNumberOfTracks = 1;
MuxerParams.pTrackParams = new UMC::TrackParams[MuxerParams.m_nNumberOfTracks];
MuxerParams.pTrackParams[0].type = UMC::VIDEO_TRACK;
MuxerParams.pTrackParams[0].info.video = &pEncoderParams->info;
MuxerParams.pTrackParams[0].bufferParams.m_prefInputBufferSize=2000000;
MuxerParams.pTrackParams[0].bufferParams.m_prefOutputBufferSize=2000000;
if ((status = pMuxer->Init(&MuxerParams)) != UMC::UMC_OK)
return; [/cpp] Working Loop[bash]UMC::VideoData in;
UMC::VideoData *p_dataIn = ∈
UMC::MediaData out(4*mWidth*mHeight);
UMC::MediaData *p_dataOut = &out;
UMC::Status ret = UMC::UMC_OK;
Ipp32s len;
p_dataIn->Init(mWidth, mHeight, mColorFormat, 8);
p_dataIn->Alloc();
mFramesEncoded = 0;
do
{
if (mFramesEncoded >= mMaxNumFrames)
p_dataIn = NULL; // get frames buffered inside encoder
if (p_dataIn)
{
if (UMC_OK == GetInputData(p_dataIn))
{
p_dataIn->SetTime((mFramesEncoded+1)/pEncoderParams->info.framerate);
}
else
{
p_dataIn = NULL;
}
}
//code video data
ret = pEncoder->GetFrame(p_dataIn, p_dataOut);
if (ret != UMC_OK && ret != UMC_ERR_NOT_ENOUGH_DATA && ret != UMC_ERR_END_OF_STREAM) {
vm_file_fprintf(vm_stderr, VM_STRING("Error: encoding failed at %d source frame (exit with %d)!\n"),
mFramesEncoded, ret);
return UMC_ERR_FAILED;
}
len = (Ipp32s)p_dataOut->GetDataSize();
if (UMC::UMC_OK == ret)
{
ret = pMuxer->PutVideoData( p_dataOut );
if (UMC::UMC_OK == ret)
{
p_dataOut->SetDataSize(0);
}
}
if ( p_dataIn )
{
mFramesEncoded++;
}
else
{
if (!len || ret == UMC_ERR_END_OF_STREAM) break; // EOF
}
if (!(mFramesEncoded % 10))
{
vm_string_printf(VM_STRING("%d."), mFramesEncoded);
}
}while (1);
// EOS for video, inform muxer about it
pMuxer->PutEndOfStream( pMuxer->GetTrackIndex( VIDEO_TRACK ) );[/bash] So please can somebody help me?Why is the mp4-file not playable?
greetings maxi
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maxi,
There is an update muxer sample code at this page. Could you check if this one can help?
Thanks,
Chao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
the sampel helped me to create mpeg files but the mp4 muxing does not work properly.
I still have the problem that the .mp4 Video is only a few seconds long.
Is there any sampel for mp4 muxing?
Or can u give me some help in getting it work?
Maxi
the sampel helped me to create mpeg files but the mp4 muxing does not work properly.
I still have the problem that the .mp4 Video is only a few seconds long.
Is there any sampel for mp4 muxing?
Or can u give me some help in getting it work?
Maxi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Chao Y thanks for the answer.
Tow more question:
Why does the muxer need information about the color format?
Line 46: VideoInfo.color_format=UMC::YV12;
And what color format do i need to feed to the Encoder?
I thought the encoder needs YUV420 and not YV12.
Maxi
Edit:
The h264 encoding and mp4 muxing works fine now.
I feeded the encoder with YUV420 data.
But i still want to know why the muxer needs color format infos.
Tow more question:
Why does the muxer need information about the color format?
Line 46: VideoInfo.color_format=UMC::YV12;
And what color format do i need to feed to the Encoder?
I thought the encoder needs YUV420 and not YV12.
Maxi
Edit:
The h264 encoding and mp4 muxing works fine now.
I feeded the encoder with YUV420 data.
But i still want to know why the muxer needs color format infos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting llt
Why does the muxer need information about the color format?
The muxer dosn't use this info. You may check it yourself.
Color_format is used in encoders.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
> And what color format do i need to feed to the Encoder? I thought the encoder needs YUV420 and not YV12.
It depends on the raw video youre feeding into the encoder.You can check color format values in the corresponding enum (audio-video-codecs\core\umc\include\umc_structures.h):
.....
YV12 = 0, // Planar Y, V, U (4:2:0) (note V,U order!)
YUV420 , // Planar Y, U, V (4:2:0)
...
Thanks,
Chao
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page