Unsolved 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 codeThe 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 internalQDir::mkpath()
to create a directory, no point running amkdir
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 toQProcess
.Note that
QProcess::exexcute()
isstatic
, so if you use that it it is misleading to declare aQProcess process;
.