From 1088a8bbe77382275aa569bc9b48441e4916de87 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:56:07 +0200 Subject: [PATCH] Minor code improvements --- src/Autoload/Export.gd | 3 +++ src/UI/Timeline/LayerButton.gd | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Autoload/Export.gd b/src/Autoload/Export.gd index 15e7293a6..6619a80d2 100644 --- a/src/Autoload/Export.gd +++ b/src/Autoload/Export.gd @@ -547,6 +547,7 @@ func export_video(export_paths: PackedStringArray, project: Project) -> bool: if layer.audio.get_length() >= max_audio_duration: max_audio_duration = layer.audio.get_length() if audio_layer_count > 0: + # If we have audio layers, merge them all into one file. var amix_inputs_string := "amix=inputs=%s" % audio_layer_count var audio_file_path := temp_path_real.path_join("audio.mp3") ffmpeg_combine_audio.append_array( @@ -554,6 +555,8 @@ func export_video(export_paths: PackedStringArray, project: Project) -> bool: ) OS.execute(Global.ffmpeg_path, ffmpeg_combine_audio, [], true) var copied_video := temp_path_real.path_join("video." + export_paths[0].get_extension()) + + # Then mix the audio file with the video. DirAccess.copy_absolute(export_paths[0], copied_video) # ffmpeg -y -i video_file -i input_audio -c:v copy -map 0:v:0 -map 1:a:0 video_file var ffmpeg_final_video: PackedStringArray = [ diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index 1429f78a9..c77e4e0b0 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -91,8 +91,8 @@ func _play_audio() -> void: var audio_length := audio_player.stream.get_length() var final_frame := audio_length * Global.current_project.fps if Global.current_project.current_frame < final_frame: - var inverse_fps := 1.0 / Global.current_project.fps - var playback_position := Global.current_project.current_frame * inverse_fps + var seconds_per_frame := 1.0 / Global.current_project.fps + var playback_position := Global.current_project.current_frame * seconds_per_frame audio_player.play(playback_position) else: audio_player.stop()