master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.51k stars 155 forks source link

Cannot make extra splits smaller than 10 seconds #749

Closed tgurath closed 1 year ago

tgurath commented 1 year ago

I'd like to experiment with smaller chunk sizes to control keyframe placement in lieu of setting a shorter keyframe interval at the encoder level. I discovered Av1an intentionally doesn't allow extra splits smaller than 10 seconds.

https://github.com/master-of-zen/Av1an/blob/14875b4b62ce02ed69ce5c25e4716872b996a6ac/av1an/src/main.rs#L661

For scene detection, --min-scene-len allows chunks as small as 24 frames by default. Why not use that same setting for the minimum frames in extra splits rather than hard coding a seemingly arbitrary magic number? If there's a good reason for the 10s rule, please advise.

shssoichiro commented 1 year ago

I believe you're reading the code incorrectly, this default only applies if the user does not specify an extra split value. If the user specifies a value, it uses the user specified value, see the line immediately above the comment you linked.

tgurath commented 1 year ago

Having set it at 192 frames (~8s) and still getting lots of chunks 10s long was what led me here to investigate and report. I do see what you mean in reading the code. Perhaps the problem is downstream. On my most recent 45m video with extra split set to 192 frames, 96 of 571 chunks are 10s.

Though, I guess that could be where the source video has keyframes. The only thing I'm still using av1an for is scene detection, until I get around to replacing that last piece. I'm using mkvmerge to split which will only split at keyframes IIRC. When I have time in the next few days I'll write a script to parse the scenes file and see if av1an's output was as expected. I'll only update this if I find a problem.

shssoichiro commented 1 year ago

Would you mind posting your full av1an command line? (You can remove filenames etc if needed)

tgurath commented 1 year ago

could be where the source video has keyframes

This seems to be the cause. The series of 100+ episodes I've been working through consistently made 10s chunks even with extra split set smaller. I decided to run av1an's scene detection with my mkvmerge split command on an episode of the next show in my queue and that produced 8s chunks just fine. Sorry for the false alarm.