Skip to content
May 23, 2018 / ftth

Saving files to remote folders (smb, nfs) on Chromium/Firefox and other GTK3 apps

When moving from GTK2 to GTK3, apps would not show the remote locations anymore in the file chooser (as displayed in Nautilus):

Took me an incredibly long time to finally figure out that this has just been moved to “Other locations”; my understanding is that only the fuse-exposed gvfs backends (like smb, but not Gdrive for instance, as visible through mount | grep fuse and mounted into e.g. /run/user/UID/gvfs).

I believe this is a design mistake that produces a really bad user experience, caused by the inconsistency of showing a different behaviour in Nautilus and in the GTK3 file chooser.

The confusion was even bigger because at some point, GTK3 did not show these at all anymore, so there were both a design change (moving these locations into “Other locations” in the filechooser) and a regression (not showing fuse mount points anymore).

All credits go to Colin Leroy, who provided the patches and the final explanation.


April 16, 2018 / ftth

Temporarily skipping vaapi decoders in decodebin

Sometimes it can be useful to disable vaapi from the gstreamer auto-plugging logic, e.g. when there is a pending issue, or when in need to force the decoder choice in decodebin for testing purposes.

The standard possibilities are:

  • removing gstreamer-vaapi alltogether
  • overriding the plugin ranking system to demote the vaapi plugins below other alternatives — this requires using the gstreamer API, not available with gst-launch or totem

I found out an easier way: defining the LIBVA_DRIVER_NAME to a fake value, which will enforce vaapi to fail initializing, hence skipping it’s plugins.

For instance:

LIBVA_DRIVER_NAME=fakedriver gst-launch-1.0 playbin uri=file:///tmp/file.mp4

Without it:

$ gst-launch-1.0 playbin uri=file://`pwd`/bbb-1920-1080-30.mp4
Got context from element 'vaapisink0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";

With the env var, we can see that avdec_h264 has been selected instead:

LIBVA_DRIVER_NAME=fakedriver gst-launch-1.0 playbin uri=file://`pwd`/bbb-1920-1080-30.mp4 -v
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/avdec_h264:avdec_h264-0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4.1, profile=(string)high, codec_data=(buffer)01640029ffe1001b67640029acca501e0089f970110000030001000003003c8f18319601000568e93b2c8b, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true



December 22, 2017 / ftth

Gstreamer “delayed linking failed” with rtspsrc video and audio

Trying to use decodebin with a network camera, i was getting some “Delayed linking failed” errors, misled by some old mailing list responses like this one.

$ gst-launch-1.0 rtspsrc location=rtsp:// name=src src. ! decodebin ! audioconvert ! fakesink silent=false src. ! decodebin ! videoconvert ! fakesink silent=false
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin1: Delayed linking failed.
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.

As ndufresnes pointed out, decodebin may just receive audio or video without regards to downstream caps, which means that linking may or may not work depending on how rtspsrc created it’s caps.

The solution is to filter out by rtp caps, which will ensure that the correct type will get correctly linked:

gst-launch-1.0 rtspsrc location=rtsp:// name=src src. ! "application/x-rtp, media=(string)audio" ! decodebin ! audioconvert ! fakesink silent=false src. ! "application/x-rtp, media=(string)video" ! decodebin ! videoconvert ! fakesink silent=false

This will however obviously fail if the network source doesn’t provide any audio at all.

December 21, 2017 / ftth

terminator-compatible tmux quick pane switching

I was trying to use tmux from within terminator with improved keyboard shortcuts. Using tips from some useful resources, i added the following to ~/.tmux.conf, which was supposed to let me switch panes with a simple Alt+arrow

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

This didn’t work out as expected (nothing was happening), and the culprit was terminator itself which was already binding these for the same task (i.e. switching between panes). After fiddling a bit, i found that the Windows key + Alt combination was pretty much left available on Gnome / terminator:

# switch panes using Win-Alt arrow without prefix
bind -n M-115-Left select-pane -L
bind -n M-115-Right select-pane -R
bind -n M-115-Up select-pane -U
bind -n M-115-Down select-pane -D
December 17, 2017 / ftth

Purging librelec databases

My Pi2 powered Librelec had a music library with ~2000 albums, which was making the Yastse android kodi remote take litterally 60 minutes to refresh in the background (happily draining the battery along the way).

I needed to purge the complete audio database, and rely on directory browsing instead to launch music.

To do this, log into your librelect device, and remove the culprit db file(s):

# ls -l ~/.kodi/userdata/Database
# ls -lh
total 47309
-rw-r--r-- 1 root root 28.0K May 14 2017 ADSP0.db
-rw-r--r-- 1 root root 1.3M Dec 17 09:31 Addons27.db
drwxr-xr-x 2 root root 1.0K May 14 2017 CDDB
-rw-r--r-- 1 root root 28.0K May 14 2017 Epg11.db
-rw-r--r-- 1 root root 43.9M Dec 17 09:23 MyMusic60.db
-rw-r--r-- 1 root root 424.0K Dec 14 23:02 MyVideos107.db
-rw-r--r-- 1 root root 32.0K May 14 2017 TV29.db
-rw-r--r-- 1 root root 432.0K Dec 17 08:42 Textures13.db
-rw-r--r-- 1 root root 20.0K May 14 2017 ViewModes6.db
# rm ~/.kodi/userdata/Database/MyMusic60.db

I guess these 43 Mb of data were just too much for this little Pi2.

After a reboot, the library should have been emptied.

November 14, 2017 / ftth

Setting up a gst_uninstalled environment with gst-build

I used to follow Arun’s QuickStart guide to setup gst-uninstalled environments easily, but this left quite a lot of manual tasks. It is now possible to make it much faster and easier thanks to gst-build, which

  1. uses meson/ninja instead of autotools (much faster)
  2. replaces both and scripts
  3. includes built-in support for python and newer projects like gstreamer-vaapi

After installing the required dependencies (meson, ninja), it’s a few lines of commands to have a complete environment usable (not to mention that it is much, much faster and automated):

Updating and rebuilding is a simple (from the main gst-build directory, not from build/):

ninja -C build/ update

To use the gst-uninstalled environment to run any program:

/home/myuser/gst-build/ gst-launch-1.0 videotestsrc ! fakesink

To build without debug options enabled (may improve performance in some cases):

meson --buildtype=debugoptimized -Denable_python=true -Ddisable_gstreamer_sharp=true -Ddisable_rtsp_server=true -Ddisable_gst_editing_services=true build

If you are using Ubuntu 16.04, you will need the following packages:

apt-get install python3-pip ninja-build pkg-config gobject-introspection gnome-devel bison flex libgirepository1.0-dev liborc-0.4-dev
pip install meson
November 10, 2017 / ftth

Software raid check killing Ubuntu 16.04 servers

While investigating why our automated on-site Q&A tests would fail once per month (http timeouts, etc…), indicating heavy load, i eventually discovered that it happened while the monthly raid array check was running, and found out that Ubuntu 16.04 ships

  • with the deadline i/o scheduler by default (cat /sys/block/sda/queue/scheduler)
  • a monthly software raid check (launched by /etc/cron.d/mdadm) which runs /usr/share/mdadm/checkarray with the –idle argument (which uses ionice)

From /usr/share/mdadm/checkarray:

# queue request for the array. The kernel will make sure that these requests
# are properly queued so as to not kill one of the array.
echo $action > $MDBASE/sync_action
[ $quiet -lt 1 ] && echo "$PROGNAME: I: check queued for array $array." >&2

case "$ionice" in
 idle) ioarg='-c3'; renice=15;;
 low) ioarg='-c2 -n7'; renice=5;;
 high) ioarg='-c2 -n0'; renice=0;;
 realtime) ioarg='-c1 -n4'; renice=-5;;
 *) break;;

resync_pid= wait=5
while [ $wait -gt 0 ]; do
 wait=$((wait - 1))
 resync_pid=$(ps -ef | awk -v dev=$array 'BEGIN { pattern = "^\\[" dev "_resync]$" } $8 ~ pattern { print $2 }')
 if [ -n "$resync_pid" ]; then
 [ $quiet -lt 1 ] && echo "$PROGNAME: I: selecting $ionice I/O scheduling class and $renice niceness for resync of $array." >&2
 ionice -p "$resync_pid" $ioarg || :
 renice -n $renice -p "$resync_pid" 1>/dev/null || :
 sleep 1

However, since the deadline i/o scheduler does ignore ionice, even though the –idle argument is passed, the raid check (which is very long) will just not run with a low i/o priority…

The most incredible part is how undocumented this all is…