mPlayRecTv - assiste e grave a programação da TV com MPlayer
Publicado por Pedro Robson Leão 05/04/2005
[ Hits: 5.748 ]
Grave a programação da tv com o uso do cron/at e mplayer.
Passei por varias opções vcr, http://www.stack.nl/~brama/vcr/, mplayerTv, http://www.mplayertv.tk/. Mas foi no site http://www.anandtech.com/guides/viewfaq.aspx?i=154 que encontrei os parametros necessários para usar o mplayer para fazer minhas gravações.
Criei então um script para fazer isto e conto com a comunidade para aprimorar este script.
Mandem suas dicas, criticas e melhorias.
#!/usr/bin/bash
#name : mPlayRecTv
#born : 01-April-2005 (it is not lie)
#author : Pedro Robson Leão (pedro.leao@ig.com.br)
#description: A simple interface to play and rec tv with mplayer.
#change log :
#20050401 ** first version.
#mencoder -tv driver=v4l:norm=palm:channel=3:chanlist=us-cable:width=320:height=240:input=0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900 -oac mp3lame -lameopts cbr:br=64 -o output.avi tv://
#mplayer -tv driver=v4l:norm=palm:channel=3:chanlist=us-cable:width=352:height=240:input=0 -vo sdl tv://
#-- default Parameters
driver=${driver:-v4l};
norm=${norm:-palm};
channel=${channel:-3};
channelist=${channelist:-us-cable};
width=${width:-320};
height=${height:-240};
ovc=${ovc:-lavc -lavcopts};
vcodec=${vcodec:-mpeg4};
vbitrate=${vbitrate:-900};
oac=${oac:-mp3lame -lameopts};
cbr=${cbr:-br=64};
input=${input:-Television};
output=${output:-output.avi};
vo=${vo:-sdl};
log=${log:-/dev/null};
time=;
play=1;
myname=$0;
#-- convert hour and minuts to seconds
function convTime() {
value=${1};
value=${value//:/};
min=$((value%100));
hour=$((value/100))
min=$((min*60));
hour=$((hour*3600));
sec=$((hour+min));
echo $sec;
}
#-- error message
function errMsg() {
echo "Use: ${myname} [options ...]";
echo;
echo "Default options:";
echo "--driver=${driver}";
echo "--norm=${norm} [palm/paln/pal/ntsc]";
echo "--channel=${channel}";
echo "--channelist=${channelist}";
echo "--width=${width}";
echo "--height=${height}";
echo "--ovc=${ovc}";
echo "--vcodec=${vcodec}";
echo "--vbitrate=${vbitrate}";
echo "--oac=${oac}";
echo "--cbr=${cbr}";
echo "--input=${input} [Television/Composite1/S-Video]";
echo "--output=${output}";
echo "--vo=${vo}";
echo "--log=${log}";
echo;
echo;
case $1 in
pid) echo "ERROR IN PLAY/REC : To debug errors to play/rec use --log option and see log to many informations.";;
input) echo "INVALID INPUT : Use --input with [Television/Composite1/S-Video]";;
mplayer|mencoder) echo "CAN'T FOUND PROGRAM ${1}";
esac
}
#-- Change input parameters to getopts format
set -- ${*//--driver/-d};
set -- ${*//--norm/-n};
set -- ${*//--channel/-c};
set -- ${*//--channelist/-l};
set -- ${*//--width/-W};
set -- ${*//--heigth/-H};
set -- ${*//--ovc/-V};
set -- ${*//--vcodec/-C};
set -- ${*//--vbitrate/-b};
set -- ${*//--oac/-A};
set -- ${*//--cbr/-R};
set -- ${*//--input/-i};
set -- ${*//--output/-o};
set -- ${*//--vo/-O};
set -- ${*//--play/-p};
set -- ${*//--rec/-r};
set -- ${*//--log/-L};
set -- ${*//--time/-T};
set -- ${*//--help/-h};
#- get parameters
while getopts d:n:c:l:W:H:V:C:b:A:R:i:o:O:prhL:T: value 2>/dev/null ; do
case $value in
d) driver="${OPTARG}";;
n) norm="${OPTARG}";;
c) channel="${OPTARG}";;
l) channelist="${OPTARG}";;
w) width="${OPTARG}";;
H) heigth="${OPTARG}";;
V) ovc="${OPTARG}";;
C) vcodec="${OPTARG}";;
b) vbitrate="${OPTARG}";;
A) oac="${OPTARG}";;
R) cbr="${OPTARG}";;
i) input="${OPTARG}";;
o) output="${OPTARG}";;
O) vo="${OPTARG}";;
L) log="${OPTARG}";;
T) time="${OPTARG}";;
p) play=1;;
r) play=;;
h) errMsg help; exit 0;;
*) errMsg help; exit 0;;
esac
done
#-- convert input parms
case ${input} in
Television) input=0;;
Composite1) input=1;;
S-Video) input=2;;
*) errMsg input; exit 0;;
esac
gparms="driver=${driver}:norm=${norm}:channel=${channel}:chanlist=${channelist}:width=${width}:height=${height}:input=${input}";
if [ ! -z ${play} ] ; then
command="mplayer -tv ${gparms} -vo ${vo} tv://";
msglog="${0} play channel ${channel} ";
else
command="mencoder -tv ${gparms} -ovc ${ovc} vcodec=${vcodec}:vbitrate=${vbitrate} -oac ${oac} cbr:${cbr} -o ${output} tv://";
msglog="${0} rec channel ${channel} ";
fi
#-- verify command
if ! which $( echo $command | cut -d" " -f1 ) ; then
errMsg $command;
exit 1;
fi
#-- execute the mplayer our mencoder
start=$(date);
${command} >${log} 2>&1 &
cmdpid=${!};
#-- in error case no has pid
[ -z "${cmdpid}" ] && errMsg pid && exit 0;
#-- get time to reproduction
time=$( convTime ${time} );
#-- if time reproduction, kill proccess after time
[ ${time} -ge 0 ] && sleep ${time} && kill ${cmdpid};
end=$(date);
#-- write log message
logger 0 "${msglog} pid:${cmdpid} start:${start} end:${end}";
exit 1;
Screenshot de menus??!! Script com temporizador popup!
Impedir duas ou mais conexões por usuário
Avisos de segurança do espaço em uso!
Programação do Dia da Tv Aberta
Nenhum comentário foi encontrado.
Usei o NotebookLM para Auditar Logs do Linux
Cinnamon seria a aposta acertada frente às outras interfaces gráficas mais populares?
KDE Plasma - porque pode ser a melhor opção de interface gráfica
Gentoo: detectando impressoras de rede e como fixar uma impressora por IP
Como o GNOME conseguiu o feito de ser preterido por outras interfaces gráficas
WiFi Seguro: EAP-TLS com FreeRADIUS e Active Directory (LDAP).
Necessário autenticar ao imprimir - Ubuntu X Windowns (2)
Midia de instalação LM-21.3 não inicializa (0)
Vou destruir sua infância:) (8)









