Я пытаюсь скомпилировать набор jpg (снимки экрана камеры каждые 5 секунд) в mp4. Команда ffmpeg работает нормально, но в полученном mp4 отсутствуют некоторые изображения. Я заметил, что "дыры" создаются, когда jpg "frames" изменяется с 1 на 3 в последовательности jpg (см. Ниже результат file
, который показывает frames 1
для 1-го jpg и frames 3
для 2-го ):
$ file 20190110060113.jpg
20190110060113.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1280x720, frames 1
$ file 20190110060119.jpg
20190110060119.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1280x720, frames 3
А с ffmpeg
сеет:
ffmpeg -i 20190110060113.jpg -i 20190110060119.jpg
ffmpeg version 3.2.10-1~deb9u1~bpo8+1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-version='1~deb9u1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, image2, from '20190110060113.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 13395 kb/s
Stream #0:0: Video: mjpeg, gray(bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #1, image2, from '20190110060119.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 21463 kb/s
Stream #1:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified
Ниже приведена команда, которую я использую для компиляции mp4 из jpg:
ffmpeg -r 25 -f image2 -s 1280x720 -i /data/camipjpg/%*.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p /data/camipmgpg/20190110.mp4
Ради любопытства я исследовал и заметил, что на самом деле камера имеет 2 режима (дневной и ночной). Снимки, сделанные ночью, имеют frames 1
, в то время как снимки, сделанные в «дневном» режиме, имеют frames 3
.
Есть ли способ, которым ffmpeg может обрабатывать такого рода изменения jpg, чтобы объединить эти различные типы jpg?
Вот вывод:
ffmpeg version 3.2.10-1~deb9u1~bpo8+1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-version='1~deb9u1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[image2 @ 0x55aed5072ba0] Pattern type 'glob_sequence' is deprecated: use pattern_type 'glob' instead
Input #0, image2, from 'bcp/%*.jpg':
Duration: 00:09:07.24, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, gray(bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x55aed50b8300] using SAR=1/1
[libx264 @ 0x55aed50b8300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x55aed50b8300] profile High, level 3.1
[libx264 @ 0x55aed50b8300] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:gray to size:1280x720 fmt:yuvj422p.937x
[swscaler @ 0x55aed5b56e80] deprecated pixel format used, make sure you did set range correctly
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:grayrop=3023 speed=0.717x
Input stream #0:0 frame changed from size:1280x720 fmt:gray to size:1280x720 fmt:yuvj422p
[swscaler @ 0x55aed550fc20] deprecated pixel format used, make sure you did set range correctly
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:grayrop=6171 speed=0.625x
frame= 7156 fps= 16 q=-1.0 Lsize= 80319kB time=00:04:46.12 bitrate=2299.6kbits/s dup=0 drop=6525 speed=0.621x
video:80233kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.107008%
[libx264 @ 0x55aed50b8300] frame I:30 Avg QP:23.39 size: 82468
[libx264 @ 0x55aed50b8300] frame P:2917 Avg QP:26.31 size: 21742
[libx264 @ 0x55aed50b8300] frame B:4209 Avg QP:28.37 size: 3864
[libx264 @ 0x55aed50b8300] consecutive B-frames: 0.9% 49.6% 37.1% 12.4%
[libx264 @ 0x55aed50b8300] mb I I16..4: 7.3% 88.2% 4.6%
[libx264 @ 0x55aed50b8300] mb P I16..4: 2.7% 4.6% 0.4% P16..4: 37.5% 12.7% 10.4% 0.0% 0.0% skip:31.7%
[libx264 @ 0x55aed50b8300] mb B I16..4: 0.7% 1.1% 0.1% B16..8: 33.4% 2.7% 0.3% direct: 1.0% skip:60.5% L0:58.0% L1:37.1% BI: 4.9%
[libx264 @ 0x55aed50b8300] 8x8 transform intra:61.4% inter:88.3%
[libx264 @ 0x55aed50b8300] coded y,uvDC,uvAC intra: 34.6% 27.8% 4.0% inter: 16.8% 5.4% 0.1%
[libx264 @ 0x55aed50b8300] i16 v,h,dc,p: 36% 21% 17% 27%
[libx264 @ 0x55aed50b8300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 13% 42% 3% 4% 4% 5% 3% 4%
[libx264 @ 0x55aed50b8300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 12% 19% 6% 8% 9% 7% 6% 5%
[libx264 @ 0x55aed50b8300] i8c dc,h,v,p: 75% 11% 13% 1%
[libx264 @ 0x55aed50b8300] Weighted P-Frames: Y:34.5% UV:6.4%
[libx264 @ 0x55aed50b8300] ref P L0: 41.0% 13.8% 22.0% 17.7% 5.5%
[libx264 @ 0x55aed50b8300] ref B L0: 39.0% 50.9% 10.1%
[libx264 @ 0x55aed50b8300] ref B L1: 84.5% 15.5%
[libx264 @ 0x55aed50b8300] kb/s:2296.19
Заранее спасибо за помощь.