📄 umc_transcoder_con_main.cpp
字号:
/*//////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2003-2007 Intel Corporation. All Rights Reserved.
//
*/
//-i "input file name"
//-t "input audio file name"
//-s "file of parameters for output video"
//default video settings:
// use input stream's resolution,
// bitrate = 5Mbps
//-o "output file name"
//-af_mp3 output audio as MP3
//-af_non no audio output
//-vf_mpeg2_ts output video as MPEG2 TS
//-vf_mpeg2_pu output video as MPEG2 pure, sets oaf_none also
//-vf_mpeg4_at output video as MPEG4 MP4 ATOM
//-vf_mpeg4_ts output video as MPEG2 TS
//-vf_mpeg4_pu output video as MPEG4 pure video
//-vf_h_264_at output video as H.264 MP4ATOM
//-vf_h_264_ts output video as H.264 TS
//-vf_h_264_pu output video as H.264 pure video
#include "umc_transcoder_con.h"
#include <stdio.h>
#if defined ( WIN32 ) || defined ( WIN64 ) || defined (_WIN32)
#include <conio.h>
#endif
#include <iostream>
void PrintHelp(char* name)
{
vm_string_printf("usage of UMC Transcoder:\n umc_transcoder_con.exe -i file [-options]\n");
vm_string_printf("\nOptions:\n");
vm_string_printf("-i input file name\n");
vm_string_printf("-t input audio stream\n");
vm_string_printf("-s file of parameters for output video\n");;
vm_string_printf("-o output file name\n\n");
vm_string_printf("-af_mp3 output audio as MP3\n");
vm_string_printf("-af_non no audio output\n\n");
vm_string_printf("-vf_mpeg2_ps output video as MPEG2 PS\n");
vm_string_printf("-vf_mpeg2_ts output video as MPEG2 TS\n");
vm_string_printf("-vf_mpeg2_pv output video as MPEG2 pure video\n");
vm_string_printf("-vf_mpeg4_pv output video as MPEG4 pure video\n");
vm_string_printf("-vf_mpeg4_ts output video as MPEG4 TS\n");
vm_string_printf("-vf_mpeg4_at output video as MPEG4 atom\n");
vm_string_printf("-vf_h_264_pv output video as H.264 pure video\n");
vm_string_printf("-vf_h_264_ts output video as H264 TS\n");
vm_string_printf("-vf_h_264_at output video as H264 atom\n");
vm_string_printf("-vf_vc1_pv output video as MPEG2 PS\n");
}
volatile bool stop_stat_flag;
Ipp32u VM_THREAD_CALLCONVENTION StatThreadFunc(void* ptr)
{
char cStr[1024];
Transcoder *m_lpTranscoder = (Transcoder*)ptr;
if(!m_lpTranscoder)
return 0;
vm_string_sprintf(cStr, "Frame(s)\tavg perf fps\tcur perf fps\tElapsed time\tremain time\n");
vm_string_printf(cStr);
while(stop_stat_flag)
{
//vm_string_printf(".");
long lProgress = 0;
Ipp64f dProgress = 0.0;
Ipp64u lCurTime = vm_time_get_tick() / vm_time_get_frequency();
// get progress
dProgress = m_lpTranscoder->GetProgress();
if (-1.0 == dProgress)
return 0;
lProgress = static_cast<long> (dProgress * 100.0);
Ipp64f dTime, dRemain;
Ipp32u lFrames, lTime, lRemain;
static long lPreviousFrameNumber = 0;
static Ipp64f dPreviousTime = 0.0;
// get statistic
m_lpTranscoder->GetPerformance(lFrames, dTime);
lTime = static_cast<long> (dTime + 0.5);
dRemain = (dTime * (1.0 - dProgress)) / dProgress;
lRemain = static_cast<long> (dRemain + 0.5);
vm_string_sprintf(cStr,
"%d\t\t%.2f\t\t%.2f\t\t%02dh %02dm %02ds\t%02dh %02dm %02ds\n",
lFrames,
(0.0 != dTime) ? (static_cast<Ipp64f> (lFrames) / dTime) : (0.0),
(dTime != dPreviousTime) ? (static_cast<Ipp64f> (lFrames - lPreviousFrameNumber) / (dTime - dPreviousTime)) : (0.0),
(lTime / 3600),
((lTime % 3600) / 60),
(lTime % 60),
(lRemain / 3600),
((lRemain % 3600) / 60),
(lRemain % 60));
// save values
lPreviousFrameNumber = lFrames;
dPreviousTime = dTime;
vm_string_printf(cStr);
vm_time_sleep(50);
}
return 1;
}
UMC::Status ParseCommandLineArgs(Ipp32u argc, vm_char* argv[], TranscoderParams& t_params)
{
UMC::Status umcRes = UMC::UMC_OK;
Ipp32u i = 1;
if(argc == 1)
{
PrintHelp(argv[0]);
return 0;
}
while (UMC::UMC_OK == umcRes && i < argc)
{
size_t stArgLen = vm_string_strlen(argv[i]);
if ('-' == argv[i][0])
{
switch (argv[i][1])
{
case 'i'://input video file
//-i "input video file name"
if (2 == stArgLen)
t_params.input_video_filename = argv[++i];
else
t_params.input_video_filename = argv[i] + 2;
break;
case 's'://settings file
//-s "file of parameters for output video"
if (2 == stArgLen)
t_params.par_filename = argv[++i];
else
t_params.par_filename = argv[i] + 2;
break;
case 't'://input audio file
//-t "input audio file"
if (2 == stArgLen)
t_params.input_audio_filename = argv[++i];
else
t_params.input_audio_filename = argv[i] + 2;
break;
case 'o'://output file
//-o "output file name"
if (2 == stArgLen)
t_params.output_filename = argv[++i];
else
t_params.output_filename = argv[i] + 2;
break;
case 'a'://audio format
//-af_mp3 output audio as MP3, default
//-af_aac output audio as AAC
//-af_non no audio output
if(0 == vm_string_strcmp(argv[i], VM_STRING("-af_mp3")))
t_params.audio_stream_type = UMC::MP1L3_AUDIO;
else if(0 == vm_string_strcmp(argv[i], VM_STRING("-af_aac")))
t_params.audio_stream_type = UMC::AAC_AUDIO;
else if(0 == vm_string_strcmp(argv[i], VM_STRING("-af_non")))
t_params.audio_stream_type = UMC::UNDEF_AUDIO;
else
{
vm_string_printf(__VM_STRING("Unknown option (a): %s\n"), argv[i]);
umcRes = UMC::UMC_ERR_FAILED;
}
break;
case 'v'://video format
//-vf_mpeg2_ps output video as MPEG2 PS
//-vf_mpeg2_ts output video as MPEG2 TS
//-vf_mpeg2_pv output video as MPEG2 pure, sets oaf_none also
//-vf_mpeg4_pv output video as MPEG4 pure video, sets oaf_none also
//-vf_mpeg4_ps output video as MPEG4 programm stream
//-vf_mpeg4_ts output video as MPEG4 transport stream
//-vf_mpeg4_at output video as MP4 atom stream
//-vf_h_264_pv output video as H.264 pure video, sets oaf_none also
//-vf_h_264_ts output video as H.264 pure video
//-vf_h_264_at output video as H264 MP4 atom stream
//-vf_non
if(0 == vm_string_strcmp(argv[i], VM_STRING("-vf_mpeg2_ps")))
{
t_params.video_stream_type = UMC::MPEG2_VIDEO;
t_params.system_stream_type = UMC::MPEG2_PROGRAMM_STREAM;
}
else if(0 == vm_string_strcmp(argv[i], VM_STRING("-vf_mpeg2_ts")))
{
t_params.video_stream_type = UMC::MPEG2_VIDEO;
t_params.system_stream_type = UMC::MPEG2_TRANSPORT_STREAM;
}
else if(0 == vm_string_strcmp(argv[i], VM_STRING("-vf_mpeg2_pv")))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -