diumenge, 9 de gener del 2011

video a l'ipod touch



Com ho he fet per transferir video a l'ipod touch:

1.- Baixar-te el video i convertir-lo. Aquí l'script que faig servir (l'he baixat no recordo de on). Nota: si l'ffmpeg o mencoder no té els codecs que necessites cal agegir el repositori medibuntu.

#!/bin/bash

quiet=""
passes="2"
codec="lavc"
bitrate="448"
bitratemax="960"
width="320"
height="240"

usage () {
echo "
Usage: `basename "$0"` [-q] [-1|-2] [-L|-H] [-b BITRATE ] [-m MAX_BITRATE] [-w WIDTH] [-h HEIGHT] MOVIE_FILE
-q Quieter output.
-1 Use 1 pass encoding.
-2 Use 2 passes (default).
-L Use lavc (default). Much quicker, but not as high quality.
-H Use h264. Slow, but high quality.
-b BITRATE Defaults to 448, 192 for low quality, 768 for high
-m MAX_BITRATE Defaults to 960, 768 for low quality, 1500 for high
-w WIDTH Defaults to 320, ipod screen width. Use 640 for tv out.
-h HEIGHT Defaults to 240, ipod screen height. Use 480 for tv out.
"
}

[ "$#" -lt 1 ] && usage && exit -1

while getopts "q12LHb:m:w:h:" Option; do
case "$Option" in
q) quiet="-quiet" ;;
1) passes="1" ;;
2) passes="2" ;;
b) bitrate="$OPTARG" ;;
m) bitratemax="$OPTARG" ;;
w) width="$OPTARG" ;;
h) height="$OPTARG" ;;
L) codec="lavc" ;;
H) codec="h264" ;;
*) usage; exit -1 ;;
esac
done
shift $(( $OPTIND - 1 ))

while [ "$1" ]; do
infile="$1"
! [ -f "$infile" ] && echo Error, file not found \"$infile\" && usage && exit -1

outfileP="${1%.*}.m4v"
outfile=`basename $outfileP`

num=1
while [ -f "$outfile" ]; do
echo "output file exists, adding number"
outfileP="${1%.*}-$num.m4v"
outfile=`basename $outfileP`
let "num += 1"
done

pass=0
if [ "$codec" = "lavc" ]; then
while [ "$pass" -lt "$passes" ]; do
let "pass += 1"
echo --- Pass $pass of $passes Pass LAVC Encoding ---
echo $outfile
echo $width x $height, $bitrate-$bitratemax
sleep 1
encopts="aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=$bitrate:acodec=libfaac:abitrate=128"
[ "$passes" -gt "1" ] && encopts="$encopts:vpass=$pass"
echo $encopts
sleep 1
mencoder "$infile" $quiet -ofps 30 -sws 9 -of lavf -lavfopts format=ipod \
-vf scale=-10:$height,dsize=$width:$height:0,harddup \
-ovc lavc \
-lavcopts $encopts \
-oac lavc \
-alang en \
-srate 22050 \
-o "$outfile"
EXIT_CODE="$?"
[[ "$?" != "0" ]] && exit "$EXIT_CODE"
done

elif [ "$codec" = "h264" ]; then
while [ "$pass" -lt "$passes" ]; do
let "pass += 1"
echo --- Pass $pass of $passes Pass H264 Encoding ---
echo $outfile
echo $width x $height, $bitrate-$bitratemax
sleep 1
encopts="bitrate=$bitrate:vbv_maxrate=$bitratemax:vbv_bufsize=2000:nocabac:me=hex:subq=4:frameref=2:trellis=1:level_idc=30:global_header:threads=auto"
[ "$passes" -gt "1" ] && encopts="$encopts:pass=$pass"
echo $encopts
sleep 1
mencoder "$infile" $quiet -ofps 30 -sws 9 -of lavf -lavfopts format=ipod \
-vf scale=-10:$height,dsize=$width:$height:0,harddup \
-ovc x264 \
-x264encopts $encopts \
-oac faac \
-alang en \
-faacopts mpeg=4:object=2:br=160:raw -channels 2 \
-srate 48000 \
-o "$outfile"
EXIT_CODE="$?"
if [[ "$?" != "0" ]]; then exit "$EXIT_CODE"; fi
done
fi

shift
done


2.- transferir el video amb gtkpod. El gtkpod l'engego amb aquest script:


#!/bin/bash
ifuse /media/ipod
gtkpod
fusermount -u /media/ipod/



abans cal haver creat /media/ipod a mà.




3.- Per que funcioni l'script: Medibuntu

sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

sudo apt-get install ffmpeg libavcodec-extra-52

sudo apt-get install ffmpeg

Cap comentari:

Publica un comentari a l'entrada