Reputation: 583
I'm writing an application which need to capture screen. I've looked up for solution and internet says that FFMPEG
could do it. But I can't find the way to do that IN CODE. FFMPEG
documentation seems to be very poor.
Can anybody please tell me how do I access framebuffer raw data with FFMPEG
?
Upvotes: 0
Views: 2672
Reputation: 752
FFmpeg supports input of rawframes throught stdin:
With the arg -f rawvideo
ffmpeg will expect frames coming from stdin
ffmpeg -r 60 -f rawvideo -pix_fmt uyvy422 -s 1280x720 -i - -threads 0 -preset fast -y -pix_fmt yuv420p output.mp4
You can check this link, it has useful information.
In Qt, you would run a QProcess with ffmpeg with -f rawvideo
and write to stdin with write() method.
This is roughly how to acomplish it:
QProcess* process;
process->start("ffmpeg.exe", args, QProcess::Unbuffered | QProcess::ReadWrite);
process->waitForStarted();
...
process->setProcessChannelMode(QProcess::ForwardedChannels);
videoFrame->GetBytes(&buffer);
process->write(buffer);
Upvotes: 1