Showing posts with label Data Conversion. Show all posts
Showing posts with label Data Conversion. Show all posts

Thursday, 6 August 2020

PDF Editors For Linux

This post is brought to you by the new Blogger interface Google has forced on everyone! Which is dreadful! The only way I keep my sanity editing posts on Blogger is to create the post in a separate editor (LibreOffice Writer in this case) and then paste the completed article into Blogger. There is much angst in the Blogger users’ community over the broken functionality in the new interface and the fact it has been forced into use with what they believe to be insufficient testing. My experiences with it exemplify those experiences, but this is the only one of my regular blogs that is still hosted on Blogger, and the workarounds for me are sufficient until such time as they fix all the bugs.


Today’s post is about editing a PDF using free/open source software. The PDF format as we are generally aware has historically been an Adobe thing, and so has the main editor software package. Everyone knows and uses Adobe Reader on various platforms, but relatively few people use Acrobat, the expensive commercial package that can edit PDF documents. Hence, a few alternative solutions have been developed, and the abilities of these are improving all the time. Here are my takes on a few of them.


My particular requirement here is filling out a PDF form and inserting my signature. It’s fine to be able to fill out the form in Okular (KDE’s in house PDF viewer) but inserting a graphic is impossible. So I looked at some of these alternatives:


LibreOffice Draw is part of the LibreOffice suite and can read and edit PDFs as files made up of individual elements. In my brief examination of Draw, the main concern I had was that it would be able to output the document looking like the original after editing; it seemed to have difficulty converting all of the text to typefaces that would fit cleanly into the original format. Because of this, I have not explored Draw further for my particular requirement at this stage.


Inkscape is a well known graphics editor that has a lot of features and is one of a few favourite graphical editors I have installed on my computer. I haven’t looked very deeply into its capabilities because the major limitation I have observed so far is that it can only handle a single page PDF; there is no obvious way of working with multi page documents.


Most of the full editors that are available are paid only. PDFSam and MS Word 2019 are examples that are Windows only. I have no desire at all to spend money on any type of Windows computer, or even a virtual machine, just to run these solutions. PDFstudio is an alternative that is available on Linux. The Pro edition that is capable of PDF editing costs $129 to buy and is licensed for 2 computers. It would be interesting to evaluiate this product at some stage to see if it is worth purchasing in future. Master PDF Editor is another product I might evaluate, it just puts a watermark on each page but it might be possible to remove that with one of the free editors.


Scribus is a FOSS desktop publishing package that also can open PDF files. Version 1.5 which is currently a development edition and only supported on most distros as an AppImage. I found however it has the same issue as some other packages of being unable to render fonts in the previously filled out PDF form.


Ultimately for this particular situation, needing a quick and easy solution to create my PDF and get it useful for my requirement, I have used Gimp which will import each page as either a layer or a separate image according to a selection choice when opening the document. It imports the pages as graphics, but you can fill in a form in something like Okular, save it to a new document, and then inserting a signature as a graphic can be done in Gimp, then export each image to a new file and paste them into a new document and export it back to PDF. A complex process for just one form but it lets me send my document completely filled out complete with signature because Okular cannot do the insertion of a graphic into the appropriate place on a PDF. I think this Gimp solution will be the best short term but I will still be interested in evaluating other possibilities in future.

Wednesday, 23 January 2019

Python Scripting [2A]; Syncing a video and music directory tree

Having completed our first scripting task involved XML extraction and copying files, the next task to be scripted in Python will be the process of extracting audio from our collection of music video tracks and syncing it into a directory tree.

The actual steps needed are:
  1. Compare two directory tree, one for video and one for music
  2. Where a music track is missing, extract the audio from a video clip in the video directory tree and save it into the music directory tree.
So it can be described in a couple of steps but the breakdown of tasks may be a little more complex.

The task involves calling ffmpeg to perform the audio extraction and the parameters may vary depending on the type of source file.  

So we will see how things proceed on this one.

Sunday, 6 May 2018

Free Linux video editors

Well when I rip my DVDs with a software program and the music all comes out on my computer as one file then I need to split that file into tracks and I need a simple editor to do that.

Avidemux is good except for this one time where I have a file that is 1 hour 50 seconds long and for some reason the program says it is only 36 minutes long so I was not going to be able to work on all the tracks. So I had a look at some other programs. VidCutter looked good but it's useless when it comes to save the clips because it seems they all save to one file and it wouldn't save anything. LosslessCut looked good too but couldn't cope with the size of the track. I have had Pitivi and haven't tried it this time, in the past it wasn't very stable.

So I ended up just using VidCutter to mark the start and end points of each track then I worked out how to feed the numbers into ffmpeg command line to extract and convert the video. When you look at this you realise Avidemux is just a front end for ffmpeg.

Here is a typical command line for one of the tracks

  • ffmpeg -ss '00:19:15.888' -t '00:05:36.035' -i VTS_02_1.VOB -b 2M -acodec mp3 -vcodec mpeg4 afl05.mkv

    The parameters are:
    • -ss tells it to seek to a position on the input track
    • -t tells it the duration you want to extract
    • -i tells it the input file name
    • -b tells it the bit rate to use
    • -acodec is the audio codec to convert to, in this case mpeg 3
    • -vcodec is the video codec to convert to, mpeg 4 in this case
    • the last parameter is the destination file name and with the mkv extension it can work out how to package the clip into a Matroska container.
So I was able to extract all of the clips the same way and everything came out well.

Thursday, 29 March 2018

Scripts to extract audio from video clips or convert other audio formats to mp3

This is a great thing because I can put all these MP3 clips onto my phone and play this music wherever I go.


find . -type f -name "*.mkv" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -c:a libmp3lame -y "${FILE%.mkv}.mp3";' _ '{}' \;
The script goes through the current folder and all subfolders to find mkv files and extract the audio from them and save it into a mp3 file.

You can change the extensions in two places to find other types of video to extract from (it works with mp4 as well).

I set the MP3 tags with Puddletag but I found my Windows phone will not recognise m4a and wma files so the next step needed is to batch these files out to mp3 using ffmpeg.

Here is a script I tried to convert the wma files:

find . -iname "*.wma" -execdir bash -c 'NAME="{}" && ffmpeg -y -i "$NAME" -ab 192k "${NAME/.wma/.mp3}" ' \;
This does the trick with the wma files, producing mp3 files in the same directory as the original. The wma files were then backed up to another computer so that the media computer only has the mp3 files. 

Apart from whichever format the phone can read, Groove music player appears to suffer from the same technical limitation as Windows Media Player, in that the ID3 tags have to be just so right in order for it to properly classify music by albums and artists. Apparently if your tags do not set a genre it will just ignore the rest of the tags and classify the track as "Unknown Album" and "Unknown Artist" even though these tags are set to specific album and artist. So I have spent quite a bit of time playing with the tags to try to get Groove to recognise them and have managed to get it to finally start recognising all the albums I am trying to load onto it, which is a lot.