Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to run windows cmd command



  • void MainWindow::on_pushButton_videoFormatConverter_clicked()
    {
        QStringList inputPaths = QFileDialog::getOpenFileNames();
    
        
        int outputIndex = inputPaths[0].lastIndexOf('/');
        QString outputPath = inputPaths[0].left(outputIndex + 1);
        outputPath.replace(QChar('\\'),QChar('/'));
    
    
        QString makeFolder = "mkdir \"" + outputPath + "outputs\"";
        QString ffmpegCode = //ffmpeg code get input parameters from QStringList inputPaths and output to the outputs folder
    
    
        qDebug().noquote() << makeFolder;
        qDebug().noquote() << ffmpegCode;
    
    
        QProcess process;
        process.execute(makeFolder);
        process.execute(ffmpegCode);
       
    
    }
    

    I would like to run the following ffmpeg code:

    mkdir outputs
    //ffmpeg code
    

    The input parameters are correct (makeFolder, ffmpegCode).

    The code is basically convert video format to .mkv format.



  • @ekato993 said in How to run windows cmd command:

    I would like to run the following ffmpeg code:
    mkdir outputs
    //ffmpeg code

    The input parameters are correct (makeFolder, ffmpegCode).
    The code is basically convert video format to .mkv format.

    Why do you not use QDir::mkpath() to create directory?
    So you can verify is directory creation was successfull.



  • @ekato993
    Use internal QDir::mkpath() to create a directory, no point running a mkdir command, as @KroMignon said.

    For the ffmpeg you need to use whatever the command-line is to run that, with appropriate parameters, and across multiple files, if it accepts that. We don't know what that command line needs to look like. Practice it from a Command Prompt till you get it right, then you're ready to pass it to QProcess.

    Note that QProcess::exexcute() is static, so if you use that it it is misleading to declare a QProcess process;.


Log in to reply