PixivUtil2 icon indicating copy to clipboard operation
PixivUtil2 copied to clipboard

Feature suggestion - Proper support for H264 in mp4

Open UpscaleAnon opened this issue 1 year ago • 3 comments

Prerequisites

  • [Yes] Did you read FAQ section in readme.md?
  • [Yes] Did you test with the latest releases or commit ?
  • [Yes] Did you search for existing issues in Issues?

Description

The program supports H264 by simply editing the ffmpeg parameter, however, if a pixiv animation happens to be odd resolution like 501x501 instead of 500x500, then it will fail and stop doing anything. This is because the H264 codec does not support odd pixels. VP9 in webm works fine because that supports it, but I'd rather use H264. So I'm wondering, is there a possibility that you can implement something that for example detects if the resolution is an odd number, it lowers it by 1? Like it detects 693x759 so it would apply -vf scale=692:758? I know I can probably do this in batch and somewhat automate it, but not really useful unless I tell it to first download it all, manually extract the frames from the zip and then convert it, which would be a pain when downloading thousands of animations. It would be really nice if PixivUtil had something like this. Or at the very least have a fallback to VP9. If H264 doesn't work, then switch back to VP9

UpscaleAnon avatar Jul 19 '23 00:07 UpscaleAnon

You could always skip encoding Ugoira and use postProcessingCmd to a script that handles Ugoira in your own way for the time being right now.

EDIT: I have also never uploaded a Ugoira before, will Pixiv allow odd resolutions?

biggestsonicfan avatar Jul 19 '23 02:07 biggestsonicfan

postProcessingCmd

I have no idea what that is and how to do that.

will Pixiv allow odd resolutions?

It does, I've seen plenty animations that have odd resolutions. Or atleast they used to. I haven't checked the dates of the stuff so for all I know maybe they allowed it before but not anymore, but don't delete old posts that do.

UpscaleAnon avatar Jul 19 '23 11:07 UpscaleAnon

Hi,

a couple of months ago, I've switched to encoding the ugoira into av1 (sorry for the last weird thread ^_^; ), and I had the same issue with the odd resolution. My quickfix solution was to use this in the config:

ffmpegParam = -vf scale=iw*2:ih*2,boxblur=1:1 -crf 30 -sws_flags lanczos+full_chroma_inp -pix_fmt yuv420p10le

Sure, it blows up the image in the dumbest manner by simple x2 resize, but it gets the job done as quick preview while I keep the og ugoira.zip file as well.

You might want to check the parameters with the ffmpeg doc though. I don't know if they will work with x264 and mp4 containers but I don't see why they wouldn't, either.

mugi-jiichan avatar Jul 21 '23 11:07 mugi-jiichan