|
|
(5 revisões intermediárias por 2 usuários não estão sendo mostradas) |
Linha 1: |
Linha 1: |
| [[Imagem:Man_ffmpeg_result.png|right|Imagem do comando '''man ffmpeg''' no terminal.]]
| | AVI to 3GP: |
| <P CLASS="western" ALIGN=JUSTIFY STYLE="margin-bottom: 0cm">Usuários
| |
| de sistemas <B>GNU/Linux</B>, especialmente os que trabalham com edição e reprodução de vídeo, certamente conhecem ou já ouviram falar do programa de linha de comandos <B>ffmpeg</B>.
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm">O que nem todos conhecem é a maneira de melhor usá-lo. Essa página pretende dar um panorama geral da sintaxe e do uso do <B>ffmpeg</B>,bem como, indicar boas referências para quem quer se aprofundar no seu uso. Mas sem maiores papos, vamos lá!</P>
| |
|
| |
|
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| | ffmpeg -i video_clip.avi-s qcif -vcodec h263 -acodec mp3 -ac 1 -ar 8000 -r 25 -ab 32 -y clip.3gp |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>Usando
| |
| o ffmpeg </B></FONT></FONT>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Com
| |
| este programa você pode cortar, converter, equalizar, juntar e até
| |
| mudar o brilho e o contraste de um vídeo, entre outras coisas. É
| |
| sem dúvida, a melhor e mais rápida opção para, por exemplo, quem
| |
| quer converter um vídeo bruto pesado, capturado de uma câmera
| |
| filmadora, para um formato mais leve como .mp4 e/ou .ogg.</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Entretanto
| |
| existem algumas características que no <B>ffmpeg</B> que as vezes
| |
| afastam o usuário sem prática. Uma desvantagem, especialmente para
| |
| <B>usuários iniciantes em sistemas Gnu/Linux</B>, é que as opções
| |
| são inúmeras e requerem um grande conhecimento da terminologia
| |
| associada à <FONT COLOR="#000000"><SPAN STYLE="text-decoration: none">tecnologia
| |
| de áudio </SPAN></FONT>e vídeo. Em casos assim, uma interface
| |
| gráfica ajuda muito. Mas tem também as receitas prontas, que
| |
| funcionam muito bem e que podem ser usadas no terminal de comandos,
| |
| permitindo o processamento de múltiplos arquivos simultaneamente. </FONT></FONT>
| |
|
| |
|
| </P>
| | ffmpeg -i inputfile.avi -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Há
| |
| um excelente artigo chamado <I><B>19 Ffmpeg Commands For All Needs</B></I><I>
| |
| </I><I><B>(19 comandos de ffmpeg para todas as necessidades)</B></I>
| |
| que oferece algumas receitas simples e muito uteis para quem quer
| |
| usar o <B>ffmpeg</B>. Apresento a seguir, em uma tradução mais ou
| |
| menos livre deste citado artigo, o passo-a-passo de muitos comandos.</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Maiores
| |
| detalhes sobre o ffmpeg podem ser consultados também diretamente na
| |
| documentação que vem junto com o programa (man ffmpeg) ou no
| |
| conjunto de referências no final desta página.</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
|
| |
|
| </P>
| | 3GP to AVI: |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>1.
| |
| Obter informação de um vídeo</B></FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"> <FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">ffmpeg
| |
| -i video.avi</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Este
| |
| comando mostra as informações implícitas de um determinado arquivo
| |
| de vídeo, tais como codecs de audio e vídeo utilizados em sua
| |
| composição.</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>2.
| |
| Transformar uma sequencia de imagens em um vídeo</B></FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"> <FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">ffmpeg
| |
| -f image2 -i <FONT COLOR="#ff0000"><B>fotos</B></FONT>%02d.jpg
| |
| video.mpg</FONT></FONT></P>
| |
|
| |
|
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| | ffmpeg -i clip.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 file.avi |
| </P>
| |
| <P CLASS="western" ALIGN=JUSTIFY STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Este
| |
| comando irá transformar todas as imagens do diretório corrente ou
| |
| indicado (no caso fotos01.jpg, fotos02.jpg, fotos03.jpg, etc que
| |
| estão na próprio diretório onde o usuário executa o comando) em
| |
| um arquivo de vídeo chamado </FONT></FONT><CODE CLASS="western"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">video.mpg.</FONT></FONT></CODE><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">
| |
| É importante dizer que no lugar de </FONT></FONT><FONT COLOR="#ff0000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>fotos
| |
| </B></FONT></FONT></FONT><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><SPAN STYLE="font-weight: normal">você
| |
| deve escrever o nome comum dos arquivos de imagem que estão no
| |
| diretório em questão, ou seja, se suas imagens tem como nome
| |
| pinguim001.jpg, pinguim002.jpg, etc, então vc deverá escrever o
| |
| comando assim: ffmpeg -f image2 -i </SPAN></FONT></FONT></FONT><FONT COLOR="#ff0000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>pinguim</B></FONT></FONT></FONT><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><SPAN STYLE="font-weight: normal">%</SPAN></FONT></FONT></FONT><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>03</B></FONT></FONT></FONT><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><SPAN STYLE="font-weight: normal">d.jpg
| |
| video.mpg, onde pinguim é o nome comum da sequencia de fotos e 03 é
| |
| o tamanho da casa numérica. </SPAN></FONT></FONT></FONT>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Exemplo
| |
| de uso do comando de conversão de fotos em vídeo no ffmpeg:
| |
|
| |
|
| <A HREF="http://www.youtube.com/watch#!v=rKhdGZm_zZw">http://www.youtube.com/watch#!v=rKhdGZm_zZw</A></FONT></FONT></P>
| | ffmpeg -i finalizado.mp4 -vcodec libx264 -preset slow -crf 22 -ar 44100 -s 480x270 -threads 0 -ab 128K outvideo4.mp4 |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Você
| |
| também pode fazer de maneira mais simples, utilizando outros
| |
| formatos de conversão suportados pelo ffmpeg. Ex: fmpeg -i
| |
| fotos%03d.jpg video.avi
| |
| Neste caso não há especificação do codec
| |
| de conversão a ser utilizado no processo e o vídeo final é
| |
| convertido para .avi.</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>3.
| |
| Transformar um vídeo em uma sequência de imagens</B></FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"> <FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">ffmpeg
| |
| -i video.mpg <FONT COLOR="#ff0000"><B>fotos</B></FONT>%<FONT COLOR="#ff0000"><B>02</B></FONT>d.jpg</FONT></FONT></P> | |
|
| |
|
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| | HandBrakeCLI -Z Universal -i myinputfile.mov -o myoutputfile.mp4 |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">Este
| |
| comando, ao contrário do anterior, gera imagens a partir de um
| |
| vídeo, ou seja, transforma um vídeo em imagens. O processo se dá
| |
| capturando frame a frame, quadro a quadro, as imagens que compõem o
| |
| vídeo. São suportados os formatos de imagem do tipo PGM, PPM, PAM,
| |
| PGMYUV, JPEG, GIF, PNG, TIFF, SGI. </FONT></FONT>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>4.
| |
| Codificar um vídeo para mp4 player, iPod/iPhone</B></FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"> <FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">ffmpeg
| |
| -i video.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 | |
| -cmp 2 -subcmp 2 -s 320x180 video_para_player.mp4</FONT></FONT></P>
| |
| <P CLASS="western" STYLE="margin-bottom: 0cm"><BR>
| |
| </P>
| |
| <P CLASS="western" ALIGN=JUSTIFY STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt">A
| |
| maior parte dos tocadores de vídeo portátil, os mp4 players, não
| |
| rodam formatos livres de encapsulamento de vídeo como .ogg e .ogv e
| |
| nem mesmo codificações bem difundidas como .avi. Estes aparelhos,
| |
| em sua maioria, rodam apenas arquivos .mp4 com audio codado em acc.
| |
| Esse comando faz a conversão de qualquer formato (.avi, .mod, .rmvb)
| |
| para .mp4 com audio em acc, possibilitando a leitura do arquivo de
| |
| vídeo em mp4 players e ipods/iphones.</FONT></FONT></P>
| |
|
| |
|
| | Vimeo recommend "640x480 (SD) / 1280x720 (HD) |
| | 640x480 for standard definition 4:3 video, 853x480 for widescreen DV, and 1280x720 or 1920x1080 for high definition." |
|
| |
|
|
| |
|
| ==Referências em vídeo:==
| | ffmpeg -i $1 -y -acodec libfaac -ab 128k -pass 2 -vcodec |
| | libx264 -threads 4 -b 1024kbps -flags +loop -cmp +chroma -partitions |
| | +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 - |
| | refs 5 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_thr |
| | eshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 $2 |
|
| |
|
| <div align=center>
| | yum update |
| | yum install gstreamer-{ffmpeg,plugins-{good,ugly,bad{,-free,-nonfree}}} |
|
| |
|
| <video type="youtube" id="gCCWucsvr_A" width="270" height="203" desc="[http://www.youtube.com/watch?v=gCCWucsvr_A Convertendo videos com ffmpeg ]" frame="true" position="right" size="full" allowfullscreen="true"/>
| |
|
| |
|
| <video type="youtube" id="WFHYV7N2nxU" width="270" height="203" desc="[http://www.youtube.com/watch?v=WFHYV7N2nxU Tutorial: Usando o FFmpeg para gravar um screencast no Linux]" frame="true" position="right" size="full" allowfullscreen="true"/>
| | ffmpeg -f dv |
| | -i video.dv |
| | -acodec libfaac |
| | -vcodec libx264 |
| | -s 640×360 |
| | -aspect 16:9 foo.mp4 |
|
| |
|
| <video type="youtube" id="a8gqOiiMC5s" width="270" height="203" desc="[http://www.youtube.com/watch?v=a8gqOiiMC5s Software Livre - Palestra: Video com softwares livres]" frame="true" position="right" size="full" allowfullscreen="true"/>
| |
|
| |
|
| </div>
| | -qscale 6 |
| | -sameq |
| | |
| | |
| | |
| | -threads 2 (no caso de ter dois nucleos de processador) |
| | |
| | -f dv -i input.dv -vcodec h264 -g 30 -deinterlace -b 900k -s 640x360 -padtop 60 -padbottom 60 -padcolor 000000 |
| | -aspect 4:3 |