rob.log

reogg - Prepare audio-files for radio loops

Did you ever want to automate live audio streaming from the command-line? Well, I do. To cut it short the requirements here were:

  • command-line (terminal) only
  • generate one long stream - concatenate all songs
  • retain (id3) tags
  • stream Ogg/Vorbis to an icecast server

In principle one can simply concatenate OGG files and use oggfwd to send it to icecast. However most players (in particular mplayer) will produce garbled output when mixing OGG files with different bitrate/samplerate/channels in one stream. Furthermore some input files may not be OGG/Vorbis encoded in the first place.

To remedy the situation, here's a simple shell-script that converts all files in a given folder to a common format and copies over the id3 tags. You'll need to have oggenc, oggdec, mpg321, flac123 and id3tool installed.

You can download the script from the repository, but it's simple enough to be printed here:

view reogg.sh source

#!/bin/sh
# reogg.sh:
#  converts audio files in SRC folder to a common OGG format which allows to
#  concatenate the resulting files.

SRC=${1-"/tmp/input"}
DST={$2-"/tmp/media"}

mkdir -p ${DST}
IFS=$'\n'
for file in $(ls ${SRC}); do
  DEC=""
  echo "${file}" | grep -e "\.mp3$"  >/dev/null && DEC="mpg321 -q -w- "
  echo "${file}" | grep -e "\.ogg$"  >/dev/null && DEC="oggdec -Q -o- "
  echo "${file}" | grep -e "\.flac$" >/dev/null && DEC="flac123 -q -w- "

  test -z "${DEC}"         && continue;
  test -r "${SRC}/${file}" || continue;

  NFN=$(echo ${file} | sed 's/flac$/ogg/' | sed 's/mp3$/ogg/')

  echo "${file}" | grep -e "\.mp3$"  >/dev/null && \
  TAG=$(id3tool "${SRC}/${file}" \
        | sed 's/"/\\"/g' \
        | awk '/^Song Title/{printf "-t \"%s\" ",substr($0,13);}
               /^Artist/    {printf "-a \"%s\" ",substr($0,10);}
               /^Album/     {printf "-l \"%s\" ",substr($0,9);}
               /^Genre/     {printf "-G \"%s\" ",substr($0,9);}
               /^Track/     {printf "-N \"%s\" ",substr($0,9);}')

  echo "${file}" | grep -e "\.ogg$"  >/dev/null && \
  TAG=$(ogginfo "${SRC}/${file}" \
        | sed 's/"/\\"/g' \
        | awk 'BEGIN{IGNORECASE=1;}
               /Title=/      {printf "-t \"%s\" ",substr($0,8);}
               /Artist=/     {printf "-a \"%s\" ",substr($0,9);}
               /Album=/      {printf "-l \"%s\" ",substr($0,8);}
               /Genre=/      {printf "-G \"%s\" ",substr($0,8);}
               /Tracknumber=/{printf "-N \"%s\" ",substr($0,14);}')

  echo "#-- FILE: ${file}"
  CMD="$DEC \"${SRC}/${file}\""
  CMD+="| oggenc --resample 44100 -q 6 -o \"${DST}/${NFN}\" ${TAG} -"
  echo "${CMD}"
  eval $CMD || exit
  echo
done



To transmit the converted files repeatedly to an icecast server I run the following shell script in a GNU Screen:

view loop_ice.sh source

#!/bin/sh

FILES=$(ls media/*.ogg)

function loopcat {
  while true; do
    # TODO: optionally randomize $FILES here..
    cat $FILES
  done
}

while true; do
  loopcat \
  | oggfwd localhost 8000 password -p -g "Genre" -n "Title" -d "Description" mountpoint.ogg;
  echo "---- LOST CONNECTION ----"
  sleep 2
done



If you find these scripts useful or want to suggest some improvements.. drop me a word:

Thinkpad smapi and Realtime Linux

The tp_smapi driver provides for Battery charge/discharge control and improved stability for the HDAPS driver. However the latest version (as of writing 0.40) does not work with a real-time patched Linux-kernel.

The problem is that rt-linux uses a new mechanism for mutex-locking, which allows preemption and is incompatible with current Linux-mainline. In order to get the tp_smapi driver compile with rt-linux you need to replace the MUTEX locks. I came up with a simple patch that applies to tp_smapi 0.40 to just do that.

Tested with linux 2.6.31.6-rt19. More information on tp_smapi can be found at http://www.thinkwiki.org/wiki/Tp_smapi

Enjoy.

rt2460 and linux 2.6.31

As of linux 2.6.31 there is no mainline support for the Ralink rt2680 Wifi chipset. While there is an official driver provided by Ralinktech, it is incompatible with 2.6.31 due to the fact that post 2.6.29 the kernel's net_device_ops API has changed and 2.6.31 also removed CONFIG_COMPAT_NET_DEV_OPS backwards compatibility.

So I came up with a small patch to the Ralink driver.

The solution is to get the module source from http://www.ralinktech.com/support.php?s=2 (tested with version 2.1.2.0 from 05/21/2009) and apply the patch before compilation..

Ralinktech provides a README file how to do this, basically you'll need the kernel-source or kernel-headers, and then simply type make after unzipping and patching the module source.

· 18.09.2009 13:03 · Robin Gareus

FOMS 2009

foms3.jpg This years FOMS (Foundations of Open Media Software) Workshop took place in Hobart, Tasmania and has not only been fun but also a great success!

The focus was on video & film, development of multimedia and collaborative video editing software such a metavid, pad.ma and videobin as well as free video codecs: dirac and ogg.

foms2.jpg Quite a few of the short-term Community Goals have been tackled, not only resulting in interesting discussion on ffmpeg-devel, but also yielding funding for open media now to publicly document codecs and prior art as an anti-patent strategy. linuxfilm.org started to index FLOSS authoring tools as a first step to indicate gaps for a professional workflow and and and..

FOMS was a very busy two days, extending into a multimedia mini-conf at LCA and quite a few days of hacking thereafter, not to mention the T42 bar evening excursions.

· 01.02.2009 06:25

wicked days

I spent the last days on the Wicked film set; driving the Chevrolet Impala set-car in gorgeous weather with an amazing team in the Amsterdamse Bos. Thanks everyone! Before post-production (and sodankyla development) begins I'm just about to release oauth-utils, preparing for the dokuwiki oAuth plug-in. Oh, a film-website is also on my ToDo list, besides ..well you don't wanna know. Stay tuned for more pictures!

Related to the movie-shooting I've been busy porting libltcsmpte to AVR-C and built myself a LTC SMPTE timecode reader. What else?

Arjan, Eelko and me are going to host the touch-screen workshop based on Frontera's justpoint at the DIY festival in Zuerich, CH. I'm looking forward to that, so I've updated the wordpress at http://fronteraproject.net/, the content and a new release is due around end of November as is the sound-track for Wicked. I'm firing up compiling ardour. See Ya.

View slide-show

· 17.12.2008 19:22 · Robin Gareus
 
blog.txt · Last modified: 02.03.2011 17:31 (external edit)