Estoy haciendo un timelapse con mi RPI en Python.
Para tomar imágenes y almacenarlas en carpetas: Cero problema. Pero para crear un vídeo con FFMPEG tengo un problema.
Después de X imágenes, el script inicia la creación de un vídeo. Da como resultado un video con solo el primer cuadro Y sobrescribe todas las imágenes en la carpeta con el primer cuadro (?!). Ningún mensaje de error.
Entonces ¿qué estoy haciendo mal?
system('ffmpeg -f image2 -framerate 1 -pattern_type glob -start_number %d -i /media/julien/USBKEY/capture_%d/%d/*.jpg -r 5 -c:v libx264 -pix_fmt yuv420p /media/julien/USBKEY/capture_%s/%d/out%d.mp4 -y' %( nom_premiere_image, nom_dossier, nom_sous_dossier, nom_dossier, nom_sous_dossier, nom_sous_dossier))
Comentarios de shell:
ffmpeg version 4.3.4-0+deb11u1+rpt1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Raspbian 10.2.1-6+rpi1)
WARNING: library configuration mismatch
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, image2, from '/media/julien/USBKEY/capture_1656104986/1/1656104987.jpg':
Duration: 00:00:01.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 720x640, 1 tbr, 1 tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #1:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #2:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #3:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Output #0, image2, to '/media/julien/USBKEY/capture_1656104986/1/1656104988.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: mjpeg, yuvj420p(pc), 720x640, q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Output #1, image2, to '/media/julien/USBKEY/capture_1656104986/1/1656104989.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #1:0: Video: mjpeg, yuvj420p(pc), 720x640, q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Output #2, image2, to '/media/julien/USBKEY/capture_1656104986/1/1656104990.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #2:0: Video: mjpeg, yuvj420p(pc), 720x640, q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[swscaler @ 0xad3880] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x73dbc0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x73dbc0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x73dbc0] 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=5 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 #3, mp4, to '/media/julien/USBKEY/capture_1656104986/1/out1.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #3:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 720x640, q=-1--1, 5 fps, 10240 tbn, 5 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= 1 fps=0.0 q=3.1 q=3.1 q=3.1 q=0.0 size=N/A time=00:00:01.00 bitrate=N/A dup=4 drop=0 speed=1.63x
frame= 1 fps=0.0 q=3.1 Lq=3.1 q=3.1 q=-1.0 size=N/A time=00:00:01.00 bitrate=N/A dup=4 drop=0 speed=1.08x
video:85kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x73dbc0] frame I:1 Avg QP:13.53 size: 29341
[libx264 @ 0x73dbc0] frame P:1 Avg QP:16.26 size: 385
[libx264 @ 0x73dbc0] frame B:3 Avg QP:15.28 size: 147
[libx264 @ 0x73dbc0] consecutive B-frames: 20.0% 0.0% 0.0% 80.0%
[libx264 @ 0x73dbc0] mb I I16..4: 8.7% 72.9% 18.4%
[libx264 @ 0x73dbc0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 9.1% 0.6% 0.2% 0.0% 0.0% skip:90.2%
[libx264 @ 0x73dbc0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 3.7% 0.1% 0.0% direct: 0.0% skip:96.2% L0: 9.8% L1:90.2% BI: 0.0%
[libx264 @ 0x73dbc0] 8x8 transform intra:72.9% inter:100.0%
[libx264 @ 0x73dbc0] coded y,uvDC,uvAC intra: 82.5% 71.1% 60.1% inter: 0.7% 0.4% 0.0%
[libx264 @ 0x73dbc0] i16 v,h,dc,p: 48% 12% 18% 22%
[libx264 @ 0x73dbc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 6% 35% 8% 4% 5% 3% 16% 4%
[libx264 @ 0x73dbc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 10% 24% 10% 6% 7% 5% 10% 3%
[libx264 @ 0x73dbc0] i8c dc,h,v,p: 56% 14% 19% 11%
[libx264 @ 0x73dbc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x73dbc0] ref B L0: 95.0% 5.0%
[libx264 @ 0x73dbc0] ref B L1: 98.4% 1.6%
[libx264 @ 0x73dbc0] kb/s:241.34
y lo mismo si uso directamente la consola
julien@raspberrypi:~ $ ffmpeg -f image2 -framerate 1 -pattern_type glob -start_number 1656104991 -i /media/julien/USBKEY/capture_1/1/*.jpg -r 5 -c:v libx264 -pix_fmt yuv420p /media/julien/USBKEY/capture_1/1/out1.mp4 -y
ffmpeg version 4.3.4-0+deb11u1+rpt1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Raspbian 10.2.1-6+rpi1)
configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
WARNING: library configuration mismatch
avutil configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avcodec configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avformat configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avdevice configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avfilter configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swscale configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
postproc configuration: --prefix=/usr --extra-version=0+deb11u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, image2, from '/media/julien/USBKEY/capture_1/1/1656104991.jpg':
Duration: 00:00:01.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 720x640 [SAR 1:1 DAR 9:8], 1 tbr, 1 tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #1:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #2:0 (mjpeg (native) -> mjpeg (native))
Stream #0:0 -> #3:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Output #0, image2, to '/media/julien/USBKEY/capture_1/1/1656104992.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: mjpeg, yuvj420p(pc), 720x640 [SAR 1:1 DAR 9:8], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Output #1, image2, to '/media/julien/USBKEY/capture_1/1/1656104993.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #1:0: Video: mjpeg, yuvj420p(pc), 720x640 [SAR 1:1 DAR 9:8], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Output #2, image2, to '/media/julien/USBKEY/capture_1/1/1656104994.jpg':
Metadata:
encoder : Lavf58.45.100
Stream #2:0: Video: mjpeg, yuvj420p(pc), 720x640 [SAR 1:1 DAR 9:8], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[swscaler @ 0x1b52780] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x17bb9f0] using SAR=1/1
[libx264 @ 0x17bb9f0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x17bb9f0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x17bb9f0] 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=5 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 #3, mp4, to '/media/julien/USBKEY/capture_1/1/out1.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #3:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 720x640 [SAR 1:1 DAR 9:8], q=-1--1, 5 fps, 10240 tbn, 5 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= 1 fps=0.0 q=3.1 q=3.1 q=3.1 q=0.0 size=N/A time=00:00:01.00 bitrate=N/frame= 1 fps=0.0 q=3.1 Lq=3.1 q=3.1 q=-1.0 size=N/A time=00:00:01.00 bitrate=N/A dup=4 drop=0 speed= 1x
video:85kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x17bb9f0] frame I:1 Avg QP:13.46 size: 29096
[libx264 @ 0x17bb9f0] frame P:1 Avg QP:16.32 size: 363
[libx264 @ 0x17bb9f0] frame B:3 Avg QP:14.14 size: 139
[libx264 @ 0x17bb9f0] consecutive B-frames: 20.0% 0.0% 0.0% 80.0%
[libx264 @ 0x17bb9f0] mb I I16..4: 9.2% 73.0% 17.8%
[libx264 @ 0x17bb9f0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 9.4% 0.6% 0.0% 0.0% 0.0% skip:90.1%
[libx264 @ 0x17bb9f0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 3.8% 0.1% 0.0% direct: 0.0% skip:96.1% L0:10.3% L1:89.7% BI: 0.0%
[libx264 @ 0x17bb9f0] 8x8 transform intra:73.0% inter:100.0%
[libx264 @ 0x17bb9f0] coded y,uvDC,uvAC intra: 79.4% 74.1% 62.8% inter: 0.4% 0.6% 0.0%
[libx264 @ 0x17bb9f0] i16 v,h,dc,p: 52% 17% 16% 15%
[libx264 @ 0x17bb9f0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 6% 34% 3% 9% 16% 4% 6% 4%
[libx264 @ 0x17bb9f0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 8% 22% 5% 12% 14% 4% 6% 4%
[libx264 @ 0x17bb9f0] i8c dc,h,v,p: 52% 16% 24% 8%
[libx264 @ 0x17bb9f0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x17bb9f0] ref B L1: 99.5% 0.5%
[libx264 @ 0x17bb9f0] kb/s:239.02
He probado esto y todo está bien:https://lindevs.com/install-ffmpeg-on-raspberry-pi/
Respuesta1
Solución rápida: coloque el nombre del archivo de entrada entre comillas simples ( ffmpeg … -i '…/*.jpg' …
).
Explicación más larga: el problema es que *
su shell expande el archivo a la lista de nombres de archivos antes de que ffmpeg los vea.
Entonces, tu comando original es incorrecto:
ffmpeg -f image2 -framerate 1 -pattern_type glob -start_number %d \
-i /media/julien/USBKEY/capture_%d/%d/*.jpg \
-r 5 -c:v libx264 -pix_fmt yuv420p \
/media/julien/USBKEY/capture_%s/%d/out%d.mp4 -y
Se llamará a ffmpeg con una lista de imágenes, esencialmente:
-i image1.jpg image2.jpg …
Para ffmpeg, el segundo archivo de imagen se interpreta como un nombre de archivo de salida. Como pasó -y
, ffmpeg felizmente sobrescribirá esta imagen. (Tenga en cuenta que, -y
como opción global, debe ir primero en la lista de argumentos).
Lo que necesitas hacer escita el comodín. De esta manera, su shell no lo interpretará ni lo pasará a ffmpeg, lo que expandirá internamente el comodín a la lista de imágenes en la carpeta.
ffmpeg -f image2 -framerate 1 -pattern_type glob -start_number %d \
-i '/media/julien/USBKEY/capture_%d/%d/*.jpg' \
-r 5 -c:v libx264 -pix_fmt yuv420p \
/media/julien/USBKEY/capture_%s/%d/out%d.mp4 -y
Ver también los ejemplos.aquí.
Para el código de su programa, recomendaría usar cadenas en formato Python y aprovechar el subprocess
módulo en lugar de llamar directamente system
:
import subprocess
subprocess.check_output(
f"ffmpeg -y -f image2 -framerate 1 -pattern_type glob -start_number {nom_premiere_image} -i '/media/julien/USBKEY/capture_{nom_dossier}/{nom_sous_dossier}/*.jpg' -r 5 -c:v libx264 -pix_fmt yuv420p /media/julien/USBKEY/capture_{nom_dossier}/{nom_sous_dossier}/out{nom_sous_dossier}.mp4", shell=True
)
Aún mejor, coloque todo el contenido del comando en una lista y páselo:
subprocess.check_output([
"ffmpeg", "-y", "-f", "image2", "-framerate", "1", "-pattern_type", "glob", "-start_number", nom_premiere_image,
"-i", f"'/media/julien/USBKEY/capture_{nom_dossier}/{nom_sous_dossier}/*.jpg'",
"-r", "5", "-c:v", "libx264", "-pix_fmt", "yuv420p",
f"/media/julien/USBKEY/capture_{nom_dossier}/{nom_sous_dossier}/out{nom_sous_dossier}.mp4",
])