Thoughts, stories and ideas.

FFMPEG: Combine videos and re-encode

Over the past few weeks, I've taken to recording my Squash games using my Gopro to understand areas of improvement. The video is recorded at 1080p and 60fps, however Gopro splits the video into several large sized mp4 files.

I wanted to combine them together into a single file and re-encoded to reduce the file size significantly and ffmpeg came to rescue.

Combine Files

First order is to combine the files. ffmpeg accepts input text file with each line consisting of the object type ( file  in this case) and the file name. Alternatively it also accepts http and a url as a line item as well.

$ ls *.MP4 | perl -ne 'print "file $_"' > input.txt
$ cat input.txt 
file GOPR4466.MP4
file GP014466.MP4


To reduce file size one can do several things. The easiest is to set the crf flag which indicates "Constant Rate Factor" or the quality of encoding with values ranging from 0 to 51.  0 indicates lossless encoding and 51 the opposite. The default value is 23

$ ffmpeg -f concat -i input.txt -c:v libx264 -crf 28 output.txt


$ ls *.MP4 | perl -ne 'print "file $_"' | ffmpeg -safe 0 -protocol_whitelist "file,pipe" -crf 28 -f concat -i - output.mp4

Books in 2018

Similar to 2016 and 2017, I spent a lot of time reading books. Original goal was to read at least 25, but I managed to read only 24. However, I attribute it to spending a lot time reading genres that were outside my comfort zone, such as philosophy and biographies.

Here is a small collage I built with a python script, of all the titles I managed to read.


1. A Thousand Splendid Suns

Hosseini, Khaled

This was by far my favourite in the entire year. The story was beautiful, heart wrenching & soul crushing tragedy. The collateral damage from the wars fought in the name of proving oneself or beliefs better than others, seemed not very far from reality at all.

The book was as evocative as this other book "The Ministry of Utmost Happiness" by Arundhati Roy. They certainly seemed to exist in the same realistic universe.

2. The Moon Is a Harsh Mistress

Heinlein, Robert A.

I ended the year with a quick blaze through the book. And it read like an action movie which you know is terrible but you watch anyway because its fun.

3. Harry Potter and the Cursed Child: Parts One and Two (Harry Potter, #8)

Tiffany, John

Just 6 years ago, I read the Harry Potter for the first time. It was incredibly enjoyable, nostalgia inducing journey to revisit the universe again, despite the book not entirely living up to the hype of the original series.

4. Space Team (Space Team, #1)

Hutchison, Barry J.

5. Use of Weapons

Banks, Iain M.

6. Stories of Your Life and Others

Chiang, Ted

The change of title of the book to "The Arrival", after a short story became a movie, deceived me into purchasing this. I was throughly confused while I went through the first short about the tower of babylon as I wondered how it related to space and aliens.

7. Killing Floor (Jack Reacher, #1)

Child, Lee

8. Artemis

Weir, Andy


1. Adulthood Is a Myth (Sarah's Scribbles, #1)

Andersen, Sarah

2. Hyperbole and a Half: Unfortunate Situations, Flawed Coping Mechanisms, Mayhem, and Other Things That Happened

Brosh, Allie


1. Mr. Nice

Marks, Howard

2. Alibaba: The House That Jack Ma Built

Clark, Duncan

3. Believe Me: A Memoir of Love, Death, and Jazz Chickens

Izzard, Eddie

4. The Spy Who Came in from the Cold

le Carré, John

5. Kitchen Confidential: Adventures in the Culinary Underbelly

Bourdain, Anthony


1. Zen and the Art of Motorcycle Maintenance: An Inquiry Into Values

Pirsig, Robert M.

2. How to Break Up with Your Phone: The 30-Day Plan to Take Back Your Life

Price, Catherine

3. How to Walk (Mindfulness Essentials, #4)

Nhất Hạnh, Thích

4. The Hidden Pleasures of Life: A New Way of Remembering the Past and Imagining the Future

Zeldin, Theodore


1. A Burglar's Guide to the City

Manaugh, Geoff

2. You Are Not So Smart:

Why You Have Too Many Friends on Facebook, Why Your Memory Is Mostly Fiction, and 46 Other Ways You're Deluding Yourself
McRaney, David

Gladwell, Malcolm

4. Good to Great: Why Some Companies Make the Leap... and Others Don't

Collins, James C.

5. How to Talk to Anyone: 92 Little Tricks for Big Success in Relationships

Lowndes, Leil

Python Deployments Wishlist

Am currently faced with a baffling realisation of the reality that there is no one sane way to deploy python applications.

It's utterly annoying that I cannot just tar a virtual env and use it.
Performing pip install on every deploy is plain ridiculous. Downloading from the internet on every code change with separate virtualenv is a nogo. No RPMs, nope, no way am writing another spec file.


  • Deployment tooling that allows me to go from zero to production with a new application with no setup.
  • No-downtime between deployments (has to work with a single instance)
  • Philosophy of implementations should make sense whether deploying to one or a 100 servers.
  • Controlled activation of the new version of software i.e. traffic shifting.
  • Stable re-producible environment setup everytime (perhaps with ansible).
  • Cli that lets you bootstrap, build, deploy and control activation of software (nginx or via LB).

Am starting to hack a prototype with fabric, python and Ansible, which is already proving to be challenging but looks doable.

Bug in my code and Ballet

... of sorts, or more accurately barre.

I use a service called Onefit in the Netherlands which lets me register for group lessons or use a gym in a bunch of places (limit is four times a month). I used it for joining yoga classes sometime back. Apparently its quite popular with locals here and so I have a hard time finding a spot. So like any sensible person, I tried to automate it. I wrote a python script that would run in the background and try to find me a spot when someone cancels their's (and people do cancel as there is a no-show fee). Lo and behold the script alerts me, and I immediately sign up. Now am feeling excited that I am the smartest person around to do such a thing.

The day of the supposed yoga class, am all pumped up to be going back after 2-3 months. I get to the venue on time and tell the person at the reception that I am here for the yoga class. One of the persons sitting there was the instructor, and she thought I was confused, so she mentioned there is no yoga class for another hour. I tell her, no, look and show her the confirmation on my phone (there is a location-based check-in), and she went "yeah no, its a 'Barre' class" which is a Ballet style workout.

Now am visibly shaken, my mind wanders away, slowly, mentally debugging the code that I refactored day earlier, as to what just happened, all the while still blankly looking at that lady. It turns out I applied filters for location type, time but not for the class type. Neither during my testing did I realise that they were offering more variety of classes from the last time I tried months earlier, nor when I was pressing the "book" button. I can at this point see the code and what the error was.

What do I do now?

It is too late. I had to do something, either go forward or back home. One on hand I begin to wonder if will I be charged a cancellation fee? On the other hand, I asked myself, would I have ever tried this by my own volition? The cancellation fee of €10 would be a blow to my ego that thought it could automate itself out to glory.

So, I went in. Yes. It happened.

Boy oh boy, what an experience it was. I was the only guy and a chubby human in the entire class, full of women in shape and active. Halfway through, am sweating, panting, full of feeling that I can collapse any moment. I keep going, and then I could no more and had to take a timeout. And all throughout, everyone was going through the motions of the class without breaking a sweat, like it was some fucking music video. What the hell.

Usually when I play sports, its the next day I feel it. No sooner than the class ended, I could feel my body telling me what a dumb idea that was.

And gents, that's how I ended up trying ballet workout, all due to a bug.
So, remember the lesson kids, test your code :)

PS: Now this made me wonder about something a friend said a long back, during one of our conversations about "anti-search" search engines, which recommend something that you wouldn't usually try, either a thing or a place, a sight or an experience. While I have tried random things in the past, if not for this "bug", don't' think I would have intentionally tried to go check this one out. Serendipity can be a good thing, and I wish this world facilitated more of it.


Ever since we are born into this world, our lives begin by being cared by others. We grow to realise, implicitly that people are essential. How could we comprehend any other possibility?

So we try to be friendly, often more than that is necessary or possible to be reciprocated as humans are different. Why do it then? Because it's convenient to think, to have more friends is to share good times with many, thereby meaning more happiness.

The danger of it is letting toxic people in. They will come, eventually. They always do. The trick is to recognise who are the ones causing the sort of drama which leaves you not feeling at the top of the world.

People who cause drama, need to be weeded out, ruthlessly. Those blissfully unaware of the damage it does to those around may perhaps deserve the benefit of a doubt, once. But just once. Life is too short to try to be nice towards those adding misery.

Having fewer friends who are more thoughtful and caring is not only energising, but also adds an immense amount of meaning to life. The value of a meaningful relationship is unmatched against a thousand casual friendships or a hundred one night stands.