Playing H.264 video in QT 5.4.1
-
Hi,
I've downloaded and installed qt-opensource-linux-x86-5.4.1.run on my
Ubuntu 14.04.2
.I've also installed required plugins for gstreamer as mentioned in https://forum.qt.io/topic/43468:
sudo add-apt-repository ppa:mc3man/trusty-media sudo apt-get update sudo apt-get install gstreamer0.10-ffmpeg sudo apt-get install gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly
Here is the list of installed gst packages (output of
dkpg -l | grep gst
): http://pastebin.com/dPinHFwMWhile I can play H.264 video files with the following command (here is the terminal output):
GST_DEBUG=2 gst-launch-0.10 playbin2 uri=file:///home/isaac/Desktop/sample_videos/480p.mp4
They still cannot be played in QT. I tried the example player program included in QT (at
Qt5.4.1/Examples/Qt-5.4/multimediawidgets/player
). Here is the terminal output when running the player withGST_DEBUG=2
and trying to play a video:0:00:00.161270387 23503 0x8cc6830 WARN qtdemux qtdemux_types.c:191:qtdemux_type_get: unknown QuickTime node type avc1 0:00:00.161343895 23503 0x8cc6830 WARN qtdemux qtdemux_types.c:191:qtdemux_type_get: unknown QuickTime node type avcC 0:00:00.161374106 23503 0x8cc6830 WARN qtdemux qtdemux.c:8854:qtdemux_parse_tree:<qtdemux0> Can't handle datetimes before 1970 yet, please file a bug at http://bugzilla.gnome.org 0:00:00.161527135 23503 0x8cc6830 WARN qtdemux qtdemux.c:7044:qtdemux_parse_trak:<qtdemux0> unknown version 00000000 0:00:00.224020092 23503 0x8d62800 WARN playsinkconvertbin gstplaysinkconvertbin.c:481:gst_play_sink_convert_bin_cache_converter_caps:<GstPlaySinkAudioConvert@0xb124c098> No conversion elements 0:00:00.348821198 23503 0x8d62800 WARN ffmpeg gstffmpegdec.c:2299:gst_ffmpegdec_frame:<ffdec_h2640> ffdec_h264: decoding error (len: -1, have_data: 0) 0:00:00.348940690 23503 0x8cc6830 WARN qtdemux qtdemux.c:3891:gst_qtdemux_loop:<qtdemux0> error: streaming stopped, reason not-negotiated Error: "GStreamer encountered a general stream error."
I guess the clue to the problem is this line:
0:00:00.348821198 23503 0x8d62800 WARN ffmpeg gstffmpegdec.c:2299:gst_ffmpegdec_frame:<ffdec_h2640> ffdec_h264: decoding error (len: -1, have_data: 0)
The following code also fails to play the videos with the same errors as above:
QVideoWidget* videoWidget = new QVideoWidget(); videoWidget->show(); player->setVideoOutput(videoWidget); player->setMedia(QUrl::fromLocalFile("/home/isaac/Desktop/sample_videos/480p.mp4")); player->play();
-
@nickaein said:
sudo apt-get update
Hmm, works for me. Have you tried
sudo apt-get upgrade
? And have you tried to turn it off and on again? -
@Wieland said:
Hi Wieland,
@nickaein said:
sudo apt-get update
Hmm, works for me. Have you tried
sudo apt-get upgrade
?The problem is still present after
sudo apt-get upgrade
.And have you tried to turn it off and on again?
First I thought it as an IT Crowd reference, but that didn't help either.
I've noticed the example program cannot even play a
MPEG-1
video! and fails with a somewhat similar error:0:00:00.193070940 2931 0x9a14e60 WARN mpeg2dec gstmpeg2dec.c:453:gst_mpeg2dec_alloc_buffer:<mpeg2dec0> error: Failed to allocate memory for buffer, reason not-negotiated 0:00:00.194245527 2931 0x9a14e60 WARN baseparse gstbaseparse.c:2890:gst_base_parse_loop:<mpegvparse0> error: streaming stopped, reason not-negotiated Error: "GStreamer encountered a general resource error."
Maybe I am missing a plugin?
The videos I am using are uploaded here: https://mega.co.nz/#F!mMpniB7C!fD8swng6Qfn4RUh2xXdIZA
-
dpkg -l | grep gst
says:ii gir1.2-gst-plugins-base-1.0 1.4.3-1ubuntu1 amd64 Description: GObject introspection data for the GStreamer Plugins Base library
ii gir1.2-gstreamer-1.0 1.4.3-1 amd64 Description: GObject introspection data for the GStreamer library
ii gstreamer0.10-alsa:amd64 0.10.36-2 amd64 GStreamer plugin for ALSA
ii gstreamer0.10-ffmpeg:amd64 0.10.13-5ubuntu1~utopic2 amd64 FFmpeg plugin for GStreamer
ii gstreamer0.10-fluendo-mp3:amd64 0.10.29.debian-1ubuntu1 amd64 Fluendo mp3 decoder GStreamer 0.10 plugin
ii gstreamer0.10-nice:amd64 0.1.7-1 amd64 ICE library (GStreamer 0.10 plugin)
ii gstreamer0.10-plugins-bad:amd64 0.10.23-7.2ubuntu5 amd64 GStreamer plugins from the "bad" set
ii gstreamer0.10-plugins-base:amd64 0.10.36-2 amd64 GStreamer plugins from the "base" set
ii gstreamer0.10-plugins-base-apps 0.10.36-2 amd64 GStreamer helper programs from the "base" set
ii gstreamer0.10-plugins-good:amd64 0.10.31-3+nmu1ubuntu5 amd64 GStreamer plugins from the "good" set
ii gstreamer0.10-plugins-ugly:amd64 0.10.19-2ubuntu5 amd64 GStreamer plugins from the "ugly" set
ii gstreamer0.10-pulseaudio:amd64 0.10.31-3+nmu1ubuntu5 amd64 GStreamer plugin for PulseAudio
ii gstreamer0.10-tools 0.10.36-1.2ubuntu3 amd64 Tools for use with GStreamer
ii gstreamer0.10-x:amd64 0.10.36-2 amd64 GStreamer plugins for X11 and Pango
ii gstreamer1.0-alsa:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugin for ALSA
ii gstreamer1.0-clutter 2.0.12-1 amd64 Clutter PLugin for GStreamer 1.0
ii gstreamer1.0-fluendo-mp3:amd64 0.10.29.debian-1ubuntu1 amd64 Fluendo mp3 decoder GStreamer 1.0 plugin
ii gstreamer1.0-libav:amd64 1.4.3-1 amd64 libav plugin for GStreamer
ii gstreamer1.0-nice:amd64 0.1.7-1 amd64 ICE library (GStreamer plugin)
ii gstreamer1.0-plugins-bad:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugins from the "bad" set
ii gstreamer1.0-plugins-bad-faad:amd64 1.4.3-1ubuntu1 amd64 GStreamer faad plugin from the "bad" set
ii gstreamer1.0-plugins-bad-videoparsers:amd64 1.4.3-1ubuntu1 amd64 GStreamer videoparsers plugin from the "bad" set
ii gstreamer1.0-plugins-base:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugins from the "base" set
ii gstreamer1.0-plugins-base-apps 1.4.3-1ubuntu1 amd64 GStreamer helper programs from the "base" set
ii gstreamer1.0-plugins-good:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugins from the "good" set
ii gstreamer1.0-plugins-ugly:amd64 1.4.2-1 amd64 GStreamer plugins from the "ugly" set
ii gstreamer1.0-pulseaudio:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugin for PulseAudio
ii gstreamer1.0-tools 1.4.3-1 amd64 Tools for use with GStreamer
ii gstreamer1.0-x:amd64 1.4.3-1ubuntu1 amd64 GStreamer plugins for X11 and Pango
ii libclutter-gst-2.0-0:amd64 2.0.12-1 amd64 Open GL based interactive canvas library GStreamer elements
ii libgstreamer-plugins-bad0.10-0:amd64 0.10.23-7.2ubuntu5 amd64 GStreamer shared libraries from the "bad" set
ii libgstreamer-plugins-bad1.0-0:amd64 1.4.3-1ubuntu1 amd64 GStreamer development files for libraries from the "bad" set
ii libgstreamer-plugins-base0.10-0:amd64 0.10.36-2 amd64 GStreamer libraries from the "base" set
ii libgstreamer-plugins-base1.0-0:amd64 1.4.3-1ubuntu1 amd64 GStreamer libraries from the "base" set
ii libgstreamer-plugins-base1.0-dev 1.4.3-1ubuntu1 amd64 GStreamer development files for libraries from the "base" set
ii libgstreamer-plugins-good1.0-0:amd64 1.4.3-1ubuntu1 amd64 GStreamer development files for libraries from the "good" set
ii libgstreamer0.10-0:amd64 0.10.36-1.2ubuntu3 amd64 Core GStreamer libraries and elements
ii libgstreamer1.0-0:amd64 1.4.3-1 amd64 Core GStreamer libraries and elements
ii libgstreamer1.0-dev 1.4.3-1 amd64 GStreamer core development files
ii libqgsttools-p1:amd64 5.3.0-1ubuntu2 amd64 GStreamer tools for Qt 5 Multimedia module
ii libreoffice-avmedia-backend-gstreamer 1:4.3.3-0ubuntu1 amd64 GStreamer backend for LibreOffice
ii phonon-backend-gstreamer:amd64 4:4.7.80-0ubuntu1 amd64 Phonon GStreamer 1.0.x backend
ii phonon-backend-gstreamer-common:amd64 4:4.7.80-0ubuntu1 amd64 Phonon GStreamer 1.0.x backend icons
ii qtgstreamer-plugins:amd64 0.10.2-2.1ubuntu1 amd64 GStreamer plugins from QtGStreamer -
@Wieland
I installed the following additional packages just to be safe:
sudo apt-get install gstreamer0.10-* sudo apt-get install qtgstreamer-plugins libqgsttools-p1 sudo apt-get install gstreamer1.0-fluendo-mp3 gstreamer1.0-libav gstreamer1.0-plugins-bad-faad gstreamer1.0-plugins-bad-videoparsers
Now
dpkg -l | grep gst
covers your list of packages, but that didn't resolve the issue.I wonder whether I am missing some steps in installation/configuration of Qt/GStreamer.
Do you know what pipelining QtMultimedia use to play videos? I've read somewhere that it is a
gst-launch-0.10 playbin2 uri=
pattern, but as Qt is failing and the terminal command doesn't with this pipelining doesn't, it is possible that Qt is using some other pipelining. -
@nickaein said:
Do you know what pipelining QtMultimedia use to play videos?
I have no idea, sorry. I just noticed a while ago that video didn't work in QML on Ubuntu and then stumbled over this ffmpeg thing you also mentioned and that did the trick.
Another idea: Besides a current Qt version that I installed manually I also have the Ubuntu SDK installed which also includes Qt. Maybe this pulled in some missing dependencies.
Btw: It was an IT Crowd reference ^_^
-
Just a thought: Do you have vlc installed? I did not install anything multimedia related on my Ubuntu machine except vlc and libav.
-
@Wieland
These didn't help either:
sudo apt-get install gstreamer1.0-* sudo apt-get install libav-tools ffmpeg vlc
I submitted a question on Qt pipelining. The thing that bothers me is I cannot get QtMultimedia work on a clean installation.
Nevertheless, I might abandon QtMultimedia and use some other library to embed the video in my Qt application (e.g. VLC-Qt).