Skip to content

Commit

Permalink
Show progres for final transcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicer86 committed Dec 28, 2024
1 parent d5e3f70 commit 4938561
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions twotone/tools/transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _calculate_quality(self, original, transcoded):

return None

def _transcode_video(self, input_file, output_file, crf, preset, input_params=[], output_params=[]):
def _transcode_video(self, input_file, output_file, crf, preset, input_params=[], output_params=[], show_progress=False):
"""Encode video with a given CRF, preset, and extra parameters."""
args = [
"-v", "error", "-stats", "-nostdin",
Expand All @@ -69,7 +69,7 @@ def _transcode_video(self, input_file, output_file, crf, preset, input_params=[]
output_file
]

result = utils.start_process("ffmpeg", args)
result = utils.start_process("ffmpeg", args, show_progress=show_progress)
self._validate_ffmpeg_result(result)

def _extract_segment(self, video_file, start_time, end_time, output_file):
Expand Down Expand Up @@ -231,8 +231,7 @@ def _final_transcode(self, input_file, crf, extra_params):
logging.info(f"Starting final transcoding with CRF: {
crf} and extra params: {extra_params}")
final_output_file = f"{basename}.temp.{ext}"
self._transcode_video(input_file, final_output_file,
crf, "veryslow", extra_params)
self._transcode_video(input_file, final_output_file, crf, "veryslow", extra_params, show_progress=True)

original_size = os.path.getsize(input_file)
final_size = os.path.getsize(final_output_file)
Expand Down

0 comments on commit 4938561

Please sign in to comment.