Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting ffmpeg output with QProccess
QtWS25 Last Chance

Getting ffmpeg output with QProccess

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 2 Posters 1.3k Views
  • 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
    rktech
    wrote on last edited by rktech
    #1

    I have this code in QT:

    #include <QCoreApplication>
    #include <QProcess>
    #include <QDebug>
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QProcess p;
        QString ba;
        QString exec = "ffmpeg.exe";
        QStringList params;
        params << " -i S01E01.mp4 2>&1";
        p.start(exec, params);
        p.waitForFinished(); // sets current thread to sleep and waits for p end
        QString output(p.readAllStandardOutput());
        qDebug()<<output;
        return a.exec();
    }
    

    When I ran the command directly I get this:
    ffmpeg.exe -i S01E01.mp4 2>&1
    ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers
    built with gcc 9.3.1 (GCC) 20200328
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
    libavutil 56. 42.102 / 56. 42.102
    libavcodec 58. 81.100 / 58. 81.100
    libavformat 58. 42.101 / 58. 42.101
    libavdevice 58. 9.103 / 58. 9.103
    libavfilter 7. 79.100 / 7. 79.100
    libswscale 5. 6.101 / 5. 6.101
    libswresample 3. 6.100 / 3. 6.100
    libpostproc 55. 6.100 / 55. 6.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S01E01.mp4':
    Metadata:
    major_brand : mp42
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    creation_time : 2017-01-01T15:13:24.000000Z
    title : The Simpsons S01E01 Simpsons Roasting on an Open Fire
    encoder : HandBrake 0.10.5 2016021100
    Duration: 00:23:12.98, start: 0.000000, bitrate: 247 kb/s
    Chapter #0:0: start 0.000000, end 18.282000
    Metadata:
    title : Chapter 1
    Chapter #0:1: start 18.282000, end 334.488000
    Metadata:
    title : Chapter 2
    Chapter #0:2: start 334.488000, end 584.364000
    Metadata:
    title : Chapter 3
    Chapter #0:3: start 584.364000, end 831.534000
    Metadata:
    title : Chapter 4
    Chapter #0:4: start 831.534000, end 1314.951000
    Metadata:
    title : Chapter 5
    Chapter #0:5: start 1314.951000, end 1392.930000
    Metadata:
    title : Chapter 6
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 480x360, 191 kb/s, 30.30 fps, 30.30 tbr, 90k tbn, 60.61 tbc (default)
    Metadata:
    creation_time : 2017-01-01T15:13:24.000000Z
    handler_name : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 49 kb/s (default)
    Metadata:
    creation_time : 2017-01-01T15:13:24.000000Z
    handler_name : Mono
    Stream #0:2(eng): Data: bin_data (text / 0x74786574)
    Metadata:
    creation_time : 2017-01-01T15:13:24.000000Z
    handler_name : SubtitleHandler
    At least one output file must be specified

    But when I run it using the code mentioned before, I get "". What I am doing wrong?

    1 Reply Last reply
    0
    • R rktech

      Done like this:

      params << "-i S01E01.mp4 2>&1";
      

      Getting this error:
      "ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\nUnrecognized option 'i S01E01.mp4 2>&1'.\r\nError splitting the argument list: Option not found\r\n"

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #15

      params << "-i" << "S01E01.mp4"

      In any case, "2>&1" is command prompt specific, so it does not make sense to put it there and might even interfere.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Remove the channel handling at the end of the command.
        Also the proper way to pass parameters is to build a QStringList with each element separately.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rktech
          wrote on last edited by rktech
          #3

          @SGaist

          params << " -i"<<" S01E01.mp4";
          

          Still nothing

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Is that video file located in the same folder as the executable ?
            You should also check whether the command failed and its standard erreur channel.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            0
            • SGaistS SGaist

              Is that video file located in the same folder as the executable ?
              You should also check whether the command failed and its standard erreur channel.

              R Offline
              R Offline
              rktech
              wrote on last edited by
              #5

              @SGaist

              Is that video file located in the same folder as the executable ?
              

              Yes, it is like this
              bea25094-c0a0-43dc-9ce1-b5c9bb04b6e2-image.png

              You should also check whether the command failed and its standard erreur channel.
              
              

              How?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                QProcess::readStandardError
                QProcess:exitCode
                QProcess::exitStatus

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                R 1 Reply Last reply
                1
                • SGaistS SGaist

                  QProcess::readStandardError
                  QProcess:exitCode
                  QProcess::exitStatus

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

                  @SGaist How to correctly use readStandartError? Print in qDebug?

                  R SGaistS 2 Replies Last reply
                  0
                  • R rktech

                    @SGaist How to correctly use readStandartError? Print in qDebug?

                    R Offline
                    R Offline
                    rktech
                    wrote on last edited by
                    #8

                    @rktech exitStatus: QProcess::NormalExit, exitCode: 1

                    R 1 Reply Last reply
                    0
                    • R rktech

                      @SGaist How to correctly use readStandartError? Print in qDebug?

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @rktech said in Getting ffmpeg output with QProccess:

                      @SGaist How to correctly use readStandartError? Print in qDebug?

                      That's one way yes.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • R rktech

                        @rktech exitStatus: QProcess::NormalExit, exitCode: 1

                        R Offline
                        R Offline
                        rktech
                        wrote on last edited by
                        #10

                        @rktech readStandartError
                        ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\n[NULL @ 0000024fd452b800] Unable to find a suitable output format for ' -i'\r\n -i: Invalid argument\r\n

                        I would drop error, but same as in my first post.

                        R 1 Reply Last reply
                        0
                        • R rktech

                          @rktech readStandartError
                          ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\n[NULL @ 0000024fd452b800] Unable to find a suitable output format for ' -i'\r\n -i: Invalid argument\r\n

                          I would drop error, but same as in my first post.

                          R Offline
                          R Offline
                          rktech
                          wrote on last edited by
                          #11

                          @rktech That was caused by splitting parametrs into list, but the problem with wrong error continues:
                          "ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\nOutput #0, mp4, to ' -i S01E01.mp4':\r\nOutput file #0 does not contain any stream\r\n"

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            Try removing the spaces in the parameter list.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              rktech
                              wrote on last edited by
                              #13

                              Done like this:

                              params << "-i S01E01.mp4 2>&1";
                              

                              Getting this error:
                              "ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\nUnrecognized option 'i S01E01.mp4 2>&1'.\r\nError splitting the argument list: Option not found\r\n"

                              SGaistS 1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                rktech
                                wrote on last edited by
                                #14

                                The

                                2>&1
                                

                                Is not the problem, it drops same error without it.

                                1 Reply Last reply
                                0
                                • R rktech

                                  Done like this:

                                  params << "-i S01E01.mp4 2>&1";
                                  

                                  Getting this error:
                                  "ffmpeg version git-2020-04-24-a501947 Copyright (c) 2000-2020 the FFmpeg developers\r\n built with gcc 9.3.1 (GCC) 20200328\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 42.102 / 56. 42.102\r\n libavcodec 58. 81.100 / 58. 81.100\r\n libavformat 58. 42.101 / 58. 42.101\r\n libavdevice 58. 9.103 / 58. 9.103\r\n libavfilter 7. 79.100 / 7. 79.100\r\n libswscale 5. 6.101 / 5. 6.101\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\nUnrecognized option 'i S01E01.mp4 2>&1'.\r\nError splitting the argument list: Option not found\r\n"

                                  SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #15

                                  params << "-i" << "S01E01.mp4"

                                  In any case, "2>&1" is command prompt specific, so it does not make sense to put it there and might even interfere.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  R 1 Reply Last reply
                                  1
                                  • SGaistS SGaist

                                    params << "-i" << "S01E01.mp4"

                                    In any case, "2>&1" is command prompt specific, so it does not make sense to put it there and might even interfere.

                                    R Offline
                                    R Offline
                                    rktech
                                    wrote on last edited by
                                    #16

                                    @SGaist Thanks, now it works

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved