[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Aufnahme von Fernsehsendungen



Hallo Jan,

On Tue, Aug 02, 2005 at 12:00:37AM +0200, Jan wrote:
> ich habe in meinem Rechner eine Fernsehkarte und sehe via tvtime fern.
> Ich würde aber so manche Sendung auch gerne aufnehmen, wie kann ich das ?

Ich habe vor Jahren mir mal zusammengebastelt, wie es mit dem
MPlayer, bzw. MEncoder, funktioniert.

Ich glaube mich aber daran zu erinnern, dass der Syntax des
MPlayers seitdem geaendert wurde.  Die Option '-tv', wie sie
beim MPlayer 0.90rc4 (mit diesem Mplayer funktionierte es
damals) existierte, gibt es bei meinem jetzigen MPlayer
(1.0pre7-3.3.5) nicht mehr.  Daher konnte ich das Script auch
nicht testen.  Es kann also nur Ansatz sein, mit dem man sich
an die erschlagende Manpage des Mplayers machen kann.

Ausser dem MPlayer brauchte ich damals natuerlich noch einen
Encoder fuer den Audiostream.  Es war also auch Lame installiert.

-----schnipp-----
#!/bin/bash

####################
# DEFAULT SETTINGS #
####################

_vbitrate=1000                   # Bitrate fuer Video
_codec=mpeg4                     # Codec fuer Video
_height=480                      # Aufloesung (Hoehe)
_width=640                       # Aufloesung (Breite)
_br=96                           # Bitrate fuer MP3
_output=output.avi               # output file
_channel=36                      # tv Sender
_fps=25                          # frames per second

########
# HELP #
########

for parm in "$@" ; do
  if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
    cat << EOF

starts mencoder to grab an .avi from TV

Usage: $0 [OPTIONS]...

  -h, --help             display this help and exit

  --channel=NAME         tv-channel [video]

  --output=FILE          output file [output.avi]

  --time=VALUE           time until end [infinity]

  --crop=w:h:x:y         Crops the given part of  the
                         image and discards the rest.
                         Useful to remove black bands
                         from widescreen movies.
                         Parameters w:h means width x height
                         in pixels, x:y means x;y position counted from the
                         upper left corner of the bigger image.

EOF
    exit 0
  fi
done # for parm in ...

##################
# OPTION PARSING #
##################

for _option in $@; do
  case "$_option" in
  --channel=*)
    _channel=$(echo $_option | cut -d '=' -f 2)
    ;;
  --crop=*)
    _crop="-vop crop=$(echo $_option | cut -d '=' -f 2)"
    ;;
  --output=*)
    _output=$(echo $_option | cut -d '=' -f 2)
    ;;
  --time=*)
    _time="-endpos $(echo $_option | cut -d '=' -f 2)"
    ;;
  esac
done

#####################
# STARTING MENCODER #
#####################

# strange problem: if the module is loaded mencoder didn't work
# sometimes. So I remove the module and let load the module new
test "$(lsmod | grep videodev | awk '{print $4}')" = "(unused)" && \
  sudo rmmod videodev

# kill all running mplayers
var=(ps -u$LOGNAME -opid -ocomm | grep tv)
if [ -n "$var" ]; then
        kill $(echo $var | awk '{print $1}')
        killall mplayer
fi

# wait some time for killing
sleep 1

# start mencoder
/usr/local/bin/mencoder \
  -tv on:driver=v4l:input=0:norm=PAL:channel=$_channel:\
chanlist=europe-west:width=$_width:height=$_height:outfmt=yv12:\
device=/dev/video0:adevice=/dev/dsp:audiorate=44100:\
forceaudio:forcechan=2:buffersize=64 \
  -ovc lavc -lavcopts vcodec=$_codec:vbitrate=$_vbitrate:keyint=30 \
  -oac mp3lame -lameopts br=$_br:cbr:mode=3 \
  -ffourcc divx \
  -o $_output \
  $_time \
  $_crop

-----schnapp-----



Reply to: