ahodesuka / ahoviewer

A GTK image viewer, manga reader, and booru browser
MIT License
480 stars 30 forks source link

Can't play webm #94

Closed botist closed 4 years ago

botist commented 4 years ago

Title. Installed all the requirements, including gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-plugins-libav Capture

ahodesuka commented 4 years ago

This is not a ahovewier issue, the problem lies with GStreamer's matroska demuxer. Other webm files work, but some fail with the error matroskademux matroska-demux.c:725:gst_matroska_demux_parse_stream:<matroskademux0> Invalid TrackUID 0, yet those same files work for me in ffplay and mpv.

The next 2 webm file in your search both work, which just so happen to have a TrackUID of 1. The Matroska Element Specification says that TrackUID's must be any number except zero. I'll try opening an issue on GStreamer's tracker to see if they can throw a warning and continue trying to demux the file instead of hard failing when this problem is encountered.

ahodesuka commented 4 years ago

Upstream issue can be found here For the time being and for personal use I wrote a simple patch for gstreamer-plugins-good-1.16.2 to fix this issue

diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index b2cd9b5d4..c5f9d5f75 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -722,9 +722,9 @@ gst_matroska_demux_parse_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml,
           break;

         if (num == 0) {
-          GST_ERROR_OBJECT (demux, "Invalid TrackUID 0");
-          ret = GST_FLOW_ERROR;
-          break;
+          GST_WARNING_OBJECT (demux, "Invalid TrackUID 0");
+          //ret = GST_FLOW_ERROR;
+          //break;
         }

         GST_DEBUG_OBJECT (demux, "TrackUID: %" G_GUINT64_FORMAT, num);
botist commented 4 years ago

Sorry, but can you instruct me on how I can use this patch you made? I'm new to Linux and all

ahodesuka commented 4 years ago

First you'll want to copy the contents and save a patch file from the above post, let's say it's located at ~/webm.patch in this example. You'll need to compile and install gstreamer1.0-plugins-good from source, here's how: Now you'll need to get the gst-plugins-good source code by running:

git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-good.git
git checkout 1.16.2
cd gst-plugins-good

After changing in to the source directory you'll want to apply the saved patch file with:

patch -p1 < ~/webm.patch

Now configure, compile, and install with:

meson build
cd build
ninja
sudo ninja install

This will install the patched version to /usr/local/ instead of the normally used directory /usr/ (which is usually meant to be used by your distros package manager). You may need to uninstall the system version of gstreamer1.0-plugins-good, so that the patched one takes priority.

botist commented 4 years ago

Hi, thanks for the detailed guide. Following your instruction, when I get to meson build I'm met with this:

The Meson build system
Version: 0.53.2
Source dir: /home/lol/gst-plugins-good
Build dir: /home/lol/gst-plugins-good/build
Build type: native build
Project name: gst-plugins-good
Project version: 1.16.2
C compiler for the host machine: cc (gcc 9.3.0 "cc (Ubuntu 9.3.0-10ubuntu2) 9.3.0")
C linker for the host machine: cc ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
C++ compiler for the host machine: c++ (gcc 9.3.0 "c++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0")
C++ linker for the host machine: c++ ld.bfd 2.34
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES
Compiler for C supports arguments -fvisibility=hidden: YES
Compiler for C supports arguments -fno-strict-aliasing: YES
Message: Disabling GLib cast checks
Has header "dlfcn.h" : YES
Has header "fcntl.h" : YES
Has header "inttypes.h" : YES
Has header "memory.h" : YES
Has header "process.h" : NO
Has header "stdint.h" : YES
Has header "stdlib.h" : YES
Has header "strings.h" : YES
Has header "string.h" : YES
Has header "sys/ioctl.h" : YES
Has header "sys/param.h" : YES
Has header "sys/socket.h" : YES
Has header "sys/stat.h" : YES
Has header "sys/time.h" : YES
Has header "sys/types.h" : YES
Has header "unistd.h" : YES
Library m found: YES
Checking for function "asinh" with dependency -lm: YES
Checking for function "clock_gettime" with dependency -lm: YES
Checking for function "cosh" with dependency -lm: YES
Checking for function "dcgettext" with dependency -lm: YES
Checking for function "getpagesize" with dependency -lm: YES
Checking for function "isinf" with dependency -lm: YES
Checking for function "mmap" with dependency -lm: YES
Checking for function "mmap64" with dependency -lm: NO
Checking for function "sinh" with dependency -lm: YES
Checking for size of "char" : 1
Checking for size of "int" : 4
Checking for size of "long" : 8
Checking for size of "short" : 2
Checking for size of "void*" : 8
Checking for size of "off_t" : 8
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C++ supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wredundant-decls: YES
Compiler for C++ supports arguments -Wredundant-decls: YES
Compiler for C supports arguments -Wwrite-strings: YES
Compiler for C++ supports arguments -Wwrite-strings: YES
Compiler for C supports arguments -Winit-self: YES
Compiler for C++ supports arguments -Winit-self: YES
Compiler for C supports arguments -Wmissing-include-dirs: YES
Compiler for C++ supports arguments -Wmissing-include-dirs: YES
Compiler for C supports arguments -Wno-multichar -Wmultichar: YES
Compiler for C++ supports arguments -Wno-multichar -Wmultichar: YES
Compiler for C supports arguments -Wvla: YES
Compiler for C++ supports arguments -Wvla: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C++ supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wdeclaration-after-statement: YES
Compiler for C supports arguments -Wold-style-definition: YES
Compiler for C supports arguments -Waggregate-return: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency gstreamer-1.0 found: YES 1.16.2
Run-time dependency gstreamer-base-1.0 found: YES 1.16.2
Run-time dependency gstreamer-net-1.0 found: YES 1.16.2
Run-time dependency gstreamer-controller-1.0 found: YES 1.16.2
Run-time dependency gstreamer-check-1.0 found: YES 1.16.2
Run-time dependency gstreamer-pbutils-1.0 found: YES 1.16.2
Run-time dependency gstreamer-allocators-1.0 found: YES 1.16.2
Run-time dependency gstreamer-app-1.0 found: YES 1.16.2
Run-time dependency gstreamer-audio-1.0 found: YES 1.16.2
Run-time dependency gstreamer-fft-1.0 found: YES 1.16.2
Run-time dependency gstreamer-riff-1.0 found: YES 1.16.2
Run-time dependency gstreamer-rtp-1.0 found: YES 1.16.2
Run-time dependency gstreamer-rtsp-1.0 found: YES 1.16.2
Run-time dependency gstreamer-sdp-1.0 found: YES 1.16.2
Run-time dependency gstreamer-tag-1.0 found: YES 1.16.2
Run-time dependency gstreamer-video-1.0 found: YES 1.16.2
Run-time dependency gstreamer-gl-1.0 found: YES 1.16.2
Message: GStreamer OpenGL window systems: gbm wayland x11
Message: GStreamer OpenGL platforms: glx egl
Message: GStreamer OpenGL apis: gles2 gl
Run-time dependency zlib found: YES 1.2.11
Run-time dependency glib-2.0 found: YES 2.64.3
Run-time dependency gobject-2.0 found: YES 2.64.3
Run-time dependency gio-2.0 found: YES 2.64.3
Run-time dependency orc-0.4 found: YES 0.4.31
Program orcc found: YES (/usr/bin/orcc)
Header <gst/gstconfig.h> has symbol "GST_DISABLE_GST_DEBUG" with dependency gstreamer-1.0: NO
Message: GStreamer debug system is enabled
Library bz2 found: NO
Has header "sys/soundcard.h" : YES
Message: Checking headers needed for Open Sound System 4 plugin...
Has header "fcntl.h" : YES (cached)
Has header "sys/ioctl.h" : YES (cached)
Has header "sys/stat.h" : YES (cached)
Has header "sys/types.h" : YES (cached)
Message: Required headers found, building Open Sound System 4 plugin.
Has header "linux/videodev2.h" : YES
Message: building v4l2 plugin
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency gudev-1.0 found: NO (tried pkgconfig and cmake)
Run-time dependency libv4l2 found: NO (tried pkgconfig and cmake)
Run-time dependency x11 found: YES 1.6.9
Run-time dependency xext found: YES 1.3.4
Checking for function "XShmAttach" with dependency xext: YES
Run-time dependency xfixes found: YES 5.0.3
Run-time dependency xdamage found: YES 1.1.5
Has header "aalib.h" : NO
Run-time dependency cairo-gobject found: YES 1.16.0
Run-time dependency flac found: NO (tried pkgconfig and cmake)
Run-time dependency gdk-pixbuf-2.0 found: YES 2.40.0
Run-time dependency gtk+-3.0 found: NO (tried pkgconfig and cmake)
Run-time dependency jack found: NO (tried pkgconfig and cmake)
Run-time dependency libjpeg found: NO (tried pkgconfig and cmake)
Library mp3lame found: NO
Run-time dependency caca found: NO (tried pkgconfig and cmake)
Run-time dependency libdv found: NO (tried pkgconfig and cmake)
Run-time dependency libpng found: YES 1.6.37
Run-time dependency libmpg123 found: NO (tried pkgconfig and cmake)
Run-time dependency libraw1394 found: NO (tried pkgconfig and cmake)
Run-time dependency libavc1394 found: NO (tried pkgconfig and cmake)
Run-time dependency libiec61883 found: NO (tried pkgconfig and cmake)
WARNING: rcc dependencies will not work reliably until this upstream issue is fixed: https://bugreports.qt.io/browse/QTBUG-45460
Run-time dependency qt5 (modules: Core, Gui, Qml, Quick) found: NO (tried pkgconfig, qmake-qt5 and qmake)
Program moc-qt5 found: NO
Program moc found: NO
Run-time dependency libpulse found: NO (tried pkgconfig and cmake)
Run-time dependency shout found: NO (tried pkgconfig and cmake)
Run-time dependency libsoup-2.4 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency libsoup-2.4
Subproject directory not found and libsoup.wrap file not found
Subproject  subprojects/libsoup is buildable: NO (disabling)
Dependency libsoup-2.4 from subproject subprojects/libsoup found: NO
Run-time dependency speex found: NO (tried pkgconfig and cmake)
Run-time dependency taglib found: NO (tried pkgconfig and cmake)
Run-time dependency twolame found: NO (tried pkgconfig and cmake)
Run-time dependency vpx found: NO (tried pkgconfig and cmake)
Run-time dependency wavpack found: NO (tried pkgconfig and cmake)
Run-time dependency valgrind found: NO (tried pkgconfig)
Run-time dependency gstreamer-plugins-base-1.0 found: YES 1.16.2
Library orc-test-0.4 found: YES
Run-time dependency qt5 (modules: Core, Gui, Widgets, Qml, Quick) found: NO (tried pkgconfig, qmake-qt5 and qmake)
Program moc-qt5 found: NO
Program moc found: NO
Run-time dependency qt5 (modules: Core, Gui, Widgets, Qml, Quick) found: NO (tried pkgconfig, qmake-qt5 and qmake)
Program moc-qt5 found: NO
Program moc found: NO
Configuring gstreamer-plugins-good-1.0-uninstalled.pc using configuration
Program xgettext found: YES (/usr/bin/xgettext)
Configuring config.h using configuration
Program python3 found: YES (/usr/bin/python3)
Build targets in project: 174

gst-plugins-good 1.16.2

  Subprojects
    libsoup: NO

Found ninja-1.10.0 at /usr/bin/ninja

Ignoring all the "NOs" and just proceding with cd build ninja sudo ninja install doesn't work. I now realize I need to install the dependencies, just wanted to ask how you do it. Do you manually search and install each one of them individually or is there a trick or command to do it automatically?

ahodesuka commented 4 years ago

The only dependencies you should need for the matroska demuxer/parser is libzip2. You could try explicitly enabling the matroska plugin with (inside the base directory ~/gst-plugins-good:

meson build --reconfigure -Dmatroska=enabled

--reconfigure is required when running meson again on the same directory (build) I can't really see anything wrong with what you posted, was there any error message when you ran ninja?

I use Gentoo which uses a package manager that compiles all the libraries every package needs (with the feature to enable/disable optional ones), and it has support for user patches.

botist commented 4 years ago

I see, guess I was wrong thinking I didn't have the dependencies...

Just tried meson build --reconfigure -Dmatroska=enabled , didn't work for me either.

No errors when running ninja, I just assumed something went wrong on my side while building because I still can't run webm's. ps: I uninstalled gstreamer1.0-plugins-good so the manually installed one takes precedence.

I don't think there's a WSL distribution of Gentoo, else I'd try it. Sounds veeeeery convenient lol

ahodesuka commented 4 years ago

So no webm files at all work, and have never worked? If that's the case then you should post the output of the following GST_DEBUG=2 gst-play-1.0 <path to valid webm file>

The patch I posted above was only for the odd webm file that had an invalid TrackUID. If no webm files play at all it sounds like you're probably missing the vpx decoder.

botist commented 4 years ago
Press 'k' to see a list of keyboard shortcuts.
Now playing /home/lol/affbba5d89b42f9e44f260afbb69d709.webm
0:00:00.009679900 25557 0x5641fa2e2690 WARN                 basesrc gstbasesrc.c:3600:gst_base_src_start_complete:<source> pad not activated yet
0:00:00.009979000 25557 0x5641fa2e2690 WARN                 basesrc gstbasesrc.c:3600:gst_base_src_start_complete:<source> pad not activated yet
0:00:00.041170000 25557 0x5641fa2dd5e0 WARN                 playbin gstplaybin2.c:4683:autoplug_select_cb:<playbin> Could not activate sink xvimagesink
error: XDG_RUNTIME_DIR not set in the environment.
0:00:00.150474300 25557 0x5641fa2dd5e0 WARN             glimagesink gstglimagesink.c:1010:_ensure_gl_setup:<sink> error: No GL shader support available
0:00:00.150637700 25557 0x5641fa2dd5e0 WARN                 playbin gstplaybin2.c:4683:autoplug_select_cb:<playbin> Could not activate sink glimagesink
0:00:04.7 / 0:00:04.7
Reached end of play list.

Apparently its running, but not inside ahoviewer (for me) for some reason. webm file I tested: https://danbooru.donmai.us/data/__texas_and_exusiai_arknights_drawn_by_amopui__affbba5d89b42f9e44f260afbb69d709.webm Capture1

ahodesuka commented 4 years ago

Okay I know what the problem is, most likely. I'm not exactly sure how WSL works (never used it), but ahoviewer is trying to load the xvimagesink and if that fails it tries ximagesink both which may not exist in your enviornment. When I build ahoviewer for Windows native, I make it use the d3dvideosink.

Post the output of gst-inspect-1.0 | grep -i "\(image\|video\)sink" to show me which plugins are available on your system.

botist commented 4 years ago

Took me some time to figure out why the command was asking for input lol here's the output:

autodetect:  autovideosink: Auto video sink
opengl:  glimagesink: GL Sink Bin
opengl:  glimagesinkelement: OpenGL video sink
xvimagesink:  xvimagesink: Video sink
ximagesink:  ximagesink: Video sink
ahodesuka commented 4 years ago

What ever you're using to run X11 application on WSL probably doesn't implement the required functionality for xvimagesink. Try running and posting the results of both: GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! xvimagesink and GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! ximagesink

botist commented 4 years ago

gmorning

I'm running VcXsrv, which I've read is the most versatile out of the avaible X11 apps out there GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! xvimagesink results:

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)
Setting pipeline to NULL ...
Freeing pipeline ...

GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! ximagesink results:

Setting pipeline to PAUSED ...
0:00:32.192657300 25763 0x556a0d775b60 WARN              ximagesink ximagesink.c:859:gst_x_image_sink_xcontext_get:<ximagesink0> error: Could not initialise X output
0:00:32.192798700 25763 0x556a0d775b60 WARN              ximagesink ximagesink.c:859:gst_x_image_sink_xcontext_get:<ximagesink0> error: Could not open display
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXImageSink:ximagesink0: Could not initialise X output
Additional debug info:
ximagesink.c(859): gst_x_image_sink_xcontext_get (): /GstPipeline:pipeline0/GstXImageSink:ximagesink0:
Could not open display
Setting pipeline to NULL ...
Freeing pipeline ...

Lmao sorry I'm actually stupid, didn't notice my xforwarding app was closed. Don't blame u for not answering I'll post actual results soon

botist commented 4 years ago

actual results to the commands GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! xvimagesink

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
XVideo extension is not available
Setting pipeline to NULL ...
Freeing pipeline ...

GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! ximagesink

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
XVideo extension is not available
Setting pipeline to NULL ...
Freeing pipeline ...
lol@DESKTOP-LUDFGKG:~$ GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! ximagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)BGRx, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstXImageSink:ximagesink0.GstPad:sink: caps = video/x-raw, format=(string)BGRx, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:09.799189700 25310 0x55578557aaa0 WARN              ximagesink ximagesink.c:696:gst_x_image_sink_handle_xevents:<ximagesink0> error: Output window was closed
ERROR: from element /GstPipeline:pipeline0/GstXImageSink:ximagesink0: Output window was closed
Additional debug info:
ximagesink.c(696): gst_x_image_sink_handle_xevents (): /GstPipeline:pipeline0/GstXImageSink:ximagesink0
Execution ended after 0:00:09.740585000
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
0:00:09.814244800 25310 0x55578557ab60 WARN              ximagesink ximagesink.c:1420:gst_x_image_sink_show_frame:<ximagesink0> could not output image - no window
0:00:09.814354900 25310 0x55578557ab60 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<videotestsrc0> error: Internal data stream error.
0:00:09.814387300 25310 0x55578557ab60 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<videotestsrc0> error: streaming stopped, reason error (-5)
Setting pipeline to NULL ...
Freeing pipeline ...

I feel obliged to say thanks for your patience lol

ahodesuka commented 4 years ago

So the test output window, like below, actually shows up and works with GST_DEBUG=2 gst-launch-1.0 -v videotestsrc ! ximagesink ? image

botist commented 4 years ago

Yes-sorry for not pointing that out

ahodesuka commented 4 years ago

Okay so the problem is then that your gst-plugins-base package installed the xvimagesink plugin but your X11 server doesn't support the Xvideo extension. You can fix this by simply deleting the /usr/lib64/gstreamer-1.0/libgstxvimagesink.so file. ahoviewer is will fall back to the ximagesink if the xvimagesink isn't found. I may add a corner case fix for this into ahoviewer, but for now deleting the .so file should be able to get things working.

botist commented 4 years ago

It works, thanks! I wish I shared at least 10% of your Linux/CS knowledge