Dependencias:
Perl-Tk
Mplayer
#!perl#################### This file was automatically generated by ZooZ.pl v1.2# on Wed Jul 17 16:49:56 2013.# Project: VideoGrab# File: /root/ZooZ-1.2/video.zooz##################### Headers#use strict;use warnings;use Tk ;use Tk::ProgressBar;## Global variables#my (# MainWindow$MW,# Hash of all widgets%ZWIDGETS,);## User-defined variables (if any)#my $audio = undef;my $estado = "Detenido";my $audios= undef;my $dispoaudio= undef;my $desition;######################## Create the MainWindow#######################$MW = MainWindow->new;######################## Load any images and fonts#######################ZloadImages();ZloadFonts ();# Widget archivoF isa Labelframe$ZWIDGETS{'archivoF'} = $MW->Labelframe(-takefocus => 0,-text => 'Archivo',)->grid(-row => 0,-column => 0,-sticky => 'ew',);# Widget archivoL isa Label$ZWIDGETS{'archivoL'} = $ZWIDGETS{archivoF}->Label(-takefocus => 0,-text => "Nombre del Archivo\n(Sin extencion)",)->grid(-row => 0,-column => 0,);# Widget archivoE isa Entry$ZWIDGETS{'archivoE'} = $ZWIDGETS{archivoF}->Entry(-exportselection => 1,)->grid(-row => 1,-column => 0,);# Widget deviceF isa Labelframe$ZWIDGETS{'deviceF'} = $MW->Labelframe(-takefocus => 0,-text => 'Dispositivo',)->grid(-row => 1,-column => 0,-sticky => 'ew',);# Widget deviceL isa Label$ZWIDGETS{'deviceL'} = $ZWIDGETS{deviceF}->Label(-text => 'Seleccione un Dispositivo',)->grid(-row => 0,-column => 0,);# Widget dev_list isa Listbox$ZWIDGETS{'dev_list'} = $ZWIDGETS{deviceF}->Listbox(-exportselection => 1,-height => 4,-setgrid => 0,)->grid(-row => 1,-column => 0,);# Widget accionF isa Labelframe$ZWIDGETS{'accionF'} = $MW->Labelframe(-takefocus => 0,-text => 'Acciones',)->grid(-row => 2,-column => 0,-columnspan => 2,-sticky => 'ew',);# Widget ButtonStart isa Button$ZWIDGETS{'ButtonStart'} = $ZWIDGETS{accionF}->Button(-command => 'main::start',-text => 'Grabar',)->grid(-row => 0,-column => 0,-padx => 20,);# Widget ButtonStop isa Button$ZWIDGETS{'ButtonStop'} = $ZWIDGETS{accionF}->Button(-command => 'main::stop',-text => 'Detener',)->grid(-row => 0,-column => 1,-padx => 20,);# Widget ButtonExit isa Button$ZWIDGETS{'ButtonExit'} = $ZWIDGETS{accionF}->Button(-command => 'main::exit',-text => 'Salir',)->grid(-row => 0,-column => 2,-padx => 20,);# Widget audioF isa Labelframe$ZWIDGETS{'audioF'} = $MW->Labelframe(-takefocus => 0,-text => 'Audio',)->grid(-row => 0,-column => 1,-sticky => 'ew',);# Widget audioL isa Label$ZWIDGETS{'audioL'} = $ZWIDGETS{audioF}->Label(-takefocus => 0,-text => 'Seleccione Una Opcion',)->grid(-row => 0,-column => 0,-columnspan => 2,);# Widget ossB isa Radiobutton$ZWIDGETS{'ossB'} = $ZWIDGETS{audioF}->Radiobutton(-command => 'main::audio',-highlightthickness => 1,-indicatoron => 1,-state => 'normal',-takefocus => 0,-text => 'OSS',-value => 1,-variable => \$audio,)->grid(-row => 1,-column => 0,);# Widget alsaB isa Radiobutton$ZWIDGETS{'alsaB'} = $ZWIDGETS{audioF}->Radiobutton(-command => 'main::audio',-indicatoron => 1,-text => 'Alsa',-value => 2,-variable => \$audio,)->grid(-row => 1,-column => 1,);# Widget estadoF isa Labelframe$ZWIDGETS{'estadoF'} = $MW->Labelframe(-text => 'Estado',)->grid(-row => 1,-column => 1,-sticky => 'nsew',);# Widget estadoL isa Label$ZWIDGETS{'estadoL'} = $ZWIDGETS{estadoF}->Label(-text => 'Label3',-textvariable => \$estado,)->grid(-row => 1,-column => 0,);my $devices=`ls /dev | grep video`;my @dev=split("\n" , $devices);$ZWIDGETS{'dev_list'}->insert('end',@dev);################# MainLoop################MainLoop;######################### Subroutines########################sub ZloadImages {}sub ZloadFonts {}sub audio {}sub start {my $archivo = $ZWIDGETS{'archivoE'}->get();if ($archivo eq ""){$MW->messageBox(-type=>"ok", -message=>"Escriba el nombre del archivo");goto start;}if ($audio eq 0){$MW->messageBox(-type=>"ok", -message=>"Seleccione una opcion de audio");goto start;}my $dev=$ZWIDGETS{'dev_list'}->get($ZWIDGETS{'dev_list'}->curselection( ));if ($dev =~ "Error"){$MW->messageBox(-type=>"ok", -message=>"Seleccione un dispositivo de captura");goto start;}if ($audio==1){$audios="adevice=/dev/dsp";$dispoaudio="OSS";}elsif($audio==2){$audios="alsa:adevice=hw.0";$dispoaudio="ALSA";}my $rewrite=`ls ~`;my $final="$dispoaudio-$archivo.avi";if ($rewrite =~ "$final"){$desition=$MW->Dialog(-title => 'Error',-text => "El archivo $final ya existe, desea sobreescribirlo?",-default_button => 'No', -buttons => [ 'Si', 'No'],-bitmap => 'question' )->Show( );if ($desition eq "No"){goto start;}}grabar:system("xterm -e mencoder -tv driver=v4l2:width=768:height=576:norm=NTSC:device=/dev/$dev:$audios:forceaudio:immediatemode=0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=9000 -oac mp3lame -lameopts cbr:br=64 -o ~/$final tv:// &");$estado="Grabando";sleep (10);system ("mplayer ~/$final &");start:}sub stop {system ("killall mencoder ; killall mplayer");$estado="Detenido";}sub exit {$MW->destroy;}