3b1b / manim

Animation engine for explanatory math videos
MIT License
61.91k stars 5.76k forks source link

Manim generates variable framerate video instead of the constant value in the CONFIG #1000

Open qo4on opened 4 years ago

qo4on commented 4 years ago

FFMPEG concat function that Manim uses for partial movie files concatenation creates variational framerate video instead of constant. You can check it with these 2 video files 00000 and 00001:

ffmpeg -y -f concat -safe 0 -i file_list.txt -loglevel error -c copy test.mp4

file_list.txt:
file '00000.mp4'
file '00001.mp4'

00000.mp4:
Duration: 00:00:00.42, start: 0.000000, bitrate: 204 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 182 kb/s,
60 fps, 60 tbr, 15360 tbn, 120 tbc (default)

00001.mp4:
Duration: 00:00:01.63, start: 0.000000, bitrate: 58 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 48 kb/s,
60 fps, 60 tbr, 15360 tbn, 120 tbc (default)

The result has a different framerate:

test.mp4:
Duration: 00:00:02.05, start: 0.000000, bitrate: 85 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 76 kb/s,
59.99 fps, 60 tbr, 15360 tbn, 120 tbc (default)

I checked for a VFR:

ffmpeg -i 00000.mp4 -vf vfrdet -an -f null -
VFR:0.000000 (0/24)

ffmpeg -i 00001.mp4 -vf vfrdet -an -f null -
VFR:0.000000 (0/97)

ffmpeg -i test.mp4 -vf vfrdet -an -f null -
VFR:0.016393 (2/120) min: 256 max: 261 avg: 258

Manim generates two CFR inputs for ffmpeg concatenation and one VFR output of this concatenation. Is it possible to get VFR:0 after the concatenation?

kevkevinpal commented 4 years ago

do you know if this is because the first video is less than a second cause it may be the way that they calculate fps, Is this a big issue I'm not sure if having our fps off by .01 is bad or does it compound over multiple concatenation of videos?

qo4on commented 4 years ago

It is a ffmpeg concat bug.

3b1b commented 3 years ago

The defaults have since changed so that it won't use the contact function but just writes to a single final movie file. It's still an option to write the animations to separate files and have them concat, but presumably in that case the user would have a reason for wanting the separate files in that case, which are individually constant frame rate (I believe).

How much of an issue is it if the default now is CFR, and that if one wants to export into many smaller video files it's an option, but default concatenation between those is no longer CFR?