Tag Archives: Featured

How To Create and Embed Subtitles – Or – How to spend half of a weekend to help a friend

A friend of mine asked me to help him with a presentation,
Part of the presentation includes several movies – you know the fast paced movies you see in Youtube? Where there is  a narrator and it’s like he draw the lecture on the board? Just like that.
Now my friend uses these but not all of his designated audiences knows English that well, so he requested of me a help with embedding subtitles (So the video will have subtitles no matter where it is showed)

Now in the past I used to translate existing subtitles to my native language of Hebrew, But that was only to take existing subtitles and translating them – which is not that hard.
In this situation I had 2 new issues to address – how to create the subs themselves and how to embed them into the video (which learning how to actually took me longer then translating and creating a subtitle to one video)

Create Subtitles

Note: This is a very simple explanation – I’m not very fluent in this software and I use it very basically – so don’t expect advance explanations and changes to existing subtitles.

Download and Install aegisub – This is a simple and open source version to create subtitles.

After starting it up you will see a bit confusing array of options, don’t worry – although this software can do much I used it in very minimal fashion and so can you.

The window combine 3 main sections:

  • On the upper left – where you can watch the video with the created subtitles.
  • On the upper right – where you can create new subtitles sections based on the sound
  • On the bottom – where you see and select all your subtitles.

The first thing you need to do is to open a video you want to create translation to:

After opening the video you will get to the working environment where you can add new lines of subtitles:

From here the job is easy (though tedious):

  • Run “Play Section” in the audio section
  • See if the section is ok for you – if not use the bars in the sound section (the red and blue bars) to adjust the section you want the subtitle in.
  • When you are satisfied with the timing enter the text in the box (use shift+enter for a new line) and in the end finish this line by pressing:
  • This will create a new line following the existing one – and that’s it.
  • This is a simple way to create some subtitles for your videos
  • Don’t forget to save your project (in ass format) – You can export it in srt format if needed.
Simple Example:

Although this is a very basic way to do it this suffice me for what my friend wanted help with.

I might play with this software (aegisub) a bit more to be able to change and update subtitles (and also add neat features for the subtitles)

The plot thickens

When I’ve finished creating the subtitles for one of the videos I’ve sent it to my friend and asked him to test it. However I got a message from him telling me that the subtitles don’t show. Apparently his pc doesn’t have VLC installed. Not only that, when he will add the videos to the presentation it won’t work (because the player of the presentation software might not support ass format subtitles.

So how can we make sure the subtitles work?

Well the easy method is just add them to a container – for example change the movie from AVI or MP4 format to the MKV format – one that can have the subtitles inside (support multi subtitles and audio to be encased in one file). Although I think this is the best method of work I can’t be sure the person on the other end using this video/player/presentation will know how to operate it so this option is invalid.

So now I need to embed the subtitles directly to video, fine let’s just use what I always use: ffmpeg.
I thought this will be easy – ffmpeg is widely used and I’ve used it many times to create several encoding encase audio into videos and more. Alas for unknown reason trying to embed a Hebrew srt/ass file to the video did not succeed.
So what to do now? Well I’ve found a simple yet effective software to achieve what I needed: VidCoder

Embed the subtitles with the videos

Download VidCoder.

  • Run the software (VidCoder).
  • Select file to encode
  • Edit the subtitles
    • Import .srt file (aegisub can export to srt format)
    • Select:
      • Burn In
      • Language
      • Encoding
    • Press OK
  • Select your destination.
  • Add to Queue
  • And just encode!
Simple Example:

Appendix: How to make ffmpeg work!

Well after writing all of this (and it is working fine) I was annoyed – Well I’m an IT guy – fuck this I’m gonna solve the ffmpeg issue!

So I sat down and tried to understand why the encoding didn’t work.

Took me a while to understand that due to the fact that the font config was not there it didn’t manage to set the subtitles (although it didn’t need it when tried using encapsulating the subtitles in the format).

So what helped me? This guy: https://github.com/FiveYellowMice/how-to-convert-videos-with-ffmpeg-zh/tree/master/etc/fontconfig-windows

I basically downloaded his fonts.conf put it in the ffmpeg folder and then added it to the environment:

After that I only needed to encode (Linux example can be found here: https://wiki.archlinux.org/index.php/Font_configuration#Example_fontconfig_configurations or https://www.freedesktop.org/software/fontconfig/fontconfig-user.html)

Now you only need to use ffmpeg to convert your video!
Now there are many examples exist on the web on how to do that but I will provide a small examples here.

Attach Subtitles to Container

MP4:

1
2
3
ffmpeg -i input.mp4 -f srt -i input.srt \
-map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \
-c:s mov_text output.mp4

Unfortunately this method missing the “Default” parameter which mean the you need to select the subtitle manually instead of a default subtitle showing up.

MKV (without default subtitle):

1
2
3
ffmpeg -i input.mp4 -f srt -i input.srt \
-map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \
-c:s mov_text output.mp4

MKV (with default subtitle):

1
2
3
4
ffmpeg -i input.mp4 -f srt -i input.srt \
-map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \
-c:s srt -metadata:s:s:0 language=LANGUAGE -disposition:s:s:0 default \
output.mkv

(example: ffmpeg -i gaga.mp4 -f srt -i gaga.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt -metadata:s:s:0 language=Hebrew -disposition:s:s:0 default Test2.mkv)

Sources:

Embed (Burn) Subtitles to the Video

ffmpeg -i video.avi -vf subtitles=subtitle.srt out.mp4

Source: https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo

MySQL Why Won’t you Dump already!

Few weeks ago I started up a project migrating a development mysql to the production environment.

Doing this change included a lot of tests and updates I wanted to do for a long time.
The short story is that I migrated user defined mysql data (permissions and triggers was vetted before) to Master Slave on docker images and a different user with the entire environment configured via Ansible (yes yes I went overboard with the design – but hey, now I have all the templates I need and every docker and mysql needs and documentation and all orchestrated by ansible)

I’ve needed to create a special docker image for MySQL 5.1 for this project – I will post a followup post with the information about the docker

After all the hard work preparation etc I was ready to do the migration! Finally! I’ve dumped the data, Upload it to the new Master and Slave, Changed the users (Create new Delete the old ones),  sync everything and set the backup.

The next day I woke up and checked the backup and found it didn’t work, I was not in a good mood – the backup failed… Continue reading MySQL Why Won’t you Dump already!

SELinux – Why I need it and why is it still on??

If you know CentOS or Redhat you probably familiar with SELinux.
For me the history with SELinux is simple – I know about it – I always disable it – and that’s it.
As probably most of you know there is abundant of explanations on the web on how to disable/enable/configure the selinux – So I won’t hassle you with the information.

However I would like to share a fun story about one of the engineers that tried to disable the feature to activate something and was wondering why the selinux keep starting up when he reboot the server.

In my environments for the past few years I disable the selinux via the pxe+kickstart installation or ansible, but now some of our engineers started sprouting their own centos servers in AWS for testing – and they started having several issues with configuration, Continue reading SELinux – Why I need it and why is it still on??

How much power my PC actually take – or – Why My Electricity Bill is so HUGE??

Like most people living in this new era my house have a large amount of electronics devices and as an IT guy I have about 5 computers (Laptops, PC etc) and 3 mobile devices.

I want to  tell you about one device particularly – my main home server. Few years ago I bought a small server called HP Microserver – low utilization and effective as basic linux server along side a good storage server (with raid).
Like most of my computer geek friends this PC was turned on day in and day out – just like every other PC I had before I just left it on – and it didn’t matter if it actually did something or not (and yes it did nothing most of the time).

A few months ago the little server went down and wouldn’t come out. When I’ve looked into it I’ve found out that it’s Power Supply was down.
And it took me about 3 months to fix that, why? Due to the fact that this Power Supply Unit was a unique one. It fitted directly inside it’s small case and was only 120W so it was not only less costly electricity wise it was also extremely expensive.

After 3 months I’ve found a cheap solution using a regular Power Supply (the 450W very cheap ones) with some of my modification.
But what I found in these 3 months was even more interesting: Continue reading How much power my PC actually take – or – Why My Electricity Bill is so HUGE??

24 Hours with my Healbe Gobe

About 2 Years ago I was really into Kickstarer/Indiegogo – I supported several projects (mostly comics or gadgets) some came threw (Makey Makey) some did not (Ringbow).
At one day I’ve found an interesting in Indiegogo called Healbe GoBe which was described as “The Only Way to Automatically Measure Calorie Intake” – That sound too good to be true! But alas I’ve decided to support and try to get my hand on the device and ordered it.

Now a year and a half after the promised delivery date I finally got the device – and have been wearing it for the past 24 hours.
then how is it? lets find out:

Continue reading 24 Hours with my Healbe Gobe

Cozi – Arrange your family and household tasks and lists

As a very busy person I handle a lot of task lists.
For example:

  • Home tasks: I set the grocery lists on my refrigerator.
  • Personal Tasks: I handle immediate tasks with Any.Do and long term tasks with Evernote (Mainly lists of what to watch and play).
  • At work: I use notebook for immediate tasks (nothing is better then marking out done task by crossing it with a pen), using  Jira to manage my work tasks and Wrike to manage large scale projects.

So you see I use a lot of different software and ways to manage my tasks. I believe that most of you (mainly the people who are short in time) find your own way to handle the tasks. Continue reading Cozi – Arrange your family and household tasks and lists

The Curious Case of Missing Quota Report on Volume

A week ago one of my old colleagues ask some help with an error he has on one of his servers, I was happy to oblige.

He had several servers all working exactly the same, same hardware, same OS and same configuration (apart from IP’s).
One of his server crashed and after the reboot one of his batch scripts stopped working specifically on this server.
The script tried to determind if a specific volume (for example: /mnt/volA) exist and have enougth free space,
This he did by invoking the “df” command and the “quota” command (Or their equivalent in the specific language).

What he found was:
While running: “df -k /mnt/volA” he got the correct line and response,
But on the other hand when he tried to run “quota -v |grep “/mnt/volA” the quota command didn’t return the volume.
This was particulary wierd because this volume was NFS volume with specified quota (set on the NFS server) – moreover the volume did apeer on the other servers when you looked for it when you’ve used “quota” Continue reading The Curious Case of Missing Quota Report on Volume

Google Drive – Where all my free space gone?

Few years ago after several critical storage catastrophes (that fortunately ended with no data lost) I’ve decides to move my most important files to the cloud (mainly my and my family photos)

After checking several cloud storage providers I’ve decided on Google (back then I think drive was non existent or at beta) to backup all my pictures to Picasa.
The plan was very good: Legacy Plan 80G for 20$ a year – for something with the features of the drive and more this price is very good.
After Google Drive was working on my desktop I’ve deserted Picasa as my photos backup and just save the directory to my Google Drive (I like to sort things my own way).

A few days ago I’ve added bunch of files to my drive and got an error: The space almost run out!
I was puzzled why no storage available – my drive isn’t 80G nor my mail or Picasa should be large enough.

Continue reading Google Drive – Where all my free space gone?

The Curious of the missing LDAP Groups Issue with new groups in LDAP

LDAP is a wonderful way to handle all your company employees users. I’ve been using it for a long time and just like the easy way to handle it and how users can be authenticated via the LDAP directory all threw our intranet sites (Ticket manager, Wiki, Tools and more).

A month ago I had a new project – simple and easy to create some directories for group of users and give some full permissions and some only read permissions.

Due to the nature of linux that was quite easy – Just create a new group (or several) to encapsulate the users and allow the permissions to the directories. For example:
1. Group: project-users       – All the users who will need to access the data for this project will be added to this group.
2. User: project-admin – This is the user that can handle the directories (add, remove etc).
2. Group: project-admins    – The only group that can access the project-admin users. I’ve added only selected users to this group. (The permissions to access the users is auto generated authorized_keys access)
Now let’s say that our directory is:
/opt/projects/project (User: project-admin, Group: project-users, Mode: rwxr-r—)

Now as you can see only the admin user can change the files but all the group can access.

Continue reading The Curious of the missing LDAP Groups Issue with new groups in LDAP

Apache HTTPD config check – Or – Check that damm engine before I try to fly this bird!

Although large amount of alternative web servers a lot of the web services out there still use Apache httpd software.

I will not go into why choose Apache httpd and how, but I like to share a  small issue I had with configuration check of my service.

As IT personnel who worked in a production environment I’ve learned the best practice of any configuration change is check your configuration before reloading/restarting the service.

Now Apache httpd configuration check is easy:

1
2
3
# apachectrl configtest
---- or ----
# apachectrl -t

Now – What about when you have multiple apache httpd instances running on the same server?
Every one of them running with it’s own configuration file.
How would you test them?

The solution should have been simple enough – just direct the check for the configuration file!
The issue with that is the relative selection of file won’t work.
Lets see a small example:

1
2
3
4
5
6
---- Following test will result in checking of /etc/httpd/conf/httpd.conf instead of what you wanted ----
/etc/httpd-site/# apachectrl -t -f conf/httpd.conf
Syntax OK
---- Following test will fail because he is looking for /etc/http/../conf/httpd.conf ----
/etc/httpd-site/conf.d/# apachectrl -t -f ../conf/httpd.conf
httpd: Could not open configuration file /etc/conf/httpd.conf: No such file or directory

So how can you fix that?

1
2
3
4
5
6
---- Use full path ----
/etc/httpd-site/# apachectrl -t -f /etc/httpd-site/conf/httpd.conf
Syntax OK
---- Set the work dir for the relative search ----
/etc/httpd-site/# apachectrl -t -d /etc/httpd-site -f conf/httpd.conf
Syntax OK

Easy and simple.