38

I'm trying to play a video using QtMediaPlayer in Raspberry pi 2 B. The source code is as follows:

QMediaPlayer *media;
QVideoWidget *video;
...
...
media = new QMediaPlayer(parent);
video = new QVideoWidget(parent);
media->setVideoOutput(video);
media->setMedia(QUrl::fromLocalFile("/home/pi/Desktop/test3.mp4"));
media->play();

But the result is a blank video screen and the following error:

** (Bus:2148): WARNING **: ffmpegcolorspace-vo: size 1105920 is not a   
multiple of unit size 829440
Error: "GStreamer encountered a general stream error."

System Information

Running latest raspbian Jessie OS, Installed Qt5.3, Installed gstreamer0.10-plugins-good/bad/ugly/ffmpeg and Installed Mpeg-2 License

Here is the video test3.mp4

I ran this code in Windows with Qt5 installed; it is working there. But it's not working in the Raspberry pi. Please tell me what I'm missing here.

Trying Pipe from Shell

enter image description here

TriskalJM
  • 2,393
  • 1
  • 19
  • 20
Myanju
  • 1,135
  • 1
  • 11
  • 23
  • I don't think that there is a answer for this but still hoping for some one to help since I'm new to Linux world. – Myanju Jan 28 '16 at 16:39
  • 2
    well you can play with gstreamer debug logs and find something interesting. run your app like this: `GST_DEBUG=3 ./yourapp` – nayana Feb 01 '16 at 12:32
  • Have the same problem for about 2 weeks on ubuntu, cant solve it :( – Netwave Feb 01 '16 at 15:45
  • 1
    Have you tried my hint? without some more debug info I dont think we can proceed, also please try this pipe from shell: `gst-launch-0.10 videotestsrc ! ffmpegcolorspace ! autovideosink` – nayana Feb 03 '16 at 09:36
  • @otopolsky I tried `GST_DEBUG=3 /myapp` and got huge debug info on terminal. Here is the [link](https://drive.google.com/file/d/0BzI0PXqNuH48bGpVUEJ3VzlRYUU/view?usp=sharing). – Myanju Feb 03 '16 at 16:56
  • I think this would be bug similiar to [this one](http://lists.freedesktop.org/archives/gstreamer-bugs/2008-June/041300.html), although you are using mp4 not avi.. maybe test some simple pipeline with playing mp4 video .. you could also dump the pipeline with GST_DEBUG_DUMP_DIR and GST_DEBUG_NO_COLOR - hopefully they are exporting the pipe in Qt somewhere.. – nayana Feb 05 '16 at 10:14
  • If you're running Jessie I'd think you'd want to be running GStreamer 1.0, not 0.10. It looks like there is a pipeline issue with GStreamer, but I guess with the QMediaPlayer element you have to go with whatever they do under the hood. If you could post your test3.mp4 file we could take a closer look for anything unusual about it. – mpr Feb 05 '16 at 21:48
  • @mpr I posted the video. – Myanju Feb 06 '16 at 09:45
  • @otopolsky Please brief it. – Myanju Feb 06 '16 at 10:29
  • I meant something like this: `GST_DEBUG=2 gst-launch-0.10 filesrc location="/tmp/test3.mp4" ! qtdemux ! queue ! ffdec_h264 ! ffmpegcolorspace ! autovideosink` - does it work for you? for me its working with your video and gstreamer 0.10 on Ubuntu – nayana Feb 06 '16 at 15:55
  • @otopolsky for me also it's playing but lags a lot. [link](https://drive.google.com/file/d/0BzI0PXqNuH48TllGWGJYVDhGYU0/view?usp=sharing) – Myanju Feb 07 '16 at 06:16
  • @otopolsky I can play [this video](https://drive.google.com/file/d/0BzI0PXqNuH48YlZIYUp0MWVuQzg/view?usp=sharing) using above command without any lag – Myanju Feb 07 '16 at 07:46
  • @mpr I didn't find gstreamer1.0 for raspberry pi `pi@raspberrypi:~$ sudo apt-get install gstreamer1.0-ffmpeg Reading package lists... Done Building dependency tree Reading state information... Done Package gstreamer1.0-ffmpeg is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'gstreamer1.0-ffmpeg' has no installation candidate` – Myanju Feb 07 '16 at 07:48
  • any debug logs when lagging? – nayana Feb 08 '16 at 07:43
  • @otopolsky [Debug Log](https://drive.google.com/file/d/0BzI0PXqNuH48TllGWGJYVDhGYU0/view) While lagging. – Myanju Feb 08 '16 at 16:54
  • just out of curiosity, is there any change in video memory? – Mandar Feb 09 '16 at 09:03
  • 1
    looks like this [bug](https://bugzilla.gnome.org/show_bug.cgi?id=707975) which is solvable by simple fix in code of gstreamer - the file has weird creation date (1970-01-01 000).. however I am not sure if it can cause that lagging.. The second video which is working is much smaller resolution and bitrate, also it has proper timestamp - does it work in Qt? – nayana Feb 09 '16 at 12:29
  • @Mozfox What video memory? Please brief it. – Myanju Feb 09 '16 at 16:08
  • 1
    @otopolsky Nope.! it didn't work in Qt. – Myanju Feb 09 '16 at 16:09
  • @Myanju (1) check table [Config HDMI_MODE](https://www.raspberrypi.org/documentation/configuration/config-txt.md) (2) May be you can increase gpu_mem*= values if you are planning for multimedia. (3) Overclock if required **Read PI warning** (4) **_irrelevant_** but use memory card of **class 10** – Mandar Feb 10 '16 at 11:32

1 Answers1

1

Video playback on the Raspberry Pi is actually a bit of a tricky thing. The most common solution is to use OMXPlayer to play videos. It's a command line program, but there are lots of flags and repeated calls can control playback. All in all, it works pretty dang well for most smallish projects.

As far as actually using Qt, QMediaPlayer, and etc. I don't think you'll be able to make it work right out of the box. However, I found a blog that discusses this issue and has some Raspberry Pi firmware that fixes QtMultimedia support on the Raspberry Pi.

ashbygeek
  • 759
  • 3
  • 20