ekisu / mpv-webm

Simple WebM maker for mpv, with no external dependencies.
MIT License
576 stars 33 forks source link

encode: patch libvpx 2-pass log file #69

Closed ekisu closed 4 years ago

ekisu commented 4 years ago

The pass log file generated by mpv doesn't contain the correct duration of each frame/aggregated sum, which leads to garbage encodes when used on the second pass.

Workaround this by writing the average frame duration on the frame stats, and the total encode duration on the EOS packet. This should be fairly accurate when dealing with constant frame rate videos, which, hopefully, is the most common case.

Closes #6 (after only two years :^)).

TheAMM commented 4 years ago

Oh, neat! Some while ago I had an mpv branch where I was poking at fixing the durations of the packets and got some sort of results but not outright fixes (I think?), and then forgot about it. Great workaround - should eventually fix the issue in mpv too.

ekisu commented 4 years ago

Yeah, I tried looking into a fix in mpv's source, however no solution I thought about seemed good enough - either guessing a timebase in which frames increased by exactly 1 time unit (which I don't think would work for every video), or hijacking the ticks_per_frame field to send the exact duration of each frame to libvpx (which doesn't seem to be the intended usage of the field, and probably would break other codecs).