使用FFMPEG进行视频截取与合并
2013-11-02 10:27
561 查看
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
char pBuf[512];
_getcwd(pBuf, 512); ////获取当前路径
string ffmpegPath = string(pBuf) +"/"+"ffmpeg";
wchar_t lpFile[512];
Acsii2WideByte(ffmpegPath.c_str(), lpFile);
ShExecInfo.lpFile = lpFile; ///默认为当前目录下
string shExe_lpParameters = "";
if(is_codec)
{
sprintf(pBuf, " -vframes %d -s %dx%d -r %d ", frames, width, height, fps);
shExe_lpParameters = "-y -i " + input_video +" -ss " + start_time + pBuf +"-vcodec flv1 " + out_video;
}
else
{
sprintf(pBuf, " -vframes %d -r %d ", frames, fps);
shExe_lpParameters = "-y -i " + input_video +" -ss " + start_time + pBuf +"-vcodec copy " + out_video;
}
wchar_t lpParam[512];
Acsii2WideByte(shExe_lpParameters.c_str(), lpParam);
ShExecInfo.lpParameters = lpParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
BOOL bResult = ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
if( ShExecInfo.hProcess != NULL)
{
TerminateProcess(ShExecInfo.hProcess,0);
CloseHandle(ShExecInfo.hProcess);
ShExecInfo.hProcess = NULL;
}
ShExecInfo.lpFile = NULL;
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
char pBuf[512];
_getcwd(pBuf, 512);
string memcoderPath = string(pBuf) +"/"+"mencoder.exe";
wchar_t lpFile[512];
Acsii2WideByte(memcoderPath.c_str(), lpFile);
ShExecInfo.lpFile = lpFile; ///默认为当前目录下
string shExe_lpParameters = videoname1 + " " + videoname2 + " -ovc copy -o " + mergeVideoPath;
wchar_t lpParam[512];
Acsii2WideByte(shExe_lpParameters.c_str(), lpParam);
ShExecInfo.lpParameters = lpParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
if( ShExecInfo.hProcess != NULL)
{
TerminateProcess(ShExecInfo.hProcess,0);
CloseHandle(ShExecInfo.hProcess);
ShExecInfo.hProcess = NULL;
}
ShExecInfo.lpFile = NULL;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
char pBuf[512];
_getcwd(pBuf, 512); ////获取当前路径
string ffmpegPath = string(pBuf) +"/"+"ffmpeg";
wchar_t lpFile[512];
Acsii2WideByte(ffmpegPath.c_str(), lpFile);
ShExecInfo.lpFile = lpFile; ///默认为当前目录下
string shExe_lpParameters = "";
if(is_codec)
{
sprintf(pBuf, " -vframes %d -s %dx%d -r %d ", frames, width, height, fps);
shExe_lpParameters = "-y -i " + input_video +" -ss " + start_time + pBuf +"-vcodec flv1 " + out_video;
}
else
{
sprintf(pBuf, " -vframes %d -r %d ", frames, fps);
shExe_lpParameters = "-y -i " + input_video +" -ss " + start_time + pBuf +"-vcodec copy " + out_video;
}
wchar_t lpParam[512];
Acsii2WideByte(shExe_lpParameters.c_str(), lpParam);
ShExecInfo.lpParameters = lpParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
BOOL bResult = ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
if( ShExecInfo.hProcess != NULL)
{
TerminateProcess(ShExecInfo.hProcess,0);
CloseHandle(ShExecInfo.hProcess);
ShExecInfo.hProcess = NULL;
}
ShExecInfo.lpFile = NULL;
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
char pBuf[512];
_getcwd(pBuf, 512);
string memcoderPath = string(pBuf) +"/"+"mencoder.exe";
wchar_t lpFile[512];
Acsii2WideByte(memcoderPath.c_str(), lpFile);
ShExecInfo.lpFile = lpFile; ///默认为当前目录下
string shExe_lpParameters = videoname1 + " " + videoname2 + " -ovc copy -o " + mergeVideoPath;
wchar_t lpParam[512];
Acsii2WideByte(shExe_lpParameters.c_str(), lpParam);
ShExecInfo.lpParameters = lpParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
if( ShExecInfo.hProcess != NULL)
{
TerminateProcess(ShExecInfo.hProcess,0);
CloseHandle(ShExecInfo.hProcess);
ShExecInfo.hProcess = NULL;
}
ShExecInfo.lpFile = NULL;
相关文章推荐
- 使用FFMPEG进行一些视频处理(C#)视频合并、转码、获取时长
- (转载)[FFmpeg]使用ffmpeg从各种视频文件中直接截取视频图片
- windows平台下使用ffmpeg对视频进行H264编码总结
- 利用ffmpeg对视频进行处理,比如截取图片作为缩略图
- 截取视频第一帧——使用ffmpeg
- 通过C++/CLI使用FFMPEG库进行视频解码[初步]
- 使用 ffmpeg 进行网络推流:拉流->解封装->解码->处理原始数据(音频、视频)->编码->编码->推流
- 使用ffmpeg合并视频文件的三种方法
- 通过C++/CLI使用FFMPEG库进行视频解码[初步]
- 使用ffmpeg合并视频文件的三种方法
- 使用ffmpeg进行视频文件转换成FLV整理
- 使用ffmpeg合并视频文件的三种方法
- 在mvc3中使用ffmpeg对上传视频进行截图和转换格式
- FFmpeg的使用——PHP转换视频、截取视频以及JW Player播放器控制
- 使用ffmpeg进行视频截图转码
- 使用ffmpeg从视频中截取图像帧
- FFmpeg的使用——PHP转换视频、截取视频以及JW Player播放器控制
- 使用FFMPEG合并视频
- asp.net使用ffmpeg进行视频转换
- 如何使用 FFmpeg 进行视频转码:字幕