Hi, Is there a working sample in IPP 7.1 that shows MP4 mux with video? The examples in UMC documentation are not in sync with IPP7.1. The following is a code segment I wrote for converting a H264 pure video stream to an MP4 file. The splitter reading H.264 file works correctly but the MP4 mux produces an empty file (1 KB size). I had the same problem when trying to output TS with MPEG2Muxer. I appreciate any help. thanks. -hari
UMC::Status result;
int nCount = 0;
UMC::MediaData buf;
buf.Alloc(1024*1024);
FileReader reader;
FileReaderParams readerParams;
readerParams.m_sFileName = argv[nInFileNameIdx];
UMC::Status status = reader.Init(&readerParams);
if(status != UMC::UMC_OK)
{
printf("ncan not open input file");
return 1;
}
Splitter *pSplitter = (Splitter*)new ThreadedDemuxer();
if(!pSplitter)
return UMC_ERR_ALLOC;
SplitterParams splitterParams;
splitterParams.m_pDataReader = &reader;
splitterParams.m_iFlags = VIDEO_SPLITTER;
if(UMC_OK != pSplitter->Init(&splitterParams))
{
UMC_DELETE(pSplitter);
return UMC_ERR_FAILED;
}
pSplitter->Run();
// init muxer
UMC::MP4Muxer outMP4Muxer;
UMC::MuxerParams muxerParams;
UMC::FileWriter writer;
UMC::FileWriterParams writerParams;
UMC::AudioStreamInfo audioInfo;
UMC::VideoStreamInfo videoInfo;
// Initialize file writer
//writerParams.m_iBufferSize = 0;
writerParams.m_sFileName = argv[nOutFileNameIdx];
result = writer.Init(&writerParams);
if(result != UMC::UMC_OK)
{
printf("ncan not create file writer: %s", argv[nOutFileNameIdx]);
return 1;
}
// Fill params structure
muxerParams.m_lpDataWriter = &writer;
muxerParams.m_SystemType = MPEG4_SYSTEM_STREAM; //UMC::H264_PURE_VIDEO_STREAM;; //
muxerParams. m_lFlags = UMC::FLAG_START_WITH_HEADER|UMC::FLAG_FRAGMENTED_AT_I_PICTURES;// | FLAG_DATA_FROM_SPLITTER;; //FLAG_FRAGMENTED_AT_I_PICTURES | FLAG_DATA_FROM_SPLITTER;
muxerParams.m_nNumberOfTracks = 1; // currently video only; streamInfo->m_nOfTracks;
int videoTrackNo = 0;
muxerParams.m_pTrackParams = new UMC::TrackParams[muxerParams.m_nNumberOfTracks];
// video info
// video params
muxerParams.m_pTrackParams[videoTrackNo].type = UMC::VIDEO_TRACK;
muxerParams.m_pTrackParams[videoTrackNo].bufferParams.m_prefInputBufferSize=50000;//20000000;
muxerParams.m_pTrackParams[videoTrackNo].bufferParams.m_prefOutputBufferSize= 50000;//20000000;
muxerParams.m_pTrackParams[videoTrackNo].bufferParams.m_numberOfFrames = 30;
UMC::SplitterInfo *pSplInfo = new SplitterInfo();
pSplitter->GetInfo(&pSplInfo);
muxerParams.m_pTrackParams[videoTrackNo].info.video = (UMC::VideoStreamInfo *)pSplInfo->m_ppTrackInfo[0]->m_pStreamInfo;
//muxerParams.m_pTrackParams[videoTrackNo].info.video = new UMC::VideoStreamInfo();
//muxerParams.m_pTrackParams[videoTrackNo].info.video->iBitrate = 2000000;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->streamType = UMC::H264_VIDEO;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->streamSubtype = UMC::AVC1_VIDEO;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->videoInfo.m_colorFormat = UMC::YV12;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->fFramerate = 60;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->videoInfo.m_iHeight = 720;
//muxerParams.m_pTrackParams[videoTrackNo].info.video->videoInfo.m_iWidth = 1280;
// call init
result = outMP4Muxer.Init(&muxerParams);
if(result != UMC::UMC_OK)
{
printf("ncan not create MP4 mux for: %s", argv[nOutFileNameIdx]);
return 1;
}
int nTotSize = 0;
float nFramePeriod = 1.0/60;
float nCutTS = 0.0;
// read frames
for(;;)
{
// ask for video input buffer
status = outMP4Muxer.LockBuffer(&buf, 0);
if (UMC::UMC_OK == status) {
//read next frame
do
{
status = pSplitter->GetNextData(&buf, 0);
} while(status == UMC_ERR_NOT_ENOUGH_DATA);
if(status == UMC_ERR_END_OF_STREAM){
printf("nEnd of stream");
outMP4Muxer.PutEndOfStream(0);
outMP4Muxer.Close();
break;
}
else if(status != UMC_OK)
{
printf("ncan not get data from splitter");
}
else
{
buf.m_fPTSEnd = buf.m_fPTSStart = nCutTS;
buf.m_fPTSEnd = nCutTS + nFramePeriod;
nCutTS += nFramePeriod;
printf("nPTS-St: %f PTS-Ed: %f FrmType: %d", buf.m_fPTSStart, buf.m_fPTSEnd, buf.m_frameType);
status = outMP4Muxer.UnlockBuffer(&buf, 0);
printf("nFrame %d size: %d status: %d", nCount++, buf.GetDataSize(), status);
nTotSize += buf.GetDataSize();
}
}
}
printf("nTotal data: %d", nTotSize);
printf("n MP4 mux for: %s", argv[nOutFileNameIdx]);