How to pass a character to Qprocess.
-
Hello all,
I am using a commandline tool (ffmpeg) to convert media formats. This is working perfect. Now i want to pass a 'q' to command line tool to stop its working on cancel click.
(command line tool says press 'q' to stop)
i can stop this if i run this tool in cmd in windows by pressing 'q' Key from the keyboard. I want the same working in Qt when i press cancel button. i already have a slot of cancel click button.
This is my code.
class.h@
QProcess proc ;
bool stop();
@class.cpp
@ QString codecTool;
codecTool = "ffmpeg/ffmpeg";
#ifdef Q_OS_WIN
codecTool="ffmpeg/win64/ffmpeg";
#endif
#ifdef Q_OS_WIN32
codecTool="ffmpeg/win32/ffmpeg";
#endif
QStringList arguments;
//Overwrite file
arguments.append("-y");
//get Info
arguments.append("-i");
arguments.append(sourcefilePath);
//Set Codec
arguments.append("-acodec");
arguments.append(setCodec);
//Set Bitrate
arguments.append("-ab");
arguments.append(setBitrate+"k");
//Set Samplerate
arguments.append("-ar");
arguments.append(setSamplerate);
arguments.append(targetfilePath+"."+extension);
proc.setProcessChannelMode(QProcess::MergedChannels);
int check=proc.execute(codecTool, arguments);@@bool ffmpeghandler::stop()
{
qDebug()<<"qprocess"<<proc.pid();
proc.write("q");
proc.write("\n\r");
}
@when i click on button it print process id but unable to stop.
Any one have any idea.
Thanks in advance.