AlUlkesh / sd_save_intermediate_images

Save intermediate images during the sampling process
The Unlicense
110 stars 17 forks source link

Filename not properly being passed to ffmpeg #19

Closed Luxter77 closed 1 year ago

Luxter77 commented 1 year ago

I believe the problem lies around this line.

https://github.com/AlUlkesh/sd_save_intermediate_images/blob/0faf746f9eaa6653d2c59150cb97531411f9828a/scripts/sd_save_intermediate_images.py#L41

PS D:\opt\DeepLearning\Voldy\stable-diffusion-webui> ffmpeg -benchmark -framerate 1 -i "outputs\img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-%03d-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png" -filter_complex "setpts=2.5*PTS [v4]; [v4]minterpolate=fps=3:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1" "outputs/img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.mp4"
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[image2 @ 000002c4746bb3c0] Could find no file with path 'outputs\img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-%03d-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png' and index in the range 0-4
outputs\img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-%03d-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png: No such file or directory

Where the actual filename should be 00000-000-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png

note the %03d that should be 000 (or the intermediate step number)

AlUlkesh commented 1 year ago

The %03d tells ffmpeg to search for files that have 3 digits there and use them all.

Please tick "debug" and post the whole console log, starting from webui-user.

Luxter77 commented 1 year ago

After re visiting the problem, I noticed that the problem was being caused by an old version of ffmpeg (4.2.3) packed on image magic being prioritized in the path.

After removing the old version, the video got generated properly.

Maybe a minimum supported version should be mentioned on the readme?

PS D:\opt\DeepLearning\Voldy\stable-diffusion-webui> where.exe ffmpeg.exe
C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\ffmpeg.exe
C:\ProgramData\chocolatey\bin\ffmpeg.exe
PS D:\opt\DeepLearning\Voldy\stable-diffusion-webui> & "C:\ProgramData\chocolatey\bin\ffmpeg.exe" -benchmark -framerate 1 -i "outputs\img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-%03d-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png" -filter_complex "setpts=2.5*PTS [v4]; [v4]minterpolate=fps=3:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1" "outputs/img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.mp4"
ffmpeg version 5.1.2-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, image2, from 'outputs\img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-%03d-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.png':
  Duration: 00:00:04.00, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: png, rgb24(pc), 87x120, 1 fps, 1 tbr, 1 tbn
Stream mapping:
  Stream #0:0 (png) -> setpts:default
  minterpolate:default -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 00000187bb444040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000187bb444040] profile High 4:4:4 Predictive, level 1.0, 4:4:4, 8-bit
[libx264 @ 00000187bb444040] 264 - core 164 r3099 e067ab0 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - 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=4 threads=4 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=3 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 'outputs/img2img-images\20230119224931_1girl blurry blurry background blurry foreground boots closed\intermediates\00000\00000-20230119224931_70_7.5_87_120_None_Euler a_135842745_3fd17af06c_2023-01-19_20230119225119.mp4':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv444p(tv, progressive), 87x120, q=2-31, 3 fps, 12288 tbn
    Metadata:
      encoder         : Lavc59.37.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   16 fps=0.0 q=-1.0 Lsize=      10kB time=00:00:04.33 bitrate=  19.3kbits/s speed=33.9x
video:9kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.797333%
bench: utime=0.062s stime=0.000s rtime=0.131s
bench: maxrss=33436kB
[libx264 @ 00000187bb444040] frame I:1     Avg QP:16.73  size:  4920
[libx264 @ 00000187bb444040] frame P:15    Avg QP:19.10  size:   261
[libx264 @ 00000187bb444040] mb I  I16..4: 22.9%  4.2% 72.9%
[libx264 @ 00000187bb444040] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4: 37.4%  5.4%  4.2%  0.0%  0.0%    skip:53.1%
[libx264 @ 00000187bb444040] 8x8 transform intra:4.2% inter:48.0%
[libx264 @ 00000187bb444040] coded y,u,v intra: 87.5% 61.5% 64.6% inter: 22.3% 1.8% 3.6%
[libx264 @ 00000187bb444040] i16 v,h,dc,p: 55%  9%  9% 27%
[libx264 @ 00000187bb444040] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 50%  0%  0%  0%  0% 12%  0% 12%
[libx264 @ 00000187bb444040] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 16%  8%  7%  6% 11%  6%  9%  9%
[libx264 @ 00000187bb444040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000187bb444040] ref P L0: 83.9%  7.9%  7.5%  0.7%
[libx264 @ 00000187bb444040] kb/s:13.25
AlUlkesh commented 1 year ago

Still odd. The %03d syntax has been in ffmpeg for at least 10 years. Also the ffmpeg version I am running is actually older than 4.2.3.

Well, glad you got it to work. I'll close the issue. Let's see if it comes up again.