diff --git a/app/routers/hosted_file.py b/app/routers/hosted_file.py index 50d9860..c65cee2 100644 --- a/app/routers/hosted_file.py +++ b/app/routers/hosted_file.py @@ -1376,6 +1376,7 @@ async def clip_video( start_time: str = Query(..., min_length=8, max_length=8), end_time: str = Query(..., min_length=8, max_length=8), reencode: bool = Query(False), + scale_down: bool = Query(False), commons: Common_Route_Params = Depends(common_route_params), ): @@ -1422,7 +1423,12 @@ async def clip_video( # NOTE: It seems very important that the -y argument is used with ffmpeg run by subprocess.run(). Otherwise the process will hang. # NOTE: This is a blocking process. It will take a while to complete. - if reencode: + if scale_down: + new_video_file_clip_filename = f'{filename_no_ext}_[clip_scaled].{to_type}' + log.debug(new_video_file_clip_filename) + + cmd = f'ffmpeg -hide_banner -loglevel error -nostats -y -i {full_file_path} -ss {start_time} -to {end_time} -vf "scale=w=1920:h=1080:force_original_aspect_ratio=decrease" -c:v libx264 -crf 23 -maxrate 2M -bufsize 2M -c:a copy -movflags +faststart {tmp_video_file_clip_path}' + elif reencode: new_video_file_clip_filename = f'{filename_no_ext}_[clip_reencode].{to_type}' log.debug(new_video_file_clip_filename)