我使用 Raspberry Pi 通过多路复用器同时从 2 个摄像头录制,这意味着我无法将其设置为直接录制 mp4,而是必须拍摄图像、切换摄像头,然后再拍摄另一张图像,然后将其转换为 mp4。有时它会拍摄损坏且无法读取的不良 jpg,我曾尝试找到解决方法,但似乎找不到一致拍照的方法,而且无论如何,跳帧也不是世界末日。
问题是,当我使用 FFmpeg 将这些图像转换为视频时,坏帧会导致它在帧之前过早停止。它没有出错,只是停止了。如果有一个标志可以跳过坏帧并继续编码视频的其余部分,那就太完美了。
我尝试使用:-err_detect active -fflags discardcorrupt 更改输入和输出帧速率
这是我正在使用的命令:
ffmpeg -framerate 1 -err_detect aggressive -fflags discardcorrupt -i recordings/current-recording/CameraA/%05d.jpg CameraA.mp4
以下是它在控制台中产生的效果:
Duration: 00:00:33.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 800x600, 1 fps, 1 tbr, 1 tbn, 1 tbc
File 'CameraA.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0xc0bac0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0xc0bac0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0xc0bac0] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=1 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
Output #0, mp4, to 'CameraA.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 800x600, q=-1--1, 1 fps, 16384 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 5 fps=2.3 q=-1.0 Lsize= 252kB time=00:00:02.00 bitrate=1030.5kbits/s speed=0.94x
video:251kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.350933%
[libx264 @ 0xc0bac0] frame I:1 Avg QP:15.01 size: 57504
[libx264 @ 0xc0bac0] frame P:1 Avg QP:15.04 size: 50197
[libx264 @ 0xc0bac0] frame B:3 Avg QP:14.46 size: 49452
[libx264 @ 0xc0bac0] consecutive B-frames: 20.0% 0.0% 0.0% 80.0%
[libx264 @ 0xc0bac0] mb I I16..4: 0.1% 99.3% 0.6%
[libx264 @ 0xc0bac0] mb P I16..4: 0.1% 91.8% 0.4% P16..4: 3.3% 2.6% 1.9% 0.0% 0.0% skip: 0.0%
[libx264 @ 0xc0bac0] mb B I16..4: 0.0% 53.5% 2.9% B16..8: 12.6% 11.7% 3.6% direct:15.2% skip: 0.3% L0:17.2% L1:27.6% BI:55.2%
[libx264 @ 0xc0bac0] 8x8 transform intra:97.2% inter:92.9%
[libx264 @ 0xc0bac0] coded y,uvDC,uvAC intra: 99.3% 44.5% 10.2% inter: 97.7% 87.9% 7.1%
[libx264 @ 0xc0bac0] i16 v,h,dc,p: 50% 0% 50% 0%
[libx264 @ 0xc0bac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 17% 35% 4% 3% 4% 5% 6% 9%
[libx264 @ 0xc0bac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 14% 17% 9% 8% 7% 9% 10% 11%
[libx264 @ 0xc0bac0] i8c dc,h,v,p: 44% 30% 22% 4%
[libx264 @ 0xc0bac0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0xc0bac0] ref B L0: 85.9% 14.1%
[libx264 @ 0xc0bac0] ref B L1: 78.5% 21.5%
[libx264 @ 0xc0bac0] kb/s:409.69```