Creating a video file in Qt
-
@mrjj Thanks for your response. Based on your suggestion I tried this:
void Video::slot_generateVideo() { QStringList arguments; QString imgPath("home/uidm9805/images/pic%04d.png"); int fps = 2; QString frameRate; QString compressionLevel("image2"); QString resolution("1920x1080"); QString startFrame("1"); QString videoFrames("1000"); QString codec("libx264"); QString quality("25"); QString pixelFormat("yuv420p"); QString outputFile("\"home/uidm9805/images/test.mp4\""); arguments << "-r"; arguments << frameRate.setNum(fps); arguments << "-f"; arguments << compressionLevel; arguments << "-s"; arguments << resolution; arguments << "-start_number"; arguments << startFrame; arguments << "-i"; arguments << imgPath; arguments << "-vframes"; arguments << videoFrames; arguments << "-vcodec"; arguments << codec; arguments << "-crf"; arguments << quality; arguments << "-pix_fmt"; arguments << pixelFormat; arguments << outputFile; qDebug() << arguments; videoProcess = new QProcess(this); connect(videoProcess, SIGNAL(started()), this, SLOT(monitorStarted())); connect(videoProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(monitorError(QProcess::ProcessError))); connect(videoProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput())); videoProcess->start("ffmpeg", arguments); videoProcess->waitForFinished(-1); } void Video::monitorStarted() { qDebug() << "Video Process started"; } void Video::monitorError(QProcess::ProcessError error) { qDebug() << "Video Process error: " << error; } void Video::readOutput() { qDebug() << videoProcess->readAllStandardOutput(); }
I am working on ubuntu.
when I run the same set of commands from terminal everything is working fine, test.mp4 is generated.
But using QProcess, I got this output:
Video Process error: 0
I don't understand what might be the problem, any help will be appreciable.
Thank you -
@NIXIN "QString imgPath("home/uidm9805/images/pic%04d.png");" you're missing / in front of home. Also why do you have % in file name?
Same here QString outputFile("\"home/uidm9805/images/test.mp4\""); and remove \" as Qt will do it for you. -
Hi
Code seems fine.
try with full path to ffmpeg
also
folderName ="images/pic"Depending on how it uses this, it might not be correct.
-
If something just appends that to other path or use it relative,
it might not work as expected.
Like
somewhere = "/home"
open (somewhere + folderName )
"/homeimages/pic"
and so one.
but if it adds / when doing + , all is fine.since there is no error reported with QProcess i assume it runs the app but app do not produce output for some reason.
-
Hi,
You are missing the leading / in your path to ffmpeg.
-
@NIXIN said in Creating a video file in Qt:
usr/bin/ffmpeg
Please take a closer look at the path. You're doing same mistake over and over even after it was pointed out.