Reading in video files?
-
Is it possible to open and read video files, in order to obtain the frames and audio from them? I don't want to actually play the video or audio content, just parse and decode it.
In the old days on Windows we could use Video For Windows which let us do this with AVI files. Anything similar would help, although I'm on Linux now. I want to avoid using ffmpeg's libraries which appear disorganized.
-
@whatabout It's absolutely possible with Qt, but it's a massive pain in the neck. Check out QVideoProbe https://doc.qt.io/qt-5/qvideoprobe.html But yeah, that will get you pixels, but it's still assuming you want to "play" a video.
Personally, I use a library called ffms2. It's a wrapper around FFMPEG that provides a simple API for getting pixels and audio for a frame from a video file. It's not optimal in terms of performance because it bypasses hardware video decoding and has an indexing step when you first open a file, but if you just want pixels in memory to do your own image processing it's still the simplest API I have used. Getting a frame once the video is open and ready is just
const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &errinfo);
No weird async callbacks to set up and GPU memory blocks to try and map and whatnot.
-
Hi,
Did you already check the Qt Multimedia module ?
-
Hi,
Did you already check the Qt Multimedia module ?
-
The module has seen a rewrite in Qt 6 and should allow you to get both audio and video frame for processing before rendering them.
If that is not enough, you might want to explain more precisely what you want to do.
-
@whatabout It's absolutely possible with Qt, but it's a massive pain in the neck. Check out QVideoProbe https://doc.qt.io/qt-5/qvideoprobe.html But yeah, that will get you pixels, but it's still assuming you want to "play" a video.
Personally, I use a library called ffms2. It's a wrapper around FFMPEG that provides a simple API for getting pixels and audio for a frame from a video file. It's not optimal in terms of performance because it bypasses hardware video decoding and has an indexing step when you first open a file, but if you just want pixels in memory to do your own image processing it's still the simplest API I have used. Getting a frame once the video is open and ready is just
const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &errinfo);
No weird async callbacks to set up and GPU memory blocks to try and map and whatnot.
-
-
@whatabout It's absolutely possible with Qt, but it's a massive pain in the neck. Check out QVideoProbe https://doc.qt.io/qt-5/qvideoprobe.html But yeah, that will get you pixels, but it's still assuming you want to "play" a video.
Personally, I use a library called ffms2. It's a wrapper around FFMPEG that provides a simple API for getting pixels and audio for a frame from a video file. It's not optimal in terms of performance because it bypasses hardware video decoding and has an indexing step when you first open a file, but if you just want pixels in memory to do your own image processing it's still the simplest API I have used. Getting a frame once the video is open and ready is just
const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &errinfo);
No weird async callbacks to set up and GPU memory blocks to try and map and whatnot.
@wrosecrans
Have you tried compiling ffms2 lately?
I'm finding the autogen.sh is giving errors.
There's no configure script. -
@wrosecrans
Have you tried compiling ffms2 lately?
I'm finding the autogen.sh is giving errors.
There's no configure script.@whatabout I just use a CMake build system in my own project. I haven't bothered keeping it particularly up to date or anything, but feel free to grab my CMake as a starting point if it's useful: https://github.com/wrosecrans/ffms2/blob/master/CMakeLists.txt May need some tweaks to keep up with upstream. I link it to an ffmpeg from vcpkg.