Bionus / imgbrd-grabber

Very customizable imageboard/booru downloader with powerful filenaming features.
https://www.bionus.org/imgbrd-grabber/
Apache License 2.0
2.5k stars 216 forks source link

[Error] [FFmpeg] "height not divisible by 2" or "width not divisible by 2" #3206

Open ProtagNeptune opened 3 months ago

ProtagNeptune commented 3 months ago
[11:37:11.342][Info] Loading image from `https://cdn.donmai.us/original/ad/54/ad54814d712b711ef45969d2b00d5ce9.webm` 1
[11:37:11.352][Info] Not enough information to directly load the image (from blacklist: 0 / from file url: 0 / from filename tags: 1/2)
[11:37:11.352][Info] Loading image details from `https://danbooru.donmai.us/posts/1745837`
[11:37:11.674][Info] Loading and saving image from `https://cdn.donmai.us/original/ad/54/__hijiri_byakuren_and_houjuu_nue_touhou_and_1_more_drawn_by_nuenya__ad54814d712b711ef45969d2b00d5ce9.webm` in `C:\Users\jelly\Grabber\#Downloads\vid\ad54814d712b711ef45969d2b00d5ce9.webm`
[11:37:12.880][Error] [FFmpeg] [libx264 @ 000001c9bcb44ac0] height not divisible by 2 (500x313)
[vost#0:0/libx264 @ 000001c9bcb4dd40] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 000001c9bcb32d80] Error sending frames to consumers: Generic error in an external library
[vf#0:0 @ 000001c9bcb32d80] Task finished with error code: -542398533 (Generic error in an external library)
[vf#0:0 @ 000001c9bcb32d80] Terminating thread with return code -542398533 (Generic error in an external library)
[vost#0:0/libx264 @ 000001c9bcb4dd40] Could not open encoder before EOF
[vost#0:0/libx264 @ 000001c9bcb4dd40] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 000001c9bcb4dd40] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 000001c9bcb44380] Nothing was written into output file, because at least one of its streams received no packets.
[11:37:12.882][Warning] Cleaning up failed conversion target file: `C:/Users/jelly/Grabber/#Downloads/vid\ad54814d712b711ef45969d2b00d5ce9.mp4`
[11:51:18.881][Info] Loading image from `https://cdn.donmai.us/original/00/69/00693777252cfccaaac3d1ce607d00c5.webm` 1
[11:51:18.891][Info] Not enough information to directly load the image (from blacklist: 0 / from file url: 0 / from filename tags: 1/2)
[11:51:18.892][Info] Loading image details from `https://danbooru.donmai.us/posts/1746288`
[11:51:19.225][Info] Loading and saving image from `https://cdn.donmai.us/original/00/69/__komeiji_koishi_touhou_drawn_by_miruki__00693777252cfccaaac3d1ce607d00c5.webm` in `C:\Users\jelly\Grabber\#Monitors\KomeijiSisters\vid\00693777252cfccaaac3d1ce607d00c5.webm`
[11:51:21.388][Error] [FFmpeg] [libx264 @ 00000233994c2b00] width not divisible by 2 (1179x1080)
[vost#0:0/libx264 @ 00000233994d58c0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 00000233994c3ac0] Error sending frames to consumers: Generic error in an external library
[vf#0:0 @ 00000233994c3ac0] Task finished with error code: -542398533 (Generic error in an external library)
[vf#0:0 @ 00000233994c3ac0] Terminating thread with return code -542398533 (Generic error in an external library)
[vost#0:0/libx264 @ 00000233994d58c0] Could not open encoder before EOF
[vost#0:0/libx264 @ 00000233994d58c0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 00000233994d58c0] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 00000233994f3dc0] Nothing was written into output file, because at least one of its streams received no packets.
[11:51:21.389][Warning] Cleaning up failed conversion target file: `C:/Users/jelly/Grabber/#Monitors/KomeijiSisters/vid\00693777252cfccaaac3d1ce607d00c5.mp4`
ProtagNeptune commented 3 months ago

Proposed Fix

  1. If height not divisible by 2 (500x313)
  2. Then remove 1 pixel of height (500x312)

ffmpeg -i input.webm -vf scale=500:312 -y output.mp4 or ffmpeg -i input.webm -vf crop=500:312 -y output.mp4


  1. If width not divisible by 2 (1179x1080)
  2. Then remove 1 pixel of width (1178x1080)

ffmpeg -i input.webm -vf scale=1178:1080 -y output.mp4 or ffmpeg -i input.webm -vf crop=1178:1080 -y output.mp4

ProtagNeptune commented 3 months ago

I don't know which one would be better in this case. 😕 https://ffmpeg.org/ffmpeg-filters.html#scale https://ffmpeg.org/ffmpeg-filters.html#crop

Edit: I asked Microsoft Copilot, cropping is probably better in this case.

image

ProtagNeptune commented 3 months ago

Proposed Fix

ffmpeg -i input.webm -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" -y output.mp4

image