ffmpeg管道摄像头流输入到两个输出包含音频的图像和视频

时间:2017-09-23 14:59:09

标签: ffmpeg raspberry-pi

我有下一个命令:

sudo ffmpeg -ar 44100 -ac 2 -f alsa -i hw:1,0 -f v4l2 -codec:v h264       -codec:a aac -ab 128k -framerate 30 -video_size hd720 -itsoffset 0.5 -i /dev/video0 -vf fps=1 snapsh%d.png -f mpeg -b:v 5000k -copyinkf -codec:v copy -codec:a aac -ab 128k -g 10 - | sudo ffmpeg -y -i - out.mp4

和目标是同时录制音频和视频,并输出管道以便能够拍摄输出视频的screnshots。我使用的是罗技网络摄像头,覆盆子pi 3,ffmpeg的最新版本,支持h264和alsa支持。

但它对我不起作用:(,我认为它正在考虑音频流的问题,但我还能找到解决方案。 有人有什么建议吗?谢谢

这是输出

ffmpeg version N-86204-g8794cfb Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --enable-nonfree --enable-gpl --enable-libx264 --enable-libfdk-aac
libavutil 55. 63.100 / 55. 63.100
libavcodec 57. 96.101 / 57. 96.101
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 90.100 / 6. 90.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
Duration: N/A, start: 1506129856.832380, bitrate: 1024 kb/s
Stream #0:0: Audio: pcm_s16le, 32000 Hz, stereo, s16, 1024 kb/s
Input #1, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1821.745623, bitrate: N/A
Stream #1:0: Video: h264 (Constrained Baseline), yuvj420p(pc, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1000k tbn, 60 tbc
Stream mapping:
Stream #1:0 -> #0:0 (h264 (native) -> png (native))
Stream #1:0 -> #1:0 (copy)
Stream #0:0 -> #1:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x23a2710] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[swscaler @ 0x25d4f40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x25d4f40] No accelerated colorspace conversion found from yuv420p to rgb24.
Output #0, image2, to '/home/pi/proyecto-aula-master/Videos/snapsh%d.png':
Metadata:
encoder : Lavf57.72.101
Stream #0:0: Video: png, rgb24, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc57.96.101 png
[alsa @ 0x23904f0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[mpeg @ 0x23a48d0] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #1, mpeg, to 'pipe:':
Metadata:
encoder : Lavf57.72.101
Stream #1:0: Video: h264 (Constrained Baseline), yuvj420p(pc, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 5000 kb/s, 30 fps, 30 tbr, 90k tbn, 30 tbc
Stream #1:1: Audio: aac (LC), 32000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.96.101 aac
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45000, current: 29998; changing to 45001. This may result in incorrect timestamps in the output file.
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45001, current: 32879; changing to 45002. This may result in incorrect timestamps in the output file.
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45002, current: 35759; changing to 45003. This may result in incorrect timestamps in the output file.
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45003, current: 38999; changing to 45004. This may result in incorrect timestamps in the output file.
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45004, current: 41880; changing to 45005. This may result in incorrect timestamps in the output file.
[mpeg @ 0x23a48d0] Non-monotonous DTS in output stream 1:0; previous: 45005, current: 44759; changing to 45006. This may result in incorrect timestamps in the output file.
frame= 0 fps=0.0 q=0.0 q=-1.0 size=N/A time=00:00:01.09 bitrate=N/A speed=2.0frame= 2 fps=1.8 q=0.0 q=-1.0 size=N/A time=00:00:01.76 bitrate=N/A dup=1 dro[alsa @ 0x23904f0] ALSA buffer xrun.
frame= 3 fps=1.8 q=-0.0 q=-1.0 size=N/A time=00:00:02.19 bitrate=N/A dup=1 drframe= 3 fps=1.4 q=-0.0 q=-1.0 size=N/A time=00:00:02.86 bitrate=N/A dup=1 drframe= 4 fps=1.5 q=-0.0 q=-1.0 size=N/A time=00:00:03.36 bitrate=N/A dup=1 drframe= 4 fps=1.3 q=-0.0 q=-1.0 size=N/A time=00:00:03.86 bitrate=N/A dup=1 drframe= 5 fps=1.4 q=-0.0 q=-1.0 size=N/A time=00:00:04.36 bitrate=N/A dup=1 drframe= 5 fps=1.2 q=-0.0 q=-1.0 size=N/A time=00:00:04.86 bitrate=N/A dup=1 dr[alsa @ 0x23904f0] ALSA buffer xrun.
[mp2 @ 0x262b660] Header missing
frame= 6 fps=1.2 q=-0.0 q=-1.0 size=N/A time=00:00:05.38 bitrate=N/A dup=1 drframe= 7 fps=1.3 q=-0.0 q=-1.0 size=N/A time=00:00:06.16 bitrate=N/A dup=1 drframe= 7 fps=1.2 q=-0.0 q=-1.0 size=N/A time=00:00:06.79 bitrate=N/A dup=1 drframe= 8 fps=1.2 q=-0.0 q=-1.0 size=N/A time=00:00:07.29 bitrate=N/A dup=1 drframe= 8 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:07.79 bitrate=N/A dup=1 dr[alsa @ 0x23904f0] ALSA buffer xrun.
frame= 9 fps=1.2 q=-0.0 q=-1.0 size=N/A time=00:00:08.16 bitrate=N/A dup=1 dr[mpeg @ 0x262a1c0] DTS discontinuity in stream 1: packet 6 with DTS 92886, packet 7 with DTS 95880
frame= 9 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:08.38 bitrate=N/A dup=1 drframe= 10 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:09.19 bitrate=N/A dup=1 drframe= 10 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:09.96 bitrate=N/A dup=1 drframe= 11 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:10.39 bitrate=N/A dup=1 drframe= 11 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:10.96 bitrate=N/A dup=1 dr[alsa @ 0x23904f0] ALSA buffer xrun.
frame= 12 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:11.40 bitrate=N/A dup=1 drframe= 12 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:12.06 bitrate=N/A dup=1 drframe= 13 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:12.56 bitrate=N/A dup=1 drframe= 13 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:13.06 bitrate=N/A dup=1 drframe= 14 fps=1.1 q=-0.0 q=-1.0 size=N/A time=00:00:13.56 bitrate=N/A dup=1 drframe= 14 fps=1.0 q=-0.0 q=-1.0 size=N/A time=00:00:14.06 bitrate=N/A dup=1 dr[alsa @ 0x23904f0] ALSA buffer xrun.
[mpeg @ 0x262a1c0] decoding for stream 0 failed
[mpeg @ 0x262a1c0] Could not find codec parameters for stream 0 (Audio: mp2, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpeg, from 'pipe:':
Duration: N/A, start: 0.500000, bitrate: N/A
Stream #0:0[0x1c0]: Audio: mp2, 0 channels, s16p
Stream #0:1[0x1e2]: Video: h264 (Constrained Baseline), yuvj420p(pc, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (mp2 (native) -> aac (native))
[mp2 @ 0x262cde0] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x26417d0] using SAR=1/1
[libx264 @ 0x26417d0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x26417d0] profile High, level 3.1
[libx264 @ 0x26417d0] 264 - core 150 r2833 df79067 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
frame= 19 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 36 fps= 34 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 47 fps=9.5 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 52 fps=9.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 56 fps=9.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 60 fps=8.8 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 64 fps=8.6 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 69 fps=7.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 71 fps=7.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 73 fps=6.9 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 76 fps=6.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 80 fps=6.3 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 82 fps=5.8 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 85 fps=5.8 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 87 fps=5.7 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 89 fps=5.4 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 90 fps=5.3 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 93 fps=5.3 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 95 fps=5.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 97 fps=5.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 99 fps=5.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 102 fps=5.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 103 fps=4.9 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 105 fps=4.7 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 108 fps=4.7 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 110 fps=4.7 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 112 fps=4.6 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 114 fps=4.5 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 117 fps=4.5 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 120 fps=4.5 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 122 fps=4.4 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 123 fps=4.4 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 126 fps=4.3 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 128 fps=4.3 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 130 fps=4.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 132 fps=4.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 135 fps=4.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbframe= 138 fps=4.2 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbToo many packets buffered for output stream 0:0.
[libx264 @ 0x26417d0] frame I:1 Avg QP:16.64 size: 29761
[libx264 @ 0x26417d0] frame P:36 Avg QP:21.71 size: 9196
[libx264 @ 0x26417d0] frame B:92 Avg QP:24.13 size: 4641
[libx264 @ 0x26417d0] consecutive B-frames: 0.8% 0.0% 32.1% 67.2%
[libx264 @ 0x26417d0] mb I I16..4: 24.3% 49.7% 25.9%
[libx264 @ 0x26417d0] mb P I16..4: 11.2% 10.0% 0.2% P16..4: 41.0% 6.2% 3.7% 0.0% 0.0% skip:27.7%
[libx264 @ 0x26417d0] mb B I16..4: 5.0% 5.5% 0.0% B16..8: 40.1% 3.0% 0.2% direct: 1.6% skip:44.6% L0:59.9% L1:38.4% BI: 1.7%
[libx264 @ 0x26417d0] 8x8 transform intra:49.7% inter:79.4%
[libx264 @ 0x26417d0] coded y,uvDC,uvAC intra: 10.0% 13.9% 0.3% inter: 8.6% 11.3% 0.0%
[libx264 @ 0x26417d0] i16 v,h,dc,p: 43% 24% 16% 16%
[libx264 @ 0x26417d0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 18% 36% 1% 0% 0% 1% 0% 1%
[libx264 @ 0x26417d0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 50% 19% 16% 3% 2% 2% 3% 3% 3%
[libx264 @ 0x26417d0] i8c dc,h,v,p: 70% 14% 16% 0%
[libx264 @ 0x26417d0] Weighted P-Frames: Y:2.8% UV:0.0%
[libx264 @ 0x26417d0] ref P L0: 39.8% 7.3% 42.5% 10.4% 0.0%
[libx264 @ 0x26417d0] ref B L0: 44.7% 41.0% 14.2%
[libx264 @ 0x26417d0] ref B L1: 70.0% 30.0%
[libx264 @ 0x26417d0] kb/s:1465.58
Exiting normally, received signal 2.

0 个答案:

没有答案