Mit Hilfe des Skriptes kann man aus dem KDE-Kontextmenu hinaus ein Video konvertieren. Superpraktisch. KDE Service Menus (Kontentmenu 'Aktion')
/home/gerald/.kde/share/apps/konqueror/servicemenus/PSP_Video.desktop
[Desktop Entry] Type=Application ServiceTypes=video/avi,video/mpeg,video/x-msvideo,video/wmv Actions=convertir_video_psp [Desktop Action convertir_video_psp] Name[es]=Convertir video a PSP/MPEG4 Name[en]=Convert video to PSP/MPEG4 Name[de]=Video für PSP konvertieren Icon=crop.png Exec=psp-recode.sh %u
psp-recode.sh:
#!/bin/bash # Autor: Ivanvega (ivanvegacbr@gmail.com) # appname=`basename "$0"` encdir=$HOME title="$2" ffmpeglog="$HOME"/psp-recode.log DSTNAME=M4V$(printf '%05d' ${RANDOM}) gui=1 progreso=1 version="1.1 (KDE)" # GUI-aware error function die () { if [ $gui ]; then zenity --error --title="$appname" --text="$1. Fallo codificación (Encoding error)." else echo "$1. Fallo codificación (Encoding error)." >/dev/stderr fi exit 1 } DisplayEncodingProgress () { progresstext="Codificando (Encoding) $SRCFILE [ pasada (pass) $pass de (of) 2 ]" if [ $gui ]; then ( while ps | grep "$pid " >/dev/null do secondsCompleted=`tail -c 90 "$ffmpeglog" | awk -F"time=" {'print $2'} | cut -d"." -f 1` [ -n "$secondsCompleted" ] || secondsCompleted=0 percentage=$((100*$secondsCompleted/$inputlength)) echo "$percentage" sleep 1 done echo 100 ) | zenity --progress --title="$appname" --text="$progresstext" --auto-close else echo "$progresstext" lastpercentage=0 while ps | grep "$pid " >/dev/null do secondsCompleted=`tail -c 90 "$ffmpeglog" | \ awk -F"time=" {'print $2'} | cut -d"." -f 1` [ -n "$secondsCompleted" ] || secondsCompleted=0 percentage=$((100*$secondsCompleted/$inputlength)) if [ $percentage -gt $lastpercentage ]; then echo -ne "$percentage%\r" lastpercentage="$percentage" fi sleep 1 done fi } # sanity check helper apps if [ $gui ]; then [ -z "$(which zenity)" ] && gui= fi [ -n "$(which kdialog)" ] || die 'kdialog no instalado (not installed)' [ -n "$(which mplayer)" ] || progreso= [ -n "$(which ffmpeg)" ] || die 'ffmpeg no instalado (not installed)' if [ -z "$(ffmpeg -formats 2>/dev/null | grep ' psp mp4 format' | grep E)" ]; then die 'Tu versión de ffmpeg no está preparada para PSP Video (Your ffmpeg version not support encoding PSP Video)' fi case $1 in --help) cat <<EOF Usage: $appname INPUTFILE [TITLE] Encode video for PSP v$version INPUTFILE can be any video input format suported by ffmpeg If no TITLE, script ask you. Report bugs to <ivanvegacbr@gmail.com>. EOF exit 1;; *) if [ -r "$1" ]; then SRCFILE="$1" else die 'El archivo de entrada no existe o no se puede leer (Input file not exist or cant read)' exit 1 fi;; esac # select destination directory, use last selected encdir=$(kdialog --title "¿Donde quieres guardar el video(s)? (Destination directory?)" --getexistingdirectory $encdir) && # encdir not writable? while test ! -w "$encdir" do kdialog --error "No tiene permiso para escribir en este directorio (You cant write in this directory)" encdir=$(kdialog --title "¿Donde quieres guardar el video(s)? (Destination directory?)" --getexistingdirectory $HOME) done test -z "$encdir" && exit if [ -z $title ] then title=$(kdialog --title "PSPRecode" --inputbox "Titulo (Title):" "$2" 2> /dev/null) fi if [ -z $resol ] then resol=$(kdialog --title "PSPRecode" --menu "Resolucion (Resolution)" 320x240 "320x240 (4:3)" 368x208 "368x208 (16:9)" 2> /dev/null) test -z "$resol" && exit fi if [ -z $frate ] then frate=$(kdialog --title "PSPRecode" --combobox "Framerate" 14.985 29.97 --default 29.97 2> /dev/null) test -z "$frate" && exit fi if [ -z $vbitrate ] then vbitrate=$(kdialog --title "PSPRecode" --combobox "Video Bitrate" 768 512 380 2> /dev/null) test -z "$vbitrate" && exit fi if [ -z $ebitrate ] then ebitrate=$(kdialog --title "PSPRecode" --radiolist "Base for Video Bitrate" 1000 "Bits/s (newer ffmpeg version)" check 1 "Kbits/s (old ffmpeg version)" uncheck 2> /dev/null) test -z "$ebitrate" && exit fi vbitrate=$vbitrate*$ebitrate if [ -z $abitrate ] then abitrate=$(kdialog --title "PSPRecode" --combobox "Audio Bitrate" 32 64 96 128 --default 64 2> /dev/null) test -z "$abitrate" && exit fi # get video length, truncated to the nearest second if [ $progreso ];then inputlength=`mplayer -identify -frames 0 -vc null -vo null -ao null \ "${SRCFILE}$device" 2>/dev/null | \ grep ^ID_LENGTH | \ sed -e 's/^.*=//' -e 's/[.].*//'` [ -n "$inputlength" ] || die "No se ha podido determinar la duración del video (Cant get video length)" else BAR=`kdialog --progressbar "Codificando (Encoding)..." 4 --icon video --caption "Codificando video para PSP (Encoding video for PSP)"` #ffmpeg -i "${SRCFILE}" -b 380 -r 29.97 -s 368x208 -f mp4 -vcodec mpeg4 -aspect 4:3 -g 300 -me epzs -qmin 3 -qmax 9 -hq -acodec aac -ab 96 -ar 24000 -ac 2 -y "${DSTNAME}.MP4" dcop $BAR setProgress 1 dcop $BAR setLabel "Primera pasada sobre (First pass over) $SRCFILE..." fi if [ $progreso ];then nice -10 ffmpeg -y -i "${SRCFILE}" -pass 1 -passlogfile "${DSTNAME}" -title "${title}" -s "${resol}" -r "${frate}" -b "${vbitrate}" -ar 24000 -ab "${abitrate}" -f psp "${encdir}/${DSTNAME}.MP4" 2>"$ffmpeglog" & pid=$! pass=1 DisplayEncodingProgress pid= else nice -10 ffmpeg -y -i "${SRCFILE}" -pass 1 -passlogfile "${DSTNAME}" -title "${title}" -s "${resol}" -r "${frate}" -b "${vbitrate}" -ar 24000 -ab "${abitrate}" -f psp "${encdir}/${DSTNAME}.MP4" 2> /dev/null dcop $BAR setProgress 2 dcop $BAR setLabel "Segunda pasada (Second pass). Creando (Writing) $DSTNAME.MP4..." fi if [ $progreso ];then nice -10 ffmpeg -y -i "${SRCFILE}" -pass 2 -passlogfile "${DSTNAME}" -title "${title}" -s "${resol}" -r "${frate}" -b "${vbitrate}" -ar 24000 -ab "${abitrate}" -f psp "${encdir}/${DSTNAME}.MP4" 2>>"$ffmpeglog" & pid=$! pass=2 DisplayEncodingProgress pid= else nice -10 ffmpeg -y -i "${SRCFILE}" -pass 2 -passlogfile "${DSTNAME}" -title "${title}" -s "${resol}" -r "${frate}" -b "${vbitrate}" -ar 24000 -ab "${abitrate}" -f psp "${encdir}/${DSTNAME}.MP4" 2> /dev/null dcop $BAR setProgress 3 dcop $BAR setLabel "Generando imagen/icono (Writing image/icon) $DSTNAME.THM..." fi rm "${DSTNAME}-0.log" if [ -e "$ffmpeglog" ] then rm "$ffmpeglog" fi nice -10 ffmpeg -y -i "${SRCFILE}" -f mjpeg -ss 15 -vframes 1 -s 160x120 -an "${encdir}/${DSTNAME}.THM" 2>/dev/null if [ -e "gmon.out" ] then rm "gmon.out" fi if [ -z $progreso ];then dcop $BAR setProgress 4 dcop $BAR close fi echo "${DSTNAME}.MP4 y ${DSTNAME}.THM generados (writed)." kdialog --msgbox "${DSTNAME}.MP4 y ${DSTNAME}.THM generados (writed)." &