mapmap icon indicating copy to clipboard operation
mapmap copied to clipboard

QtMultimedia prototype

Open sofian opened this issue 8 years ago • 13 comments

The most recent version of QtMultimedia seems to finally be able to do what we need: get access to the raw data. It is becoming a viable alternative to GStreamer (which has many problems).

We need to make a test first. The easiest would probably be to implement a subclass of VideoImpl (see for example VideoV4l2SrcImpl).

sofian avatar Nov 29 '16 15:11 sofian

If using Qt from the APT sources, it should be fine. However:

QTMultimedia from Qt 5.7 installer is broken on Ubuntu 16.10. https://bugreports.qt.io/browse/QTBUG-56640 - since Qt 5.7 relies on GStreamer 0.10, which has been removed.

Qt 5.8 (from installer) relies on GStreamer 1.0. It should be ok. (and provides the new QML Qt Quick Controls 2 - the version 1 is deprecated)

aalex avatar Jan 19 '17 19:01 aalex

Ok.

The weird thing is that I use mapmap on 2 laptops, both with qt5.7, and the other one worked fine. I'm not on ubuntu, I'm on manjaro (based on archlinux). Anyway I upgraded to qt5.8.

skankerror avatar Jan 20 '17 18:01 skankerror

@skankerror Could you open a new issue for this? So that we do not get confused. Thanks.

sofian avatar Jan 20 '17 18:01 sofian

@skankerror MapMap is not yet using QtMultimedia, so it doesn't make any difference which version of Qt you use. We use GStreamer 1.0.

We are discussing a future potential port to QtMultimedia, since it's not quite obvious to use GStreamer on macOS.

@sofian Another alternative would be to simply improve our packaging for macOS. We need to include the GStreamer.framework and the plugins we use in our .app.

aalex avatar Feb 03 '17 19:02 aalex

Yes but we're still having issues with GStreamer (we're not using it the proper way) which results in videos not showing (eg. #321). I also think we might be having issues with memory leaks (remember we had a user who was reporting MapMap crashing after 10-15 minutes). So using QtMultimedia would likely make the whole process much cleaner and safe.

sofian avatar Feb 06 '17 21:02 sofian

Might make #326 obsolete

aalex avatar Feb 20 '17 19:02 aalex

The most simple and straightforward approach seems to be using QVideoProbe: http://doc.qt.io/qt-5/qvideoprobe.html

(Go to section "Detailed example" there is an example of exactly what we are looking for. There is the equivalent for audio: http://doc.qt.io/qt-5/qaudioprobe.html)

This post says that QVideoProbe and QAudioProbe do not work in certain contexts (?) and shows another way to grab frames: https://stackoverflow.com/questions/37724602/how-to-save-a-frame-using-qmediaplayer

sofian avatar Nov 11 '17 04:11 sofian

I have done some tests with QtMultimedia on Ubuntu 16.04. Tried to run simple examples such as this one: https://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-camera-example.html

I was not able to do so. None of the examples I tried worked. I might be missing some plugins. But let's say that as a first test I am not very much impressed. Maybe the framework is not ready yet...

sofian avatar Nov 11 '17 19:11 sofian

Gave another chance to QtMultimedia (on Ubuntu 17.10). This time I tried implementing frame grabbing on QMediaPlayer (you can view my work in the feature/qtmultimedia branch).

Implementation was easy. However, there's a nasty glitch when trying to "loop" the video: a black frame appears for a fraction of second (one frame presumably) towards the end. I tried many different ways to fix it and did not succeed.

I am starting to think that this might be a dead-end and that perhaps we should rather focus on refactoring / testing our GStreamer code.

sofian avatar Dec 28 '17 03:12 sofian

Hey Sofian did you already try to let QMediaplaylist handle the looping as I do in this commit 43d0b4468a98b6cb4d20b1adc3e64deb9a09cd26. It's work but still have a little lags. We can keep trying to make it work rather than continue to use Gstreamer

baydam avatar Jan 19 '18 01:01 baydam

Yes I did try the media playlist with the "loop" option. If you can find a way to avoid the "lag" then it changes everything of course. But I would not know where to start. If we cannot find the solution we should ask some QtMultimedia experts online on a forum or IRC.

sofian avatar Jan 19 '18 02:01 sofian

Not an option right now, because there is a black frame each time the video loops.

It uses the codec installed on the system. If there is no codec installed, it doesn't work.

It also lags.

aalex avatar Apr 01 '20 18:04 aalex

Qt 6 offers a big refactor of Qt Multimedia: https://www.qt.io/blog/qt-multimedia-in-qt-6

aalex avatar Sep 10 '21 15:09 aalex