Skip to content

Commit

Permalink
Enhance cover/poster generation
Browse files Browse the repository at this point in the history
  • Loading branch information
deldesir committed Jun 21, 2024
1 parent 46f0e6c commit 2bdd296
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions cps/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,16 @@ def sanitize_path(path):

def generate_video_cover(tmp_file_path):
ffmpeg_executable = os.getenv('FFMPEG_PATH', 'ffmpeg')
if not ffmpeg_executable:
log.error('FFMPEG_PATH environment variable is not set.')
return None

sanitized_input_path = sanitize_path(tmp_file_path)
output_file_path = os.path.splitext(tmp_file_path)[0] + '.cover.jpg'
sanitized_output_path = sanitize_path(output_file_path)
ffmpeg_output_file = os.path.splitext(tmp_file_path)[0] + '.cover.jpg'

ffmpeg_args = [
ffmpeg_executable,
'-i', sanitized_input_path,
'-i', tmp_file_path,
'-vf', 'fps=1,thumbnail,select=gt(scene\,0.1),scale=-1:720',
'-frames:v', '1',
'-vsync', 'vfr',
'-y',
sanitized_output_path
ffmpeg_output_file
]

try:
Expand Down

0 comments on commit 2bdd296

Please sign in to comment.