Skip to content
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

Variable framerate fix for all branches #1190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions manimlib/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_resolution_directory(self):
that immediately contains the video file will be
480p15.
The file structure should look something like:

MEDIA_DIR
|--Tex
|--texts
Expand All @@ -175,7 +175,7 @@ def get_image_file_path(self):
written to.
It is usually named "images", but can be changed by changing
"image_file_path".

Returns
-------
str
Expand All @@ -186,7 +186,7 @@ def get_image_file_path(self):
def get_next_partial_movie_path(self):
"""
Manim renders each play-like call in a short partial
video file. All such files are then concatenated with
video file. All such files are then concatenated with
the help of FFMPEG.

This method returns the path of the next partial movie.
Expand Down Expand Up @@ -233,9 +233,9 @@ def add_audio_segment(self, new_segment,
time=None,
gain_to_background=None):
"""
This method adds an audio segment from an
This method adds an audio segment from an
AudioSegment type object and suitable parameters.

Parameters
----------
new_segment (AudioSegment)
Expand Down Expand Up @@ -277,7 +277,7 @@ def add_sound(self, sound_file, time=None, gain=None, **kwargs):
----------
sound_file (str)
The path to the sound file.

time (Union[float, int])
The timestamp at which the audio should be added.

Expand Down Expand Up @@ -497,6 +497,19 @@ def combine_movie_files(self):
combine_process = subprocess.Popen(commands)
combine_process.wait()

mp4fpsmod_file_path = os.path.join(
os.getcwd(),
'mp4fpsmod.exe' if os.name == 'nt' else 'mp4fpsmod'
)

fix_timestamps_process = subprocess.Popen([
mp4fpsmod_file_path,
'--fps', '0:' + str(self.scene.camera.frame_rate),
'--timescale', '15360',
movie_file_path, '--inplace'
])
fix_timestamps_process.wait()

if self.includes_sound:
sound_file_path = movie_file_path.replace(
self.movie_file_extension, ".wav"
Expand Down
Binary file added mp4fpsmod
Binary file not shown.
Binary file added mp4fpsmod.exe
Binary file not shown.