Eu tentei gravar áudio e vídeo ao mesmo tempo usando o FFmpeg. No entanto, vários problemas ocorreram. Aqui está o meu código:
ffmpeg -f alsa -ar 24000 -i plughw:1 -acodec aac -strict experimental -f video4linux2 -y -r 4 -i /dev/video0 -vf "drawtext=fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf:expansion=strftime:text='%Y-%m-%d %H\:%M\:%S': fontcolor=white:box=1:[email protected]:x=w-text_w:y=h-line_h" -vframes 20 -vcodec mpeg4 out.mp4
E o resultado que copiei é mostrado abaixo:
ffmpeg version N-61372-g1306359 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 19 2014 22:59:34 with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration: --enable-cross-compile --cross-prefix= --arch=armel --target-os=linux --prefix=/usr --enable-gpl --enable-libfreetype --enable-nonfree --enable-libaacplus --extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --extra-libs=-ldl
libavutil 52. 66.101 / 52. 66.101
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 34.101 / 55. 34.101
libavdevice 55. 11.100 / 55. 11.100
libavfilter 4. 3.100 / 4. 3.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'plughw:1':
Duration: N/A, start: 1395351824.134003, bitrate: 768 kb/s
Stream #0:0: Audio: pcm_s16le, 24000 Hz, stereo, s16, 768 kb/s
[video4linux2,v4l2 @ 0x21c1840] The driver changed the time per frame from 1/4 to 1/5
Input #1, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 15130.155369, bitrate: 24576 kb/s
Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 24576 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc
[Parsed_drawtext_0 @ 0x21c14f0] expansion=strftime is deprecated.
libaacplus: bad aac setting: br:128000, AACch:2, AACsr:24000
[libaacplus @ 0x21c6370] libaacplus doesn't support this output format!
Output #0, mp4, to 'out.mp4':
Stream #0:0: Video: mpeg4, yuv420p, 640x480, q=2-31, 200 kb/s, 90k tbn, 4 tbc
Stream #0:1: Audio: aac, 24000 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo -> mpeg4)
Stream #0:0 -> #0:1 (pcm_s16le -> libaacplus)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
Mostra que libaacplus doesn't support this output format!
. Funcionou muito bem enquanto eu estava mudando o formato de saída para mpg. No entanto, não havia som no arquivo de saída final. Não tenho certeza de quais partes dão errado. Alguém poderia me ajudar?
O libfaac
suporta mp4
?