Improvement in converting video/audio files with VLC

VLC Media Player has the ability to convert video/audio files into various formats it supports, since a long time. There is a dedicated “Convert/Save” menu for converting single or multiple files at once into a different format, with limited ‘editing’ features such as specifying a start time, caching options etc. It is quite useful for basic editing/cropping of multimedia files.

As an example, one of the easiest ways to create a custom iPhone ringtone is to create a “.m4r” (AAC format) file exactly 40 seconds long. It is a matter of selecting your favourite music file and doing a “Convert/Save” with appropriate “Profile”. A “Profile” specifies the video/audio encoding to be used, which can be easily customized by selecting different audio and video codecs.

The options “Caching time”, “Play another media synchronously” (think adding different sound track to a video clipping) and a “Start time” etc can be specified under “Show more options” button and even more advanced functionality is available by making use of the “Edit Options” line. Internally, all the options specified at this line are passed to the converter.

There was one thing lacking in this “Convert/Save” dialog though – there was no possibility to specify a “Stop Time” akin to the “Start Time”, in the GUI (although it can be manually specified in the “Edit Options”, but you need to calculate the time in milliseconds). VLC 2.x series convert looks like as follows – notice the lack of “Stop time”:


Being bugged by this minor annoyance, I set out to add the missing “Stop-time” functionality. Going through the codebase of VLC, it was relieving to see that the converter backend already supports “:stop-time=” option (akin to “:start-time=”). It was then a matter of adding “Stop Time” to the GUI and properly updating the “Edit Options” when user changes the value.

A working patch was then sent to vlc-devel mailing list for review and feedback. After 5 rounds of review and constructive feedback from Filip Roséen the code was cleaned up (including existing code) which is now committed to the master branch. This functionality should be available to users in the upcoming 3.0 release. Screenshot below:




Convert iPhone contacts to vCard

On a recent troubleshooting attempt, I lost all the contacts in my Android phone. It had also received a recent update which took away the option to import contacts from another phone via bluetooth.
I still had some contacts in the old iPhone, but now that mass transfer via bluetooth is gone, it was a question of manually sending each contact in vCard format to the Android phone. That means I should probably find a less dreadful way to get the contacts back.

Here is one way to extract contacts en-masse from iPhone into popular vCard format. The contact and address details in iOS are stored by AddressBook application in a file named ‘AddressBook.sqlitedb’ which is an sqlite database. The idea is to open this database using sqlite, extract the details from a couple of tables and convert the entries into vCard format.

Disclaimer: the iPhone is an old 3GS running iOS 6 and it is jailbroken. If you attempt this, your mileage would vary. Required tools/softwares are usbmuxd (especially libusbmuxd-utils) and sqlite, with the prerequisite that openssh server is running on the jailbroken iPhone.

  1. Connect iPhone via USB cable to the Linux machine. Run iproxy 2222 22 to connect to the openssh server running on the jailbroken phone. iproxy comes with libusbmuxd-utils package.
  2. Copy the addressbook sqlite database from phone:scp -P 2222 mobile@localhost:/var/mobile/Library/AddressBook/AddressBook.sqlitedb .Instead of steps 1 and 2 above, it might be possible to copy this file using Nautilus (gvfs-afc) or Dolphin (kio_afc) file manager, although I’m not sure if the file is accessible.
  3. Extract the contact and address details from the sqlite db (based on this forum post):sqlite3 -cmd ".out contacts.txt" AddressBook.sqlitedb "select ABPerson.prefix, ABPerson.first,ABPerson.last,ABPerson.organization, c.value as MobilePhone, h.val ue as HomePhone, he.value as HomeEmail, w.value as WorkPhone, we.value as WorkEmail,ABPerson.note from ABPerson left outer join ABMultiValue c on c.record_id = ABPerson.ROWID and c.label = 1 and 3 left outer join ABMultiValue h on h.record_id = ABPerson.ROWID and h.label = 2 and = 3 left outer join ABMultiValue he on he.record_id = ABPerson.ROWID and he.label = 2 and = 4 left outer join ABMultiValue w on w.record_id = ABPerson.ROWID and w.label = 4 and = 3 left outer join ABMultiValue we on we.record_id = ABPerson.ROWID and we.label = 4 and = 4;"
  4. Convert the extracted contact details to vCard format:cat contacts.txt | awk -F\| '{print "BEGIN:VCARD\nVERSION:3.0\nN:"$3";"$2";;;\nFN:"$2" "$3"\nORG:"$4"\nEMAIL;type=INTERNET;type=WORK;type=pref:" $9"\nTEL;type=CELL;type=pref:"$5"\nTEL;TYPE=HOME:"$6"\nTEL;TYPE=WORK:"$8"\nNOTE:"$9"\nEND:VCARD\n"}' > Contacts.vcf
  5. Remove the empty content lines if some contacts do not have all the different fields:sed -i '/.*:$/d' Contacts.vcf

Now simply transfer the Contact.vcf file containing all the contact details to Android phone’s storage and import contacts from there.

TeX: Justification with no hyphenation

I’ve been reading a copy of 1984 by George Orwell, published by Fingerprint publishing — a beautifully typeset one. Already into half of Part II, but that’s when I noticed that the book is typeset with full justification sans any hyphenation. Incidentally I was typesetting something else, which probably is the reason I noticed it now. And I wanted to typeset my article the same way, with full justification but no hyphenation.

Biggest strength of TeX is its line, paragraph and page breaking algorithms where hyphenation plays a big part. Thus removing hyphenation means taking away a lot of those advantages. In any case, there are seemingly multiple ways to do it. From the TeX FAQ:

Use hyphenat package with


or set \hyphenpenalty and \exhyphenpenalty to 10000. These avoided hyphenation, but justification was bad – there were long words extending beyond the right margin. So moved on to next solution:


This one kept hyphenation to the minimum with justified text, but didn’t fully avoid it. And it would work only for text with current font. \sloppy sets \tolerance and \emergencystretch to large values.

And the last one, which provided full justification with no hyphenation is:


The \tolerance parameter sets how much badness is allowed, which influence paragraph/line breaking. \emergencystretch is the magical parameter which stretches text over multiple passes to balance the spacing. Setting \hyphenpenalty to infinite value actually has better effect than setting \tolerance.

Kerning feature for Malayalam fonts

At SMC, we’ve been continuously working on improving the fonts for Malayalam – by updating to newer opentype standard (mlm2), adding new glyphs, supporting new Unicode points, fixing shaping issues, reducing complexity and the compiled font size, involving new contributors etc.

Recently, out of scratching my own itch, I decided that it is high time to fix the annoyance that combination of Virama(U+D04D ് ) with quote marks (‘ ” ‘ ’ “ ” etc) used to overlap into an ugly amalgam in all our fonts. Usually Virama(് ) connects/combines two consonants which makes all 3 into a new glyph – for example സ+്+ന is shaped into a new glyph സ്ന (Note that you need a traditional orthography font installed to see the distinction in this example. Many of them are available here) . The root of the problem is that sometimes when Virama(് ) appears individually in a word such as “സ്വപ്‌‌നം” it connects two consonants പ and ന, it is positioned above the x height of most glyphs and it shall not have much left and right bearing to avoid ugly spacing between the consonants പ and ന.  Because of small side bearings, in fact of the negative right bearing (് protrudes beyond the right bearing) when a quote mark follows it, quote mark gets a little juxtaposed into Virama glyph and renders rather bad. The issue is quite prominent when you professionally typeset a book or article in Malayalam using XeTeX or SILE.

Fontforge’s tools made it easy to write opentype lookup rules for horizontal pair kerning to allow more space between Virama(് ) and quote marks. You can see the before and after effect of the change with Rachana font in the screenshot.


Update 26/03/2016: Many applications already support the kerning feature out of the box, including Firefox, SILE and VLC (3.0.0-git for subtitles) that I have tested, but many still need support, for instance LibreOffice, Kwrite etc. Here is a screenshot of VLC (3.0.0-git) taking kerning rules into account while displaying Malayalam subtitle.


Other fonts like AnjaliOldLipi, Meera and Chilanka also got this feature and those will be available with the new release in the pipeline. I have plans to expand this further to use with post-base vowels of വ(്വ) and യ(്യ) with abundant stacked glyphs that Malayalam has.

VLC now render subtitles in South Asian scripts!

If you were following VLC development status (hey, you should follow the awesome Jean-Baptiste Kempf’s weekly updates!), you might have noticed some recent improvements on how VLC handles subtitle text rendering. In May 2015, the freetype module was improved to use Harfbuzz for text shaping. On the week of August 4, it was mentioned that the internals of VLC subtitle handling were completely rewritten . And in last week’s (October 26) update it mentioned Salah-Eddin added support for font fallback in the freetype module; which would mean that there is no need to set a specific font to display particular script/language.

All this combined, it should mean that complex text shaping and rendering for subtitles should work fine out of the box. To test this, I built the VLC 3.0.0-git master branch by checking out the code, creating a tar ball and adapting the spec file from RPMFusion to build RPM package. NOTE: don’t remove '.git*' files while creating tar ball, otherwise building would fail. Then edited/translated one of the .srt subtitle files and used that to play a movie. The result is – Malayalam subtitles are shaped and rendered beautifully!

VLC rendering Malayalam subtitle
VLC rendering Malayalam subtitle

Jean-Baptiste Kempf tells me that this should also work fine with Android (since version 1.6.90) as well as with Windows. Totem (GNOME Vidoes) have been displaying complex texts correctly since years but VLC lacked that feature till now. This is an awesome news for people who were limited in enjoying world movies in their own language. There are collectives like MSone where volunteers translate world movies’ subtitles to Malayalam and help those to reach wider audience.

Kudos to the awesome Videolan team!

Akademy 2015 – where awesome things happen

Day 0:

Reached La Coruña on Friday 24th evening in time for the pre-registration event to attend my first Akademy. I met a few familiar faces and Jonathan Riddell introduced to many hackers. Later in the night we witnessed the interesting Galician ceremony of calling spirits.

Day 1:

Matthias Kirschner, the vice president of FSFE, delivered his keynote “An endangered species: The computer as universal machine”, offering a perspective on how computers were ‘unrestricted’ tools in the beginning. He started with the picture of man landing on the Moon and then raising his mobile phone to state the fact that this tiny device has more computing power than the computer that helped man land on the Moon. Fast forward to present times, look at how various businesses are trying to restrict that computing power. Trying to build restricting technologies actually takes a lot of manpower, time, effort and incurs cost - consider for instance the example of ‘sim locking’ - phones are manufactured by default to operate with any compatible sim card, but companies put a lot of effort in the software and hardware to restrict and tie down to specific carriers. The talk clearly showed the need for communities defending freedom in the digital age.

“Plasma desktop” by David Edmundson – David argued with the help of survey graphs that desktop usage is not slowing down, nor is the usage of Linux on desktop. He emphasized on the point that Plasma focus on “getting things done” and being “contextually aware” using KActivities etc. David concluded with the notes that Plasma 5 is in an encouraging state, it has a lot of potential for improvement in the short and long term and this is a great time to get involved in shaping its future.

“Plasma mobile” introduction - by Sebastian Kügler and Boudewijn Rempt. This session was quite an interesting event by virtue of announcing Plasma Mobile and demonstrating it running on Nexus 5 phone. Plasma mobile reference implementation is built on top of Kubuntu, using libhybris compatibility layer and KWin as the compositing manager. After the talk, a number of Nexus 5 devices flashed with Plasma mobile were on demo which felt super responsive and stable enough for a fantastic mobile development system.

I then went to the presentation about “Kdenlive” by Jean-Baptiste Mardelle - this video editor is in development for more than 10 years. Jean explained how it uses MLT framework and how important a vision statement for Kdenlive for a bright future of this video editing software.

“KDE Frameworks in use” - by commercial applications, by David Faure. David, being the maintainer of KDELibs and KDE Frameworks libraries, shared his experiences with commercial applications using KDE Frameworks such as KArchive, KIO etc. He mentioned that most companies are happy to upstream the improvements and they get ‘free of cost’ maintenance going forward.

And then we broke for a fantastic lunch sponsored by BlueSystems at the cafeteria.

Next talk was about “Packing C++ structs” by Volker Krause. Volker explained how memory layout of members in a struct are usually sequential and each member occupies size of its type and are aligned to alignment requirements of the type. For example, in x86 systems an int variable occupies 4 bytes and is aligned to 4 byte boundary in memory. He further explained how each individual member of a struct could be rearranged (at definition) to optimize the total size occupied by the struct and eliminate padding which wastes memory space.

Àlex Fiestas explained in his talk how Agile, TDD (test driven development), CI (continuous integration) & CD (continuous delivery) all mean the same and why continuous feedback is essential for successful software development.

Jens Reuterberg then talked on how to deal with different categories of jerks lurk in the community who make people feel “their work is bad and they should feel bad”, and potential strategies assumed against each type.

Next up was “KDevelop” by Milian Wolf. The KF5 port of core platform and some plugins are already completed and it works. The developers are working with CMake upstream for a faster engine. Some old code were removed and with it lost few features but those will make a come back sooner or later. The C++ support improved greatly due to LLVM based kdev-clang.

“Trojitá – a fast IMAP email client” by Jan Kundrát. Jan demonstrated Trojitá on the stage loading many thousands of messages very quickly. The Plasma mobile team expressed their interest to work together with Jan in bringing Trojitá to mobile. Jan later in a casual discussion explained how Trojitá makes use of on-demand and lazy loading to achieve fast response and excellent performance. At first only the IMAP envelops are retrieved from the server and when a message is selected, its header and body are retrieved. He also discussed how lazy loading hurts performance in certain situations.

After the talks, met with and talked to “WikiFM/WikitoLearn developer Riccardo Iaconelli, offered help by some of my friends who work on PHP/JavaScript to improve the WikitoLearn backend system. We had further discussions next days.

Day 2:

Second day started with the keynote on “Evolving KDE” by KDE e.V president Lydia Pintscher. She looked at KDE as a community - where we have been, where do we stand and where do we want to go. She emphasized on the necessity to focus on key areas and products. To the question from an audience member on what concretely means by focusing, Lydia answered - ask questions such as ‘why do we have so many music players’ for instance. There were also opinions expressed that design decisions in a top-down order do not usually work in community based projects and it has to come from ground up where involved parties (users, developers, designers) come together to agree on decisions. More discussions within the community followed during the Evolving KDE BoF session.

Andrew Lake and Thomas Pfeiffer from VDG team talked about “Vision” - the importance of each project to define a vision and strive to achieve it, guarding against diversion such as trying to do everything and ending up not doing anything better. They offered help and BoF session for interested projects to define and refine the vision for those. Many project maintainers later made use of their offer to define and refine vision for their projects.

“QtModeling and meta-modeling” by Sandro Andrade. QtModeling was developed as part of his PhD, which is a tool to define software models such as UML.

“Welcome to Massachusetts” presentation was changed by the time of presentation to “Welcome to Wayland” as Martin Gräßlin managed to actually make KWin and Plasma work on Wayland. He ran the presentation in his laptop running with Wayland backend. Clearly, Plasma/Kwin on Wayland has made huge progress, but there are still pieces to fall in place and features to be implemented and rough edges to be polished. This certainly was one of the most interesting news from KDE world during Akademy.

I managed to pester Jan Grulich enough to implement the missing network traffic plotter in Plasma Network Manager. He had a prototype in his local branch, but adding the dynamically adapting transfer rate on Y-axis needed more work on the Plotter plasma component. We continued working and testing in the next days.

I missed Dan Vratil’s sandboxing applications talk. But then attended the talk in which Dan Vratil introduced KAsync, an asynchronous event library and its syntax. And then the talk on HiDPI applications by David Edmundson explaining Plasma’s own pixel scaling technique before Qt had the capability and once Qt has, how to not rely on the QT_DEVICE_PIXEL_RATIO.

The day ended with presenting this year’s Akademy awards – Milian Wolf for best application (KDevelop), Jen Reuterberg and VDG team for best non-application, Scarlett Clark for CI/Jenkins and Albert Vacca for kdeconnect.


A bunch of us went to La Coruña city center for dinner, and I found out that Mexican tortilla (the flat bread) and Spanish tortilla (with potato and egg) are two entirely different items; Kai Uwe learned the same at greater expense of nearly starving. But we all had a good laugh at Kai’s expense 😉

Day 3:

From day 3 onward, it was all about BoF sessions, hacking together, fixing things, implementing new features. I started to fix a long standing annoyance with KCharSelect on displaying characters with large width (such as South Asian scripts), turned out to be trickier than I thought. Later in the night I found the fix committed introduced a regression, planned to consult with David Faure next day.

Attended the “Plasma BoF”. Then attended “VDG BoF”, helped fixing Thomas Pfieffer’s Plasma5 installation and grub. Identified a password entry focus issue with plasma-nm on connecting to a new wifi when Thomas tried to do that; later talked to Jan and he fixed the issue in 2 minutes.

VDG team asked people from different ethnicity to pop in during BoF to make new KDE avatars. Jens Reuterberg took my picture and he is making a KDE avatar out of me 😉

Day 4:

Attended “Wayland BoF” conducted by Martin Gräßlin.

Continuing with investigating the KCharSelect regression, I was lucky to work with David Faure properly fixing KCharSelect both in kdelibs and in KWidgetAddons framework. We then noticed further issues with KF5 based KCharSelect, investigated and unearthed a Qt4→Qt5 QChar enum issue. More on that in another blog post.

“Solid BoF”. Few people turned up for the Solid discussion, we discussed the general status in hardware support and later Lamarque Souza handed over the maintainership of Plasma Network Manager to Jan Grulich.

Day 5:

Dan Vratil organized the “Containers and Application Sandboxing” BoF. He explained how to define and build runtimes and KDE applications in Fedora using xdg-app. Scarlett Clark’s continuous integration and Phabricator session followed, and Release team BoF afterwards.

I started testing the new plasma-volume-control (later renamed to plasma-pa [pulseaudio]). Built F22 rpms in Copr, F23 has copr build issues. Found a bunch of issues, fixed many of them and David Edmundson reviewed the on the spot which I committed in the repo. Reported rest of the issues to him and left them in his custody 😉

Missed Valentin Rusu’s talk “Going from graphical dev tools to VIM”.

We then took the day trip to Tower of Hercules and the Aquarium. Climbed up the tower and enjoyed the beautiful view of the sea. Dinner later at a small but expensive restaurant with delicious food – especially fish. I did immaculate pronunciation of an Italian tongue twister, earning high-fives from Marco Martin and Riccardo Iaconelli.

Day 6:

Fixed the mute volume and volume slider issues with plasma-volume-control. Talked to Andrew Lake about a plasma “welcome” screen. Worked with Kai Uwe on improving the Notes taking applet.

To compensate the missed session on vim editor by Valentin Rusu, he gave us an overview again at the hacking area. Amazed to see his vim setup – a full fledged IDE, and he showed many cool tricks using vim and i3 window manager. Even firefox is configured to have vim shortcuts.

Signed the FLA with KDE e.V.

Later in the day went for swimming after many years, which turned out to be harder than I expected.

Day 7:

Flew back to Brussels.

Overall, I met a lot of wonderful people who I am happy to make acquaintance of. I learned many things, contributed a few patches,  fixed some bugs and enjoyed the great atmosphere where people come together, exchange ideas, build new things, fix problems, evolve visions and immerse themselves in creativity.

Thanks a tonne to KDE e.V for sponsoring my attendance. A huge thanks to the organizers, GPUL and Rialta for excellent organization, coordination and facilities.