Hi all,

First, congratulations to all developers for making such a nice piece of software. It brought a lot of happy hours to this home ;-)

I'd like to contribute a UNIX shell script that converts .kar file to .mpg. I know, it's not much, but still... Maybe someone finds it useful.


Regards,
Zoltan
#! /bin/sh

# Sanity-check parameters.
for kar in "$@"; do
  if [ `basename "$kar" .kar` == "$kar" ]; then
    echo "$kar" does not end in .kar.
    exit 1
  fi
  if [ ! -f "$kar" ]; then
    echo "$kar" does not exist.
    exit 1
  fi
  wav=`dirname "$kar"`/`basename "$kar" .kar`.wav
  if [ ! -f "$wav" ]; then
    #echo "WAV file $wav does not exist, generating it ..."
    timidity $kar -Ow1S -s 44100 -o $wav 1>/dev/null
  fi
done

for kar in "$@"; do
  # Get temporary and output filenames, based on the input filename.
  wav=`dirname "$kar"`/`basename "$kar" .kar`.wav
  ppm=`dirname "$kar"`/`basename "$kar" .kar`.ppm
  mpa=`dirname "$kar"`/`basename "$kar" .kar`.mpa
  mpv=`dirname "$kar"`/`basename "$kar" .kar`.mpv
  mpg=`dirname "$kar"`/`basename "$kar" .kar`.mpg

  # Use PyKaraoke to extract the frames.  We render into a slightly
  # larger window than 288x192, to give room for a border and allow
  # for TV overscan.
  # PAL: 24000:1001 fps (23.976), NTSC: 30000:1001 fps (29.97)
  
  pykar --dump="$ppm" --dump-fps=23.976 --num-channels=2 --width=320 
--height=240 "$kar" || exit

  # Scale the video up to the DVD-sized screen, and convert it to mpeg.
  ppmtoy4m -v0 -F 24000:1001 "$ppm" | y4mscaler -v0 -O preset=dvd | mpeg2enc 
-M2 -v0 -f8 -b7500 -o "$mpv" || exit

  # Convert the audio to mpeg.
  mp2enc -v0 -b224 -r44100 -s -o "$mpa" <"$wav" || exit

  # Multiplex the audio and the video together.
  mplex -v0 -f8 "$mpa" "$mpv" -o "$mpg" || exit

  # Clean up.
  rm -f "$ppm" "$mpa" "$mpv" "$wav"
done

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Pykaraoke-discuss mailing list
Pykaraoke-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pykaraoke-discuss

Reply via email to