FFMPEG +VC++ Console Programming
-
After weeks of trying to program using the dlls and/or libs, i finally considered building my own gui i.e. Console Programming in vc++ Now all i get is
CString csExecute; csExecute="C://msys//home//ffmpeg4//ffmpeg.exe";//+ "ffmpeg -i Rahul.avi -s qcif fort.mpeg"; csExecute+= " "; csExecute+="-i Rahul.avi -s qcif -o fort1.mpeg"; SECURITY_ATTRIBUTES secattr; ZeroMemory(&secattr,sizeof(secattr)); secattr.nLength = sizeof(secattr); secattr.bInheritHandle = TRUE; HANDLE rPipe, wPipe; //Create pipes to write and read data CreatePipe(&rPipe,&wPipe,&secattr,0); // STARTUPINFO sInfo; ZeroMemory(&sInfo,sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); sInfo.cb=sizeof(sInfo); sInfo.dwFlags=STARTF_USESTDHANDLES; sInfo.hStdInput=NULL; sInfo.hStdOutput=wPipe; sInfo.hStdError=wPipe; char command[1024]; strcpy(command,csExecute.GetBuffer(csExecute.GetLength())); //Create the process here. CreateProcess(0, command,0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo); CloseHandle(wPipe); //now read the output pipe here. char buf[100]; DWORD reDword; CString m_csOutput,csTemp; BOOL res; do { res=::ReadFile(rPipe,buf,100,&reDword,0); csTemp=buf; m_csOutput+=csTemp.Left(reDword); }while(res); AfxMessageBox(m_csOutput);
which does a nifty little trick of displaying output from the console Now all i get is"Rahul.avi I/O Error Usually that means that input file is truncated and/or corrupted "
which is strange since if i try the same from the command line it encodes fine. So what am I doing wrong? -
After weeks of trying to program using the dlls and/or libs, i finally considered building my own gui i.e. Console Programming in vc++ Now all i get is
CString csExecute; csExecute="C://msys//home//ffmpeg4//ffmpeg.exe";//+ "ffmpeg -i Rahul.avi -s qcif fort.mpeg"; csExecute+= " "; csExecute+="-i Rahul.avi -s qcif -o fort1.mpeg"; SECURITY_ATTRIBUTES secattr; ZeroMemory(&secattr,sizeof(secattr)); secattr.nLength = sizeof(secattr); secattr.bInheritHandle = TRUE; HANDLE rPipe, wPipe; //Create pipes to write and read data CreatePipe(&rPipe,&wPipe,&secattr,0); // STARTUPINFO sInfo; ZeroMemory(&sInfo,sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); sInfo.cb=sizeof(sInfo); sInfo.dwFlags=STARTF_USESTDHANDLES; sInfo.hStdInput=NULL; sInfo.hStdOutput=wPipe; sInfo.hStdError=wPipe; char command[1024]; strcpy(command,csExecute.GetBuffer(csExecute.GetLength())); //Create the process here. CreateProcess(0, command,0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo); CloseHandle(wPipe); //now read the output pipe here. char buf[100]; DWORD reDword; CString m_csOutput,csTemp; BOOL res; do { res=::ReadFile(rPipe,buf,100,&reDword,0); csTemp=buf; m_csOutput+=csTemp.Left(reDword); }while(res); AfxMessageBox(m_csOutput);
which does a nifty little trick of displaying output from the console Now all i get is"Rahul.avi I/O Error Usually that means that input file is truncated and/or corrupted "
which is strange since if i try the same from the command line it encodes fine. So what am I doing wrong?Try using
ShellExecuteEx
Appu.. "If you judge people, you have no time to love them." -
After weeks of trying to program using the dlls and/or libs, i finally considered building my own gui i.e. Console Programming in vc++ Now all i get is
CString csExecute; csExecute="C://msys//home//ffmpeg4//ffmpeg.exe";//+ "ffmpeg -i Rahul.avi -s qcif fort.mpeg"; csExecute+= " "; csExecute+="-i Rahul.avi -s qcif -o fort1.mpeg"; SECURITY_ATTRIBUTES secattr; ZeroMemory(&secattr,sizeof(secattr)); secattr.nLength = sizeof(secattr); secattr.bInheritHandle = TRUE; HANDLE rPipe, wPipe; //Create pipes to write and read data CreatePipe(&rPipe,&wPipe,&secattr,0); // STARTUPINFO sInfo; ZeroMemory(&sInfo,sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); sInfo.cb=sizeof(sInfo); sInfo.dwFlags=STARTF_USESTDHANDLES; sInfo.hStdInput=NULL; sInfo.hStdOutput=wPipe; sInfo.hStdError=wPipe; char command[1024]; strcpy(command,csExecute.GetBuffer(csExecute.GetLength())); //Create the process here. CreateProcess(0, command,0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo); CloseHandle(wPipe); //now read the output pipe here. char buf[100]; DWORD reDword; CString m_csOutput,csTemp; BOOL res; do { res=::ReadFile(rPipe,buf,100,&reDword,0); csTemp=buf; m_csOutput+=csTemp.Left(reDword); }while(res); AfxMessageBox(m_csOutput);
which does a nifty little trick of displaying output from the console Now all i get is"Rahul.avi I/O Error Usually that means that input file is truncated and/or corrupted "
which is strange since if i try the same from the command line it encodes fine. So what am I doing wrong?Try specifying the full path to your avi. Also GUI means Graphical User Interface, and calling a console application as a GUI is a bit of a stretch.
-
After weeks of trying to program using the dlls and/or libs, i finally considered building my own gui i.e. Console Programming in vc++ Now all i get is
CString csExecute; csExecute="C://msys//home//ffmpeg4//ffmpeg.exe";//+ "ffmpeg -i Rahul.avi -s qcif fort.mpeg"; csExecute+= " "; csExecute+="-i Rahul.avi -s qcif -o fort1.mpeg"; SECURITY_ATTRIBUTES secattr; ZeroMemory(&secattr,sizeof(secattr)); secattr.nLength = sizeof(secattr); secattr.bInheritHandle = TRUE; HANDLE rPipe, wPipe; //Create pipes to write and read data CreatePipe(&rPipe,&wPipe,&secattr,0); // STARTUPINFO sInfo; ZeroMemory(&sInfo,sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); sInfo.cb=sizeof(sInfo); sInfo.dwFlags=STARTF_USESTDHANDLES; sInfo.hStdInput=NULL; sInfo.hStdOutput=wPipe; sInfo.hStdError=wPipe; char command[1024]; strcpy(command,csExecute.GetBuffer(csExecute.GetLength())); //Create the process here. CreateProcess(0, command,0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo); CloseHandle(wPipe); //now read the output pipe here. char buf[100]; DWORD reDword; CString m_csOutput,csTemp; BOOL res; do { res=::ReadFile(rPipe,buf,100,&reDword,0); csTemp=buf; m_csOutput+=csTemp.Left(reDword); }while(res); AfxMessageBox(m_csOutput);
which does a nifty little trick of displaying output from the console Now all i get is"Rahul.avi I/O Error Usually that means that input file is truncated and/or corrupted "
which is strange since if i try the same from the command line it encodes fine. So what am I doing wrong?RahulOP wrote:
="C://msys//home//ffmpeg4//ffmpeg.exe"
Try replacing "//" with "\\" Appu.. "If you judge people, you have no time to love them."
-
After weeks of trying to program using the dlls and/or libs, i finally considered building my own gui i.e. Console Programming in vc++ Now all i get is
CString csExecute; csExecute="C://msys//home//ffmpeg4//ffmpeg.exe";//+ "ffmpeg -i Rahul.avi -s qcif fort.mpeg"; csExecute+= " "; csExecute+="-i Rahul.avi -s qcif -o fort1.mpeg"; SECURITY_ATTRIBUTES secattr; ZeroMemory(&secattr,sizeof(secattr)); secattr.nLength = sizeof(secattr); secattr.bInheritHandle = TRUE; HANDLE rPipe, wPipe; //Create pipes to write and read data CreatePipe(&rPipe,&wPipe,&secattr,0); // STARTUPINFO sInfo; ZeroMemory(&sInfo,sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); sInfo.cb=sizeof(sInfo); sInfo.dwFlags=STARTF_USESTDHANDLES; sInfo.hStdInput=NULL; sInfo.hStdOutput=wPipe; sInfo.hStdError=wPipe; char command[1024]; strcpy(command,csExecute.GetBuffer(csExecute.GetLength())); //Create the process here. CreateProcess(0, command,0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo); CloseHandle(wPipe); //now read the output pipe here. char buf[100]; DWORD reDword; CString m_csOutput,csTemp; BOOL res; do { res=::ReadFile(rPipe,buf,100,&reDword,0); csTemp=buf; m_csOutput+=csTemp.Left(reDword); }while(res); AfxMessageBox(m_csOutput);
which does a nifty little trick of displaying output from the console Now all i get is"Rahul.avi I/O Error Usually that means that input file is truncated and/or corrupted "
which is strange since if i try the same from the command line it encodes fine. So what am I doing wrong?Maybe you are closing the write handle for pipe too early, while the ffmpeg.exe process is still running? Perhaps you have to wait for process termination before closing the handle, like this:
::WaitForSingleObject(pInfo.hProcess, INFINITE); ::CloseHandle(wPipe);
-
Try using
ShellExecuteEx
Appu.. "If you judge people, you have no time to love them." -
Try specifying the full path to your avi. Also GUI means Graphical User Interface, and calling a console application as a GUI is a bit of a stretch.
-
Maybe you are closing the write handle for pipe too early, while the ffmpeg.exe process is still running? Perhaps you have to wait for process termination before closing the handle, like this:
::WaitForSingleObject(pInfo.hProcess, INFINITE); ::CloseHandle(wPipe);
-
RahulOP wrote:
="C://msys//home//ffmpeg4//ffmpeg.exe"
Try replacing "//" with "\\" Appu.. "If you judge people, you have no time to love them."