2015-09-30

HOWTO: get rid of packed B-frames in AVI (MPEG-4 Visual) video with FFmpeg

You've probably seen some AVI (Audio Video Interleave) files with MPEG-4 video (more specifically, MPEG-4 Visual / ASP, usually encoded by DivX or Xvid codecs) inside; they are often used for DVD-rips. Such AVI video files often contain "packed B-frames", which is not an optimal frame storage way, but just a workaround for the VfW (Video for Windows) framework shortcomings (i. e., bugs).
To ensure you have a "bad-style" MPEG-4 AVI file, you can check it with a media analyzer utility like MediaInfo (in this case, it'll show you something like "Muxing mode : Packed bitstream").
Fortunately, that wrong thing is easy to "unpack" with an up-to date version of FFmpeg (v2.7+):
$ ffmpeg -i in_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes out_good.avi
The conversion is lossless (neither video nor audio quality is harmed; the file should remain compatible with the hardware players... or even become more compatible), but often can even reduce the resulting AVI container size.

BTW, after "bitstream unpacking", the MPEG-4 video stream becomes standards-compliant, so you can put it directly into the popular MP4 container without transcoding (but it requires the audio stream to be MP4-compatible too, e. g. MP3 is OK);
e. g., here are 2.5 3 remuxing examples using the same FFmpeg:
$ ffmpeg -i in10_good.avi -codec copy out10_good.mp4
$ ffmpeg -i in20_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes out20_better.mp4
$ ffmpeg -i in20_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes -movflags faststart out25_best.mp4

You can download the source code and binary builds of the current FFmpeg (for MS Windows, Apple Mac OS X and Linux) freely from the official site.
Usually, you will find a compatible version in the repositories of your favorite Linux distribution;
however, in Debian, it's available only starting from the release 9 "Stretch" (and fortunately, it's currently in the backports for 8 "Jessie" too; and for use in Ubuntu, you need release 15.10 "Wily Werewolf", at least):
# sudo apt-get install ffmpeg

References:
  1. FFmpeg
    1. FFmpeg Bitstream Filters Documentation
    2. Download FFmpeg
    3. FFmpeg Changelog
    4. #2913 (Bitstream filter to fix "invalid and inefficient vfw-avi packed B frames") – FFmpeg
  2. MediaInfo
  3. Debian Package Tracker - ffmpeg
  4. ffmpeg package : Ubuntu
  5. Wikipedia
    1. Ripping
    2. MPEG-4 Part 2
    3. DivX
    4. Xvid
    5. Audio Video Interleave
    6. Video for Windows
    7. Video compression picture types
    8. Inter frame
---
Last updated: 2017-12-28

2015-08-31

Tips: where to find the photos in your Google account

You can try to find your photos in different "departments" of your Google account:

And don't forget about the trash folder(s):

---
Last updated: 2018-03-01

2015-08-01

Overview: barcode reading software in Linux

Tested in Debian Jessie:
# apt-get install dmtx-utils zbar-tools

2015-07-31

Tip: where to get the periodic table of the chemical elements

My favorite official source to download printable copies of the periodic table of the chemical elements (also known in the post-USSR countries as the Mendeleev's table) is IUPAC (the International Union of Pure and Applied Chemistry):
(Currently, the table on the IUPAC site dates back to 2016-11-28).
---
Last updated: 2017-02-11

HOWTO: the poor man's random number generator

Spoiler: the described binary random number generator (RNG) usually doesn't consume any electricity, but still definitely needs a minimal investment :-)