- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear supporter
Is it possbile for direct video/audio stream copy using IPP's UMC class ?
I have tested IPP 6.0's UMC class for video transcoder.
The sample project (umc_transcoder_con) can transcode the video/aduio.
I want to transcode video stream only, not audio stream.
I would like to know the method for direct stream copy.
When the transcoder process muxing video and audio,
video has converted or transcoded, but audio stream is not converted and
directly copying stream.
Or Audio has converted or transcoded, but video stream is not conveted nad
directly copying stream.
The sample transcoder is followed...
If you uncomment "#define DIERCT_COPY_ONLY", the process will be direct
video stream copy mode..
But this mode has critical error and infinite loop.
If you comment "#define DIERCT_COPY_ONLY", the process will be normal
transcode mode. This mode is good for mp4(h.264/aac).
Please advise me for direct stream copy mode in muxing video/audio process..
Thanks....
Is it possbile for direct video/audio stream copy using IPP's UMC class ?
I have tested IPP 6.0's UMC class for video transcoder.
The sample project (umc_transcoder_con) can transcode the video/aduio.
I want to transcode video stream only, not audio stream.
I would like to know the method for direct stream copy.
When the transcoder process muxing video and audio,
video has converted or transcoded, but audio stream is not converted and
directly copying stream.
Or Audio has converted or transcoded, but video stream is not conveted nad
directly copying stream.
The sample transcoder is followed...
If you uncomment "#define DIERCT_COPY_ONLY", the process will be direct
video stream copy mode..
But this mode has critical error and infinite loop.
If you comment "#define DIERCT_COPY_ONLY", the process will be normal
transcode mode. This mode is good for mp4(h.264/aac).
Please advise me for direct stream copy mode in muxing video/audio process..
Thanks....
[cpp]#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_file_writer.h"
#include "vm_time.h"
#include "vm_strings.h"
#include "umc_mp4_mux.h"
#define MAXAFRAMESIZE 1000000
#define MAXYUVSIZE 200000000
// from simple_splitter
#include "ipp.h"
#include "umc_file_reader.h"
#include "umc_fio_reader.h"
#include "umc_mp4_spl.h"
#include "umc_splitter.h"
#include "umc_video_render.h"
#include "fw_video_render.h"
#include "umc_h264_dec.h"
#include "vm_time.h"
#define DIERCT_COPY_ONLY
void DirectStreamCopyForVideo(char* pcSrcFile, char* psDstFile)
{
/*
* splitter.....
*/
Ipp32u videoTrack = 0;
int exit_flag = 0;
UMC::Status status;
UMC::MediaData in;
UMC::FIOReader reader;
UMC::FileReaderParams readerParams;
UMC::SplitterParams splitterParams;
UMC::SplitterInfo* streamInfo;
UMC::MP4Splitter Splitter;
UMC::VideoStreamInfo* videoInfo=NULL;
#ifndef DIERCT_COPY_ONLY
UMC::VideoDecoder* videoDecoder;
UMC::VideoDecoderParams videoDecParams;
Ipp8u* pcDecodedVideoBuffer=NULL;
Ipp32u nBuffersize=1920*1080*4;
pcDecodedVideoBuffer = ippsMalloc_8u(nBuffersize); // max...
#endif
readerParams.m_portion_size = 0;
vm_string_strcpy(readerParams.m_file_name, pcSrcFile);
if ((status = reader.Init(&readerParams))!= UMC::UMC_OK)
return;
splitterParams.m_lFlags = UMC::VIDEO_SPLITTER;
splitterParams.m_pDataReader = &reader;
if((status = Splitter.Init(splitterParams))!= UMC::UMC_OK)
return;
Splitter.GetInfo(&streamInfo);
for (videoTrack = 0; videoTrack < streamInfo->m_nOfTracks; videoTrack++) {
if (streamInfo->m_ppTrackInfo[videoTrack]->m_Type == UMC::TRACK_H264)
break;
}
videoInfo = (UMC::VideoStreamInfo*)(streamInfo->m_ppTrackInfo[videoTrack]->m_pStreamInfo);
if(videoInfo->stream_type!=UMC::H264_VIDEO)
return;
#ifndef DIERCT_COPY_ONLY
videoDecParams.info = (*videoInfo);
videoDecParams.m_pData = streamInfo->m_ppTrackInfo[videoTrack]->m_pDecSpecInfo;
videoDecParams.numThreads = 1;
videoDecoder = (UMC::VideoDecoder*)(new UMC::H264VideoDecoder());
if((status = videoDecoder->Init(&videoDecParams))!= UMC::UMC_OK)
return;
#endif
/*
* Muxer...
*/
UMC::MediaData MuxData,MediaEncoded;
UMC::MP4Muxer Muxer;
UMC::MuxerParams MuxerParams;
UMC::FileWriter Writer;
UMC::FileWriterParams WriterParams;
strcpy(WriterParams.m_file_name, psDstFile);
if ((status = Writer.Init(&WriterParams)) != UMC::UMC_OK)
return;
MuxerParams.m_lpDataWriter = &Writer;
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 = videoInfo;
MuxerParams.pTrackParams[0].bufferParams.m_prefInputBufferSize=2000000;
MuxerParams.pTrackParams[0].bufferParams.m_prefOutputBufferSize=2000000;
if ((status = Muxer.Init(&MuxerParams)) != UMC::UMC_OK)
return;
#ifndef DIERCT_COPY_ONLY
UMC::H264EncoderParams Params;
UMC::H264VideoEncoder H264Encoder;
UMC::VideoData MediaDst;
Params.info.clip_info.height = videoInfo->clip_info.height;
Params.info.clip_info.width = videoInfo->clip_info.width;
Params.info.bitrate = 1000000;
Params.numThreads = 1;
if((status = H264Encoder.Init(&Params)) != UMC::UMC_OK)
return;
MediaDst.Init(videoInfo->clip_info.width,
videoInfo->clip_info.height,
videoInfo->color_format);
MediaDst.Alloc();
#endif
int nLen;
int nEncodedFrames=0;
Ipp32s nRet;
UMC::Status muxstatus;
Splitter.Run();
do
{ do
{ if ( (nLen = in.GetDataSize()) < 4)
{ do
{ status= Splitter.GetNextData(&in,videoTrack);
if (status==UMC::UMC_ERR_NOT_ENOUGH_DATA)
vm_time_sleep(5);
} while(status==UMC::UMC_ERR_NOT_ENOUGH_DATA);
if (((status != UMC::UMC_OK) && (status != UMC::UMC_ERR_END_OF_STREAM))||
(status == UMC::UMC_ERR_END_OF_STREAM)&& (in.GetDataSize()<4))
{
exit_flag=1;
}
#ifndef DIERCT_COPY_ONLY
videoDecoder->GetFrame(&in,&MediaDst);
MediaEncoded.SetBufferPointer(pcDecodedVideoBuffer, nBuffersize);
MediaEncoded.SetDataSize(0);
MediaDst.SetFrameType(UMC::NONE_PICTURE);
muxstatus = H264Encoder.GetFrame(&MediaDst, &MediaEncoded);
if (muxstatus == UMC::UMC_OK)
{
nEncodedFrames++;
MuxData.SetBufferPointer((Ipp8u*)MediaEncoded.GetBufferPointer(),MediaEncoded.GetDataSize());
memcpy(MuxData.GetDataPointer(),MediaEncoded.GetDataPointer(), MediaEncoded.GetDataSize());
MuxData.SetDataSize(MediaEncoded.GetDataSize());
MuxData.SetTime(nEncodedFrames*((double)1.0)/30);
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);
}
#else
nEncodedFrames++;
MuxData.SetBufferPointer((Ipp8u*)in.GetBufferPointer(),in.GetDataSize());
memcpy(MuxData.GetDataPointer(),in.GetDataPointer(), in.GetDataSize());
MuxData.SetDataSize(in.GetDataSize());
MuxData.SetTime(nEncodedFrames*((double)1.0)/30);
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);
#endif
}
} while(!exit_flag && (status == UMC::UMC_ERR_NOT_ENOUGH_DATA || status == UMC::UMC_ERR_SYNC));
} while (exit_flag!=1);
Muxer.Close();
return;
}
#if 1
int main(int argc, vm_char* argv[])
{
ippStaticInit();
DirectStreamCopyForVideo(argv[1],argv[2]);
return 0;
}
#endif
[/cpp]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need consume data from MediaData object after splitter get the next portion of it. I think you may develop direct_copy UMC object which mimic to decoder and behave similarly but do not decode data. Please take a look at UMC manual and source code on how UMC decoders are implemented
Vladimir
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to convert jpeg files to video(.mp4 format) using intelIPP 7
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