-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug][ugoira] calculate_framerate #4421
Comments
I currently just replaced gallery-dl/gallery_dl/postprocessor/ugoira.py Line 179 in f9fb276
with if rate_out and rate_out != "1000/1": to fix it. |
BTW, I recommend to use {
"name": "ugoira",
"ffmpeg-args": ["-c:v", "libvpx", "-crf", "4", "-b:v", "5000k", "-hide_banner", "-loglevel", "error"],
"ffmpeg-twopass": true,
"keep-files": false,
"mtime": true
} |
I think, the more correct fix is to delete gallery-dl/gallery_dl/postprocessor/ugoira.py Lines 278 to 289 in f9fb276
|
Last time I checked, FFmpeg assumes an implicit 25 fps when no framerate is specified and it uses the edit: https://trac.ffmpeg.org/ticket/6128 The code should probably enforce an upper fps limit (60? 120?) and ignore frame delay values that differ from the rest (duration 2.0 when everything else is 0.041). I would generally recommend adding |
Hm, I tested it manually now, I need to duplicate the last frame two times to make ffmpeg to work properly. Although, it worked as expected when I use gallery-dl. ffmpeg -f concat -i ./ffconcat.txt -c:v libvpx -crf 4 -b:v 5000k -y o.webm ffconcat.txt
In this case
The result is a 2 seconds video. |
It's strange, but it's. For example, by default, for this https://www.pixiv.net/en/artworks/110956550 gallery-dl creates a file that looks correct, but it's 4 times bigger, since it uses 100 FPS. In this case [
{'file': '000000.jpg', 'delay': 80},
{'file': '000001.jpg', 'delay': 80},
{'file': '000002.jpg', 'delay': 90},
...
] GCD is With https://www.pixiv.net/en/artworks/110935156 is similar, also 100 FPS. Here is a uniform video: https://www.pixiv.net/en/artworks/110894780 ( Let's make it non-uniform for a test, just add frames[-1]["delay"] = 2000 as the first line in Now Encoding takes a lot of time and computing resources. And the result is a corrupted file. With the suggested fix — returning |
Tested this, yet again (*), and it still shows the same unwanted behavior: Dropped frames, wrong frame timestamps. https://www.pixiv.net/en/artworks/110912034, with 10ms and 20ms frame durations and 360 frames in total, results in a video with only 152 frames and the frame timestamps are all 40ms apart, i.e. 25fps.
gallery-dl repeats the last frame by default for this exact reason. ( gallery-dl/gallery_dl/postprocessor/ugoira.py Lines 253 to 254 in 8dceea3
(*) I've spent many, many hours over the last couple of years trying to find a general solution and to get FFmpeg to just apply the frame timestamps as given in an ffconcat.txt file, to no avail. To this days I still haven't found anything that works except |
I had forgotten about this, but it is already possible to skip the |
However, it will affect on the cases when UPD: UPD2: |
- when setting this option to a string value, pass -hide-banner and -loglevel to FFmpeg - change default to "error"
only return an output frame rate for non-uniform ugoira when the frame delay gcd is >= 10, i.e. 100 fps
Well, no. Using ffconcat.txt without explicit frame rate still defaults to 25fps. |
Looks good. By the way, a new related to Pixiv's "bug" is that it now does not return In the Android application, and therefore in gallery-dl too. SFW examples of the recently posted artworks:
There is the caption on the site (on desktop), but not in the application. *I don't even understand the logic when it happens. Some arts have "normal" I assume, it's not possible to do something with the Android application's API to "fix" it. So, just a note. |
Probably related to #4327 |
Ah, yeah, I see, there is also is entirely shadow banned images, they are hidden for Android API when you check user's profile. Shadow banned ("This work cannot be displayed"): My examples above have only shadow banned |
calculate_framerate
returns1000
fps ifuniform
isFalse
.For example, when
frames
array looks like this:calculate_framerate
returns(None, '1000/1')
and ffmpeg uses1000/1
as-r
argument, that results in a corrupted video file (also encoding is taking a lot of time).ffconcat.txt
contains the follow content:It seems, omitting
-r
should help.generates the more correct file, with the last frame is displaying for 2 seconds.
The text was updated successfully, but these errors were encountered: