Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

UMC::MPEG4Muxer usage

Tamer_Assad
Innovator
996 Views
Hi,

working with UMC::MPEG4Muxer
What are the correct parameters/settings and function calls? I'v been working with the UMC documentation example as well as the MPEG2Muxer sample "http://software.intel.com/en-us/articles/getting-started-with-intel-ipp-unified-media-classes-sample/" as guides, however, I seem to be missing somthing.

I'm trying to perform a simple multipex operation using a single mpeg4 track (video) only, but the ".mp4" product of the "MPEG4Muxer" I'm getting, is not playble, even with UMC player sample, it finishs playing immediately, as if there is no video available, the same result I get by mediaPlayer classic and videoLan.
original mpeg4 video stream is produced within the same test, and it works well.

the steps I tried are:
1) assigning the muxerparams, and videoinfo
2) Init();
3) encoder.GetFrame();

then, one of the following:
a- LockBuffer(); copy memory to muxer buffer; unlockBuffer ();
b- copy memory to muxer buffer; putData();
c- copy memory to muxer buffer; putVideoData();

a,b, and c were not successful, what is the right way to have the MPEG4Muxer working?
Regards,
Tamer Assad
0 Kudos
3 Replies
Tamer_Assad
Innovator
996 Views
Hi,

examinig the .mp4 product file, it seems to be MP4 version "1"
UMC::MP4Muxer follows the (ISO/IEC 14496-14) among other standards, I assume this means it is possible to produce mp4 version 2 file/atoms, is this true? if it is, how can I do so?

Best regards,
Tamer Assad
0 Kudos
Tamer_Assad
Innovator
996 Views

Hi,

I was trying (mistakingly) to mux an MP2 video stream into .mp4 file using the UMC:: MP4Muxer.

Multiplexing an MPEG4 encoded video with UMC:: MP4Muxer resulted in a prety playable .mp4 file (thanks to IPP guys).

Regarding the muxer function call sequence, PutData() encapsulates the necessary calls to Lock/UnlocBuffer functions.

I still have the question about the MP4 file type version, why version "1"?!

Best regards,

Tamer Assad
0 Kudos
Ying_H_Intel
Employee
996 Views
Hi Tamer,

Would you like share your MPEG4 mux code here so more developers can refer toithere?
I attached one simple code we have used ashttp://software.intel.com/en-us/articles/getting-started-with-intel-ipp-unified-media-classes-sample/

About the version 1 and version 2, do you know what's the difference?
As I understand, both MP41 and MP42 headers belong to ISO 14496 standard and should be supported by all splitters. IPP MP4 Muxer writes MP41.If you'd like, youcan change it to MP42, but not sure if it is necessary.

Best Regards,
Ying

//mp4muxer sample code

#include
#include

#include "ipp.h"
#include "umc_defs.h"
#include "umc_video_data.h"
#include "umc_h264_video_encoder.h"
#include "umc_structures.h"
#include "umc_video_encoder.h"
#include "umc_mpeg2_muxer.h"
#include "umc_mp4_mux.h"
#include "umc_file_writer.h"
#include "vm_time.h"
#include "vm_strings.h"


#define MAXAFRAMESIZE 1000000
#define MAXYUVSIZE 200000000

void EncodeStream(Ipp8u *cYUVData, int imgWidth, int imgHeight, int frameNumber,char * tsFileName)
{
UMC::Status status;
UMC::MediaData DataOut, MuxData; UMC::VideoData DataIn;
UMC::H264EncoderParams Params; UMC::H264VideoEncoder H264Encoder;
// UMC::MPEG2Muxer Muxer; UMC::MPEG2MuxerParams MuxerParams;
UMC::MP4Muxer Muxer;
UMC::MuxerParams MuxerParams;

Ipp8u *cMaxVideoData=NULL;

UMC::VideoStreamInfo VideoInfo;

UMC::FileWriter Writer; UMC::FileWriterParams WriterParams;
strcpy(WriterParams.m_file_name, VM_STRING(tsFileName));
Writer.Init(&WriterParams);

MuxerParams.m_lpDataWriter = &Writer;
//MuxerParams.m_SystemType = UMC:: MPEG2_TRANSPORT_STREAM;
MuxerParams.m_SystemType = UMC::MPEG4_PURE_VIDEO_STREAM;

MuxerParams.m_nNumberOfTracks = 1;
MuxerParams.pTrackParams = new UMC::TrackParams[MuxerParams.m_nNumberOfTracks];

VideoInfo.clip_info.height=imgHeight; VideoInfo.clip_info.width=imgWidth;
VideoInfo.stream_type=UMC::H264_VIDEO;
VideoInfo.color_format=UMC::YV12; VideoInfo.interlace_type=UMC::PROGRESSIVE;
VideoInfo.bitrate=64000000; VideoInfo.streamPID=0;

MuxerParams.pTrackParams[0].type = UMC::VIDEO_TRACK;
MuxerParams.pTrackParams[0].info.video = &VideoInfo;
MuxerParams.pTrackParams[0].bufferParams.m_prefInputBufferSize=2000000;
MuxerParams.pTrackParams[0].bufferParams.m_prefOutputBufferSize=2000000;

if((status =Muxer.Init(&MuxerParams))!=UMC::UMC_OK)
return;

Params.info.clip_info.height=imgHeight; Params.info.clip_info.width=imgWidth;
Params.info.bitrate = 64000000;
Params.numThreads = 1;
if((status = H264Encoder.Init(&Params))!=UMC::UMC_OK)
return;

cMaxVideoData= ippsMalloc_8u(MAXAFRAMESIZE);
DataIn.Init(imgWidth,imgHeight,UMC::YV12,8);
DataIn.SetBufferPointer(cYUVData,imgWidth*imgHeight*3/2);
DataIn.SetDataSize(imgWidth*imgHeight*3/2);
DataOut.SetBufferPointer(cMaxVideoData,MAXAFRAMESIZE);

int nEncodedFrames=0;
while ( nEncodedFrames < frameNumber)
{
status = H264Encoder.GetFrame(&DataIn, &DataOut);
if (status == UMC::UMC_OK) {
nEncodedFrames++;

MuxData.SetBufferPointer((Ipp8u*)DataOut.GetBufferPointer(),DataOut.GetDataSize());
memcpy(MuxData.GetDataPointer(),DataOut.GetDataPointer(), DataOut.GetDataSize());
MuxData.SetDataSize(DataOut.GetDataSize());
MuxData.SetTime(nEncodedFrames*((double)1.0)/15);
do {
status = Muxer.PutVideoData(&MuxData);
if (UMC::UMC_ERR_NOT_ENOUGH_BUFFER == status)
vm_time_sleep(5);
}while (UMC::UMC_ERR_NOT_ENOUGH_BUFFER == status);

cYUVData+=imgWidth*imgHeight*3/2;
DataIn.SetBufferPointer(cYUVData,imgWidth*imgHeight*3/2);
DataIn.SetDataSize(imgWidth*imgHeight*3/2);
DataOut.SetBufferPointer(cMaxVideoData,MAXAFRAMESIZE);
}
}
Muxer.Close();
return;
}

void ReadYUVData(char* strFilename,Ipp8u *cYUVData, int imgWidth, int imgHeight, int frameNumber)
{
FILE* infp = fopen(strFilename, "rb");
if(infp==NULL)
return ;
fread(cYUVData,1,frameNumber*imgWidth*imgHeight*3/2, infp);
fclose(infp);
}


int main(int argc, vm_char* argv[]) {
ippStaticInit();

Ipp8u *cYUVData = ippsMalloc_8u(MAXYUVSIZE);
int VideoDataSize;

ReadYUVData("stream352x288.yuv",cYUVData,352,288,200);
EncodeStream(cYUVData,352,288,200,"testout.mp4");

return 0;
}

0 Kudos
Reply