Contoh Skrip Zenity
#1
Ini ffmpeg GUI dengan Zenity yang saya sunting dari http://techpad.co.uk/content.php?sid=90. Saya berusaha memperbaiki bug-nya tetapi mungkin akang masih bisa sempurnakan. Pokoknya, skrip ini sudah bisa dipakai untuk konversi video selama akang punya ffmpeg.

Code:
#!/bin/bash
#videotranscoder.sh
#dipelajari dari laman http://techpad.co.uk/content.php?sid=90 dengan beberapa penyuntingan mandiri karena berkas unduhannya hilang semenjak 2009
#deklarasi variabel global
MessageSelectFormat="Select output format"
MessageSelectFormatVerbose="Please select the format you want to convert your file to"
MessageEnterFilename="Enter output filename"
MessageEnterFilenameVerbose="Enter output filename without suffix, ie. Shaun Of The Dead"
MessageSelectDirectory="Select destination directory"
MessageComplete="Your file has been transcoded"

#bagian1
WindowTitle="Video Transcoder"
MessageIntro="Please select the file you want to transcode"

    $(zenity --info --title "$WindowTitle" --width=300 --text "$MessageIntro")
    if [ $? = 1 ];
    then exit
    fi

#bagian2
SourceFile=$(zenity --file-selection --title "$WindowTitle" --width 500 --text "$MessageSelectFile")

    echo "Source: $SourceFile"
    if [ $? = 1 ];
    then exit
    fi

#bagian3
OutputFormat=$(zenity --title "$WindowTitle $MessageSelectFormat" --width 500 --list --text "$MessageSelectFormatVerbose" --radiolist --column "Select" --column "Output format" TRUE mp4 FALSE mkv FALSE wmv FALSE flv);

echo "Format: $OutputFormat"

if [ $? = 1 ];
then exit
fi

OutputFilename=$(zenity --title "$WindowTitle | $MessageEnterFilename" --width 500 --entry --text "$MessageEnterFilenameVerbose");

OutputFilename=`echo "$OutputFilename.$OutputFormat" | awk '{$1=$1}1' OFS="_"`

echo "Filename: $OutputFilename"

if [ $? = 1 ];
then exit
fi

#awas, salah petik salah semua
Directory=$(zenity --title "$WindowTitle  $MessageSelectDirectory" --width 500 --file-selection --directory);

echo "Directory: $Directory"

if [ $? = 1 ];
then exit
fi

ffmpeg -vcodec copy -acodec copy -i "$SourceFile" "$Directory/$OutputFilename" 2>&1 | zenity --width 500 --title "$WindowTitle  $MessageProgressTitle" --text "$MessageProgress" --progress --pulsate --auto-close

echo "Command: ffmpeg -vcodec copy -acodec copy -i "$SourceFile" "$Directory/$OutputFilename""

if [ $? = 1 ];
then exit
fi

zenity --info --title "$WindowTitle" --text "$MessageComplete"
echo "Done"
exit






Users browsing this thread: 1 Guest(s)