Convert video to iPhone/iPod Touch using ffmpeg
Colocado por Gustavo Felisberto em Ciência/TecnologiaIf you search for this topic you will find some examples of using ffmpeg to convert movies to a format that will work with the iPhone. I am a Linux user so I did not had much usage for this because there is no iTunes in linux
Until I needed to stream videos to the iPhone. Right now I’m using wowza for the actual streaming that involves creating a special playlist that will tell the iPhone how to get the file from the server. But that is another story.
So the actual ffmpeg command I’m using is:
ffmpeg -threads 2 -i INPUT_FILE -r 20 -vcodec libx264 -s 320x240 -flags +loop \ -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 \ -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 \ -keyint_min 25 -level 30 -qmin 10 -qmax 51 -trellis 2 -sc_threshold 40 \ -i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 OUTPUT_FILE
So what does all this mean? I am no ffmpeg expert but I’ll try to give an explanation. If you can fill the gaps please post a reply.
- -threads 2 Number of threads ffmpeg will use. This should be the number of cores in your system
- -i INPUT_FILE The path to the file you want to convert
- -r 20 The frame rate of the converted file. This should be the same as the input file. A lower value means a smaller file
- -vcodec libx264 Codec of the output file. This means that output will be a H264 Mpeg4 file
- -s 320×240 Resolution of the output. Should not exceed the input file. In any case remember that iPhone resolution is: 480×320
- -acodec libfaac -ab 128k -ar 48000 -ac 2 Audio format. AAC audio with 128kbits bitrate, with 48000Hz sample rate and 2 channels. Lower values will give smaller files and less quality.
If you know what the others do anf how do they affect the quality/size please post.
Tópicos (RSS)
Hum… E se o formato mudar de 4:3 para 16:9? Vai logo dar ***** de filmes esticados.
Para fazer este tipo de work, aconselho o Nero Recode pra Windows. Faz a conversão pro iPOD perfeita.
Amava escrever um post a armar-me em hacker do ffmpeg, quando foi tudo copiado sem dar creditos. Continua com os posts com bom conteúdo original!
RTFM. man é nosso amigo
man ffmpeg
@falso: Não impinjas o Nero Recode ou programas para windows, é para trabalhar em linux.
-qmin e -qmax are the minimum and maximum video quantitizer scale values.
-crf enables constant quality mode and selects the quality.
In case you don’t have the man page installed you can read the documentation here
Sr falso AKA florindo:
1 – Não coloquei referências porque não me recordo de onde fui buscar, não foi desse post como é facil de ver se abrir os olhos e olhar para o codec de video (só para começar).
2 – Se continuar a abrir os olhos vai reparar que o objectivo era uma solução para Linux. Utilizar software de Windows parece-me que sai um pouco do ambito.
Sr Nitroflow:
Faz tempo que não me diziam para ler uma man page. Devo dizer que eu li, mas o facto de lá estar apenas nos diz o que significa. Não como afecta a qualidade/tamanho (que era o que eu pedia no post).
you could use the powerful handbrake which has a gui and a cli interface or maybe winff (it runs on gnu/linux).
http://winff.org/html_new/
http://handbrake.fr/
Ricardo: Thanks for the tips. Tomorow I’ll try winff. I tried Handbrake today and with the iPhone preset there was a crop that I could not remove and it cuted the videos.
I was doing command line because of the Wowza streaming of HTTP/H264 to the iPhone.