PDA

View Full Version : QProcess & Lame



clive
4th August 2007, 15:38
I am having a problem when running lame as a QProcess.
I have tried using the standard method of placing the commandline params in a QStringList but have moved onto a plain line of text to simplify things for now.


QProcess * lame = new QProcess(this);

connect(lame, SIGNAL(readyReadStandardOutput()), this, SLOT(lameDataAvailable()));
connect(lame, SIGNAL(readyReadStandardError()), this, SLOT(lameErrorAvailable()));
connect(lame, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(lameFinished(int, QProcess::ExitStatus)));

QString tmp = "lame \"-b 112\" \"-m j\" -f \"-V 2\" \"-B 320\" \"" + inFile + "\" \"" + outFile + "\"";

lame->start(tmp);

lame reports this...
lame: -m mode must be s/d/j/f/m not j

if I remove the space between the -m and j thus.. -mj then lame accepts it.

But if I put a --lowpass 18 in the string then lame says it is an unrecognised switch.

But if I use all and any of the lame switches in a terminal they are always accepted okay.

I am running Lame version 3.97 but the problem was the same with an earlier version.

After numerous tests I have come to the conclusion that it is something to do with an environment setting for the QProcess.
I tried setting a TERM=xterm environment setting but it doesn't make any difference.

Does anyone have any idea about what is happening?
Thanks

marcel
4th August 2007, 15:51
I don't think it has something to do with the environment.
It should work though... What happens if you use a QString list instead?
Maybe all the quotes confuse lame...

Regards

clive
4th August 2007, 15:54
I was originally using a QStringList, I reverted to this simplified method to try to find where the problem is.... the problem is just the same using the QStringList method.
The quotes are required when a command line switch has a space in it.

clive
4th August 2007, 20:37
Well it has taken me all day and the solution turns out to be rather simple.

It CANNOT be done with a QStringList because the strings in a QStringList are 16bit per character just as they are in a QString........ Ahhhh... the penny drops.

So the way I have solved it is to create the complete lame command line in a QString....
QString tmp = "lame -b 128 -m j ....... etc etc

Then start the QProcess like this

lame->start(tmp.toUtf8());

and it works fine.