This is mostly a note pad for myself with quick instructions about how to add subtitles streams to an existent video.

Although I’m personally more in favor of using Ogg, reality is that Matroska is the one that is getting the biggest support among the Open Source container formats and it also has a great deal of features.

Also, because of widespread adoption, in spite of not having a really formal syntax and many features, SubRip is my chosen format for subtitles.

Now, I’m the owner of a Samsung 3D SmartTV which allows external SubRip .srt files. However, it also supports Matroska files with embedded subtitles and having the subtitles in the same container than the audio and video streams have some advantages. The main one is that I would be able to play such file through UPnP, with subtitles included, meanwhile that’s not possible with some UPnP servers if the subtitles are in a different file than the video. That’s the case, for example, with BubbleUPnP for Android, which I use from a tablet.

Anyway, enough introduction.

For creating a Matroska file from an existing video and a SubRip file I would use the MKVToolNix package. In a Debian based system you can install it with the following command:

Shell

1

root$apt-getinstall mkvtoolnix

In order to merge video and a subtitles (actually, many multiple streams), the proper command for this would be mkvmerge. Its usage is quite straight forward:

That’s basically it. With this command we will get, from a .mp4 and a .srt file, a .mkv file with both merged together. Now, if we would be wanting to add more languages we could have done something like this:

This is mostly a note pad for myself with quick instructions about how to add a “cover” tag to audio files.

I usually add covers to every individual audio file from my albums so I can nicely see them when playing the file either in my computer or mobile. Often, I just use the fantastic Ex Falso application not just to add more advanced tags to my audio files but also for downloading covers from different providers.

Whenever I cannot easily find the cover I’m looking for, I would just scan it and finally save it as a 500×500 pixels JPEG file named as cover.jpg in the same directory than the audio files.

Having this into account, let’s see how to embed the cover as a tag.

MP3 or, rather, id3 tags

For id3 tags I would use the eyeD3 tool. It can be done as easily as running:

Shell

1

$eyeD3--add-image=cover.jpg:FRONT_COVER*.mp3

OGG Vorbis

In the case of OGG Vorbis files I follow a little bit more complex steps. I’m sure I could just simplify this in a single step but, by now, I’m too lazy to spend 5 minutes improving this O:)

First, I would add the cover into an individual OGG Vorbis file using the EasyTag application. I could just save the same cover on every file but I wanted to show how to do that in batch mode from the command line.

Therefore, as I said, I just save the cover into and individual file an extract all the tags from such file using the vorbiscomment tool:

Shell

1

$vorbiscomment-l<file>.oga>comments.txt

Then, I would modify the comments.txt file so it will only contain the needed art cover tags and append them to the rest of the files:

Shell

1

$vorbiscomment-a-ccomments.txt<other_file>.oga

Hopefully, I will update this in the future with a single command to do it in a go and will also review how to be able to just link the proper cover from the audio files. Also, I will try to explain the logic for the naming of the covers in the local directory without having to add the tag to any file so crawlers like Tracker will just do the work for us.

This is mostly a note pad for myself with quick instructions about how to extract, cut, join and merge audio and video streams.

In Igalia we often hold meetings with several parties attending remotely. The easy setting of such meetings usually involve a shared desktop through VNC and a SIP call in a multi user room hold in our Asterisk installation.

When some of my Igalian mates cannot attend we may want to record the meeting so they can play it later. Fortunately, GNOME Shell provides integrated desktop recording out of the box and we have Asterisk set to record automatically our calls in specific multi user rooms.

So, all what it is left after a meeting is just to get both files, edit them slightly and sync them to merge them in a single multimedia container.

Usually, I would use Kdenlive in my video editing tasks. However, Kdenlive doesn’t support “video edition” without re-encoding and I would really like not to re-encode the whole stuff. Specially, the video stream. Therefore, I still will use Kdenlive for the task of syncing both streams and looking for the cutting points for both, the video and the audio file.

For most of this “without re-encoding” actions I will use the great avconv tool.

First, I will cut the video in the time 00:07:45 as starting point and 02:05:20 as ending point:

This command basically demuxes the WebM container and extract the video stream between those two points to mux it again into a Matroska container.

Then, I will cut the audio in the starting point 00:02:13 and ending point 01:59:48. For editing OGG files we can use Oggscissors or OGG Video Tools’ oggCut .

You won’t find Oggscissors in Debian (the distribution I use). Therefore, you will have to download it and install pyvorbis and pyogg and, maybe, modify slightly the script to use the proper python interpreter. You can install the missing packages like this:

Shell

1

root$apt-getinstall python-pyvorbis

Once with Oggscissors working, we can get the interesting audio chunk like:

Shell

1

$oggscissors.py--from=133--upto=7188conf-call.oggcut-confcall.ogg

or, with oggCut, like:

Shell

1

$oggCut-s133000-e7188000conf-call.oggcut-conf-call.ogg

It may happen that we actually want to extract the audio from another video file. This has happened to us, eventually, when wanting to use the audio from a synced file into another video with higher quality.

We will also use avconv for this:

Shell

1

$avconv-isynced-video.ogv-map0:1-c:acopy synced-audio-output.ogg

It may also happen that we want to join a couple of OGG files since our SIP conf-calls sometimes have hiccups. With Oggscissors this will be done as follows:

Shell

1

$oggscissors.py--joinfirst.oggsecond.oggjoint-output.ogg

With oggCat this will be done like:

Shell

1

$oggCat joint-output.oggfirst.oggsecond.ogg

Finally, we will merge or mux the resulting video and audio files into a single media container. Again, with avconv this will be done like:

So lately I’ve been devoting my time in Igalia around the GNU/Linux graphics stack focusing, more specifically, in Mesa, the most popular open-source implementation of the OpenGL specification.

When working in Mesa and piglit, its testing suite, quite often you would like to compare the results obtained when running a specific OpenGL code with one driver or another.

In the case of nVIDIA graphic cards we have the chance of comparing the default open source driver provided by Mesa, nouveau, or the proprietary driver provided by nVIDIA. For installing the nVIDIA driver you will have to run something like:

Changing from one driver to another involves several steps so I decided to create a dirty script for helping with this.

The actions done by this script are:

Instruct your X Server to use the adequate X driver.
These instructions apply to the X.org server only.
When using the default nouveau driver in Debian, the X.org server is able to configure itself automatically. However, when using the nVIDIA driver you most probably will have to instruct the proper settings to X.org.
nVIDIA provides the package nvidia-xconfig. This package provides a tool of the same name that will generate a X.org configuration file suitable to work with the nVIDIA X driver:

Shell

1

2

3

4

5

6

7

8

9

root$nvidia-xconfig

WARNING:Unable tolocate/openXconfiguration file.

Packagexorg-server was notfound inthe pkg-config search path.

Perhaps you should add the directory containing`xorg-server.pc'

tothe PKG_CONFIG_PATH environment variable

No package'xorg-server'found

NewXconfiguration filewritten to'/etc/X11/xorg.conf'

I have embedded this generated file into the provided custom script since it is suitable for my system:

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

echo'Section"ServerLayout"

Identifier"Layout0"

Screen0"Screen0"

InputDevice"Keyboard0""CoreKeyboard"

InputDevice"Mouse0""CorePointer"

EndSection

Section"Files"

EndSection

Section"InputDevice"

# generated from default

Identifier"Mouse0"

Driver"mouse"

Option"Protocol""auto"

Option"Device""/dev/psaux"

Option"Emulate3Buttons""no"

Option"ZAxisMapping""4 5"

EndSection

Section"InputDevice"

# generated from default

Identifier"Keyboard0"

Driver"kbd"

EndSection

Section"Monitor"

Identifier"Monitor0"

VendorName"Unknown"

ModelName"Unknown"

HorizSync28.0-33.0

VertRefresh43.0-72.0

Option"DPMS"

EndSection

Section"Device"

Identifier"Device0"

Driver"nvidia"

VendorName"NVIDIA Corporation"

EndSection

Section"Screen"

Identifier"Screen0"

Device"Device0"

Monitor"Monitor0"

DefaultDepth24

SubSection"Display"

Depth24

EndSubSection

EndSection

'>/etc/X11/xorg.conf

I would recommend you to substitute this with another configuration file generated with nvidia-xconfig on your system.

Select the proper GLX library.
Fortunately, Debian provides the alternatives mechanism to select between one or the other.

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

ALTERNATIVE=""

…

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

ALTERNATIVE="/usr/lib/mesa-diverted"

…

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

ALTERNATIVE="/usr/lib/nvidia"

…

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

update-alternatives--set glx"${ALTERNATIVE}"

Black list the module we don’t want the Linux kernel to load on start up.
Again, in Debian, the nVIDIA driver package installs the file /etc/nvidia/nvidia-blacklists-nouveau.conf that is linked, then, from /etc/modprobe.d/nvidia-blacklists-nouveau.conf instructing that the open source nouveau kernel driver for the graphic card should be avoided.
When selecting nouveau, this script removes the soft link creating a new file which, instead of black listing nouveau’s driver, does it for the nVIDIA proprietary one:

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

2

rm-f/etc/modprobe.d/nvidia-blacklists-nouveau.conf

echo"blacklist nvidia">/etc/modprobe.d/nouveau-blacklists-nvidia.conf

When selecting nVIDIA, the previous file is removed and the soft link is restored.

Re-generate the image used in the inital booting.
This will ensure that we are using the proper kernel driver from the beginning of the booting of the system:

Alternate nouveau and nVIDIA proprietary OpenGL driver

Shell

1

update-initramfs-u

With these actions you will be already able to switch your running graphic driver.

It is recommended to reboot the system although theoretically you could unload the kernel driver and restart the X.org server. The reason is that it has been reported that unloading the nVIDIA kernel driver and loading a different one is not always working correctly.