From Ксения [Xenia] to Мария [Maria] With ffmpeg, gnome-subtitles, and mencoder

I used Mplayer's mencoder (built from source) to render the English/Russian subtitles in the PoC video above -- as I was trying out the upcoming GNU/Linux Debian Jessie distribution encapsulated inside a KVM virtual machine.

Debian: virt-manager managed KVM Jessie instance

In the past I had used mencoder to add Spanish subtitles to a video, but this time I was challenged with Russian subtitles, as those initially would not render properly in the resulting video. As a matter of fact, I was not even able to install mencoder from the Debian Jessie and Sid repositories due to libdvdnav4 dependency issue. Thus, the ephemeral viable option was to build mplayer's mencoder from source --which will skip support for DVD during the configure phase.

To solve the first issue, during Debian Jessie installation routine in the virtual machine I selected Russian as an additional language:

Debian Jessie installation: add ru_RU.UTF-8 locale during installation

I can verify the above action by examining /etc/locale.gen; I can see (scrolling to the bottom) that, in effect, I enabled 2 languages in addition to English: Russian and Mexico's Spanish dialect, all UTF-8.

Examining Debian Jessie /etc/locale.gen

For the record, at the top of the /etc/locale.gen file the user is advised to execute:


after manually enabling any locale (by removing the hash symbol from the beginning of the directive.)

Building mplayer -- defaults to building mencoder, too -- from source in Debian Jessie.

I update Debian repositories:


apt-get update

Since I am getting mplayer/mencoder code via Subversion:


apt-get install subversion

Then I get the mplayer/mencoder source code:


svn checkout svn:// mplayer

and directory mplayer will be created at my current directory location.

I change directory into mplayer:


cd mplayer

Since I am on Debian, and after scanning the README file, I can simply download a couple of DEBs:


apt-get install git devscripts

and then could simply execute the script under the debian directory to

"configure, compile and build a proper Debian .deb package with only one command:"


debian/ -b

But no. Since I am in a non-stable Debian, the resulting mencoder package may still refuse to install. Thus, I will download the relevant DEB packages manually:


apt-get install ffmpeg docbook-xsl ladspa-sdk libenca-dev libaa1-dev libasound2-dev libaudio-dev libcaca-dev libcdparanoia-dev libbluray-dev libdirectfb-dev libdts-dev libesd0-dev libfaad-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgif-dev libgl1-mesa-dev libgtk2.0-dev libjack-dev libjpeg-dev liblircclient-dev liblivemedia-dev liblzo2-dev libmp3lame-dev libmpcdec-dev libncurses5-dev libopenal-dev libpng12-dev libpulse-dev libschroedinger-dev libsdl1.2-dev libsmbclient-dev libspeex-dev libsvga1-dev libswscale-dev libtheora-dev libvorbis-dev libvorbisidec-dev libx11-dev libx264-dev  libxext-dev libxinerama-dev libxv-dev libxvidcore-dev libxvmc-dev libxxf86dga-dev libxxf86vm-dev libvdpau-dev pkg-config vstream-client-dev x11proto-core-dev xsltproc yasm zlib1g-dev mpg123 libmpg123-dev

After the above operation completes, then we are ready to build mplayer/mencoder from our downloaded source snapshot. Since I am in the mplayer directory:


./configure --enable-gui

(sample partial output):

Creating config.mak
Creating config.h

Config files successfully generated by ./configure --enable-gui !

Install prefix: /usr/local
Data directory: /usr/local/share/mplayer
Config direct.: /usr/local/etc/mplayer

Byte order: little-endian
Optimizing for: native

Note: the default installation directory is /usr/local/ and the --enable-gui option is, well, optional. As usual we could change the installation directory and disable/enable options. Simply type ./configure --help for an overview.

Additionally, if you will be downloading codecs, make sure to place the extracted files ending in .so under the directory /usr/local/lib/codecs/
End of note.

In this particular case for this post, I follow a successfully completed ./configure operation with:


make install

You may be required to acquire root privilege to make install into /usr/local --as is usual any time you install software from repositories.

Cihuatl Archetype And The Human Subconsciousness.

Unless one is brainwashed by one of those three(3) major patriarchal strains spread by fanatics throughout the world imposing a misogynist attitude, the archetype of Cihuatl, Nahuatl -- Mexico's language par excellence -- which translates as женщина in Russian, Woman in English, and Mujer in Spanish, is fascinating. It beams down onto a man's subconsciousness when least expected.

I happen to add an extra feature supporting RuTube videos in b2evolution for Openshift PaaS cloud hosted at my Nepohualtzintzin GitHub repository. And during testing I came across Miss MAXIM 2013 (Ксения Кайгородова: Xenia Kaygorodova). Thus the seed of a proof of concept -- or PoC -- was generated as result of a Russian media video and my chance listening of a melody sung in Spanish: ¿Tú De Que Vas? -- loosely translated as, Do You Even Need To Ask?

Thus, I used youtube-dl utility -- available also from Debian repositories. If it does not exist in your system, all you have to do is:


apt-get install youtube-dl

and subsequently downloaded the video from RuTube with command:


youtube-dl -o nenetl.flv

the option -o is just to assign a name to the file of interest; otherwise, you will end up with an unintelligeble alphanumeric-named file. As for the word nenetl, it is akin to a female image, ideal form, approaching an archetype.

Assuming current location is where the downloaded file resides, I create an ephemeral directory and change into it:


mkdir --verbose ephemeral
cd ephemeral

At this directory I will operate as follows:

used ffmpeg in order to extract the images from the nenetl.flv video, thus:


ffmpeg -../nenetl.flv -f image2 images%05d.png

The extracted images will occupy around 1.5 Gb of space. Now, by rough trial and error, I aimed to fit a relevant subset of the images into an interval equal to the length of the melody playing in the background. The final command -- referenced below -- outputs a nenetl_slideshow.mp4 which lasts approximately the length of the melody:


ffmpeg -r 6.2 -ss 00:00:03 -i images%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p ../nenetl_slideshow.mp4

I had to decrease the intake of the images to 6.2 frames per second (fps) by using the -r option to ffmpeg; thus it gives the video somewhat of a slow motion :))

Also, by feeding the -ss to ffmpeg I advanced the resulting slideshow by hh:mm:03 seconds. Please type:


man ffmpeg

for additional information relevant to options specified.

Once we are satisfied with the outcome, we can erase all the extracted .png (picture) files at our current ephemeral directory and thus recover our disk space.

Subsequently, I merged the slideshow file with the .mp3 Franco de Vita audio file as follows:


ffmpeg -../nenetl_slideshow.mp4 -../Franco_De_Vita-Tu_De_Que_Vas.mp3 -map 0 -map 1 -codec copy -shortest ../nenetl.mp4

Cool! Now we have the length of the melody that is roughly equivalent to the most visually interesting media. We can verify it with the mplayer that was built above:


mplayer ../nenetl.mp4

Or, alternatively, since we enabled the graphical user interface (GUI) as an argument during ./configure


gmplayer ../nenetl.mp4

Using Hayraphon skin in GUI-enabled mplayer: gmplayer

Note: If you accepted the default installation path for the mplayer build, please make sure to install your skins under /usr/local/share/mplayer/skins/. For instance, the location for the Hayraphon skin in the above snapshot would be /usr/local/share/mplayer/skins/hayraphon
End of note.

Adding Subtitles with GNOME Subtitles Editor

In Debian, we install the application as:


apt-get install gnome-subtitles

After it is completely installed, we start it from our shell:



From topmost menu, we select Video, Open from the ensuing cascaded menu, and locate the nenetl.mp4 video/audio media we created before. The media file will be embedded in the upper section of the application.

gnome-subtitles: open video

We select the leftmost blank paper icon labeled New to start creating subtitles for our video -- as it is played using the controls under the embedded media. Further, as our embedded media is played, we can add another line of text by pressing the plus icon labeled Insert located in the upper row of icons -- just below the uppermost menu.

gnome-subtitles: new/open .srt file

From aforementioned row we also can save our newly created subtitles file by selecting the green arrow pointing down in a drawer icon, labeled as Save.

The named file will default to be saved with an extension .srt and UTF-8 locale.

Save dialog prompting format and location of subtitles file.

After we are satisfied assigning subtitles to relevant sections of the embedded audio/visual stream, we are ready to embed the subtitles file into the actual nenetl.mp4 media. For that we will use mencoder.

Assuming our location continues to be our ephemeral directory that we created for this set of tasks and we have a resulting subtitles file also here, we type next command:


mencoder ../nenetl.mp4 -oac mp3lame -ovc lavc -sub -subcp enca:ru:utf--subfont-outline 4 -of mpeg -o xenia.mp4

Alternatively, directive below will add extra font feature to your subtitles:


mencoder ../nenetl.mp4 -oac mp3lame -ovc lavc -sub -subcp enca:ru:utf--subfont-text-scale 4 -subfont-outline 6 -of mpeg -o Nenetl.mp4

Debian Jessie gmplayer


Useful FFmpeg Commands.

ffmpeg, how to add new audio (not mixing) in video

Past midway during the creation of this post -- researching sources -- I was surprised to find the RuTube source is also available from YouTube, albeit with a different cover:
Десятка финалисток Miss MAXIM 2013. Часть первая (Ксения Кайгородова)

How I got b2evolution to work in both English and Russian with UTF-8

DISCLAIMER:P although due diligence has been applied, the above post is intended as a proof of concept for encoding Russian language subtitles in videos.

Please do not hold me or Metztli Information Technology, or its associates, responsible if the information provided here does not achieve the desired result. The information is provided AS IS and with the hope that it may be useful to the Internet community.

Notwithstanding, There is no implicit or explicit guarantee that the information presented here is accurate. Accordingly, if an user(s) decide to implement the procedure or shell commands described here she, he, or them, do so at her, his, or their own risk. You have been forewarned.

I reserve the right to modify the blog and even to delete it without further notice.
Jose   ,   01:03:00 pm
Categories: media creation

No feedback yet

Form is loading...