Why nm-applet does not show up...

When search online for answers on how the Network Manager doesn't show up in the GNOME notification area one find hundreds of confused forum posts (mostly Ubuntu).

There are only two reasons:

  1. Your Network Manager setup is somehow broken
  2. There is no network device to manage

The second case is propably going on in most of the cases. When you check your /etc/network/interfaces and see something like:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

... it cannot work, as Network Manager to manage your connections it needs to look like:

auto lo
iface lo inet loopback

Restart Network Manager (e.g. "/etc/init.d/network-manager restart") for the nm-applet icon to show up.

pgbouncer "Pooler Error: Auth failed"

If connections to your pgbouncer setup fail with "Pooler Error: Auth failed" check the following configuration values in your pgbouncer.ini

  • auth_file = ... : Ensure to point this path to your pg_auth file in your Postgres setup.
  • auth_type = ... : Ensure to set the correct authentication type. E.g. "md5" for MD5 hashed passwords.
  • Check if your pg_auth file has the needed passwords entries.

libfaac 1.28 compilation fails with: mpeg4ip.h:126:58: error: new declaration ‘char* strcasestr(const char*, const char*)’

When compiling libfaac with GCC you get:

g++ -DHAVE_CONFIG_H -I. -I../.. -I../../include -Wall -g -O2 -MT 3gp.o -MD -MP -MF .deps/3gp.Tpo -c -o 3gp.o 3gp.cpp
In file included from mp4common.h:29:0,
from 3gp.cpp:28:
mpeg4ip.h:126:58: error: new declaration ‘char* strcasestr(const char*, const char*)’
/usr/include/string.h:369:28: error: ambiguates old declaration ‘const char* strcasestr(const char*, const char*)’
make[3]: *** [3gp.o] Error 1

Solution is to remove the declaration of strcasestr() in commom/mp4v2/mpeg4ip.h (suggested here).

ffmpeg AAC "Can not resample 6 channels..."

When you try to encode with ffmpeg and you end up with such an error

Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 6 channels @ 48000

you are probably trying to encode from AAC with 5.1 audio to less than 6 channels or different audio sampling rate.

There are three solutions:

  1. As a solution either do not reduce the audio channels and change the audio sampling rate or do convert the audio with faad first.
  2. Apply one of the available ffmpeg patches to fix the AAC 6 channel issue...
  3. Split video and audio and convert audio separately.

The third solution can be done as following:

  1. Extract audio with ffmpeg:
    ffmpeg -y -i source.avi -acodec copy source.6.aac
  2. Convert audio with faad:
    faad -d -o source.2.pcm source.6.aac
  3. Merge video and audio again with ffmpeg:
    ffmpeg -y -i source.avi -i source.2.pcm -map 0:0 -map 1:0 -vcodec copy -acodec copy output.avi

Update: As hinted by a fellow commentter the big disadvantage is the quality loss as faad can only convert into PCM 16bit.

Fix Broken Text Encoding

You have a text file with broken encoding? You want to strip it from all invalid characters?

Here is how to do it:

iconv -c -t ASCII input.txt

The result will be printed to stdout. The -c switch does the stripping. Using -t you can select every target encoding you like.

Shell ANSI Color Matrix

The following script will dump a ANSI color matrix that allows you to easily choose colours. I ripped this off somewhere, just forgot where... This post is for conservation only. Don't read it!


T='gYw'   # The test text

echo -e "\n                 40m     41m     42m     43m\
     44m     45m     46m     47m";

for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
           '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
           '  36m' '1;36m' '  37m' '1;37m';
  do FG=${FGs// /}
  echo -en " $FGs \033[$FG  $T  "
  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";

Easily fix async video with ffmpeg

1. Correcting Audio that is too slow/fast

This can be done using the "-async" switch of ffmpeg which according to the documentation "Stretches/squeezes" the audio stream to match the timestamps. The parameter takes a numeric value for the samples per seconds to enforce.

Example: ffmpeg -async 25 -i input.mpg <encoding options> -r 25

Try slowly increasing the -async value until audio and video matches.

2. Correcting Time-Shift (Variant 1)

Case 1: Audio ahead of video: As a special case the "-async" switch auto-corrects the start of the audio stream when passed as "-async 1". So try running

ffmpeg -async 1 -i input.mpg <encoding options>

Case 2: Audio behind video: Instead of using "-async" you need to use "-vsync" to drop/duplicate frames in the video stream. There are two methods in the manual page "-vsync 1" and "-vsync 2" and an method auto-detection with "-vsync -1". But using "-map" it is possible to specify the stream to sync against.

Interestingly Google shows people using -aync and -vsync together. So it might be worth experimenting a bit to achieve the intended result :-)

3. Correcting Time-Shift (Variant 2)

If you have a constantly shifted sound/video track that the previous fix doesn't work with, but you know the time shift that needs to be corrected, then you can easily fix it with one of the following two commands:

Case 1: Audio ahead of video:
ffmpeg -i input.flv -itsoffset 00:00:03.0 -i input.flv -vcodec copy -acodec copy -map 0:1 -map 1:0 output_shift3s.flv

Case 2: Audio behind video:
ffmpeg -i input.flv -itsoffset 00:00:03.0 -i input.flv -vcodec copy -acodec copy -map 1:0 -map 0:1 output_shift3s.flv

The difference is in the mapping parameters which specify which of the two supplied input files to map on which output channel. The "-itsoffset" option indicates an offset (3 seconds in the example) for the following input file. The input file is required to have exactly one video channel at position 0 and one audio channel at position 1.

I added "-vcodec copy -acodec copy" to avoid reencoding the video and loose quality. These parameters need to be added after the second input file and before the mapping options. Otherwise one runs into mapping errors.

Update: Also check the comment of an anonymous user below mentioning that he needed a different mapping with a more recent version of ffmpeg. The commands above were tested using ffmpeg 0.5/0.6

When rsync --delete doesn't work

David Grant explains why rsync might silentely refuse to delete anything. It happens when you call rsync without a trailing slash in the source path like this:

rsync -az -e ssh --delete /data server:/data

It just won't delete anything. It will when running it like this:

rsync -az -e ssh --delete /data/ server:/data

Create Random Passwords

In Debian there is a package "mkpasswd" which allows creating passwords like this:

echo | mkpasswd -s

Frame exact splitting with ffmpeg

When preparing videos for Apples HTTP streaming for iPad/iPhone you need to split your video into 10s chunks and provide a play list for Quicktime to process.

The problem lies with frame exact splitting of arbitrary video input material. Wether you split the file using ffmpeg or the Apple segmenter tool you often end up with

  • asynchronous audio in some or all segments
  • missing video frames at the start of each segment
  • audio glitches between two segements
  • missing audio+video between otherwise audio-synchronous consecutive segments

When using the Apple segmenter the only safe way to split files is to convert into an intermediate format which allows frame-exact splitting. As the segmenter only supports transport stream only MPEG-2 TS and MPEG-4 TS do make sense.

To allow frame-exact splitting on problematic input files the easiest way is to blow them up to consist only of I-frames. The parameter for this depends on the output video codec.

An ffmpeg command line for MPEG-2 TS can look like this:

ffmpeg -i inputfile -vcodec mpeg2video -pix_fmt yuv422p -qscale 1 -qmin 1 -intra outputfile

The relevant piece is the "-intra" switch. For MPEG-4 TS something like the following should work:

ffmpeg -i inputfile -vcodec libx264 -vpre slow -vpre baseline -acodec libfaac -ab 128k -ar 44100 -intra -b 2000k -minrate 2000k -maxrate 2000k outputfile

Note: It is important to watch the resulting muxing overhead which might lower the effective bitrate a lot!

The resulting output files should be safe to be passed to the Apple segmenter.

Syndicate content Syndicate content