Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FFMPEG +VC++ Console Programming

FFMPEG +VC++ Console Programming

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
9 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahulOP
    wrote on last edited by
    #1

    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?

    N J V 4 Replies Last reply
    0
    • R RahulOP

      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?

      N Offline
      N Offline
      NiceNaidu fo
      wrote on last edited by
      #2

      Try using ShellExecuteEx Appu.. "If you judge people, you have no time to love them."

      R 1 Reply Last reply
      0
      • R RahulOP

        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?

        J Offline
        J Offline
        Justin Tay
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • R RahulOP

          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?

          N Offline
          N Offline
          NiceNaidu fo
          wrote on last edited by
          #4

          RahulOP wrote:

          ="C://msys//home//ffmpeg4//ffmpeg.exe"

          Try replacing "//" with "\\" Appu.. "If you judge people, you have no time to love them."

          R 1 Reply Last reply
          0
          • R RahulOP

            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?

            V Offline
            V Offline
            Viorel
            wrote on last edited by
            #5

            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);
            
            R 1 Reply Last reply
            0
            • N NiceNaidu fo

              Try using ShellExecuteEx Appu.. "If you judge people, you have no time to love them."

              R Offline
              R Offline
              RahulOP
              wrote on last edited by
              #6

              I am trying shellexecute as well ShellExecute(NULL,_T("Open"),_T("C://msys//home//ffmpeg4//ffmpeg.exe"),_T(" -i Rahul.avi -s qcif fort.mpeg"),NULL,SW_SHOWMAXIMIZED); DOesnt seem to work though:(

              1 Reply Last reply
              0
              • J Justin Tay

                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.

                R Offline
                R Offline
                RahulOP
                wrote on last edited by
                #7

                Well I intend to extend my dialog to give the user options and all that jazz. SOrry for the confusion.

                1 Reply Last reply
                0
                • V Viorel

                  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);
                  
                  R Offline
                  R Offline
                  RahulOP
                  wrote on last edited by
                  #8

                  Nope doesnt work. it works fine when I give the option as " -L" which is to show the GNU license. So this has me a li'l confused. Thanks for the tip though.

                  1 Reply Last reply
                  0
                  • N NiceNaidu fo

                    RahulOP wrote:

                    ="C://msys//home//ffmpeg4//ffmpeg.exe"

                    Try replacing "//" with "\\" Appu.. "If you judge people, you have no time to love them."

                    R Offline
                    R Offline
                    RahulOP
                    wrote on last edited by
                    #9

                    That line is fine because when I give the option to display license it works.Thanks anyway

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups