H's Blog A good shell is the best user interface.

24Jul/100

Shrink VDR Recordings (MP4)

I currently use the following ffmpeg script to convert the recordings of my VDR 1.6 to more handy MPEG4 files:

#!/bin/bash

profile="-vpre hq"
quality="-crf 26"   # constant quality
prefix="nice"         # "nice ionice -c3"

for i in "$@"; do
    [ -r "$i" ] || continue
    output="$(basename "$i" | cut -f 1 -d .).$profile.mp4"
    [ -e "$output" ] && continue

    $nice ffmpeg -i "$i" -acodec copy -scodec copy -threads 0 \
        -vcodec libx264 $profile $quality "$output"
done

But I am still testing the ffmpeg parameters and I use additional calls to avidemux to merge parts and establish audio audio/video sync.
Sometimes I have to save the stream with -700ms shift after the ffmpeg conversion.
I got the x264 presets at the ffmpeg repository and downloaded them to $HOME/.ffmpeg, so the vpre option will not complain.
Of course the quality setting is subject to your personal constraints to file size and video quality.

22Jul/102

Streaming MPEG-TS

Up to release 1.6 VDR is recording into MPEG-PS files named *.vdr.
In newer release this was switched to MPEG-TS (with some impact on moving marks).
The Asus O!Play is fine with the TS (Transport Stream) format, but lacks support of the *.vdr files.

Since I want to stick to release 1.6 of VDR for now, I just wrote a script, that will convert the recordings into MPEG-TS files using ffmpeg, all contained on a Samba export, which is connected to the streaming device:

#!/bin/bash
find . -type f -name "???.vdr" | while read vdr; do
  dir="$(dirname "$vdr")"
  file="$(basename "$vdr" .vdr)"
  target="$dir/$file.mpg"
  [ -f "$target" ] && continue
  nice ffmpeg -i "$vdr" \
    -vcodec copy \
    -acodec copy \
    -scodec copy \
    -sameq \
    -f mpegts \
    "$target"
done

Since only the container format changes, this script does not cost that much performance and I can even run it without larger problems on my Atom-driven VDR host.