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

Generate cover [a.k.a. thumbnail/poster] for video manually uploaded #196

Merged
merged 13 commits into from
Jun 21, 2024
7 changes: 5 additions & 2 deletions cps/uploader.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same video
image

Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ def generate_video_cover(tmp_file_path):
ffmpeg_args = [
ffmpeg_executable,
'-i', tmp_file_path,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defensive programming reminder: Sanitize the file path to prevent command injection

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll use shlex for now. Should be safe on POSIX compliant shells. (Done in f8c39f2)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a general warning that shlex.quote() is not bulletproof:

3a965f8

(Though it's probably good enough for path sanitizing!)

'-vframes', '1',
'-y', ffmpeg_output_file
'-vf', 'fps=1,thumbnail,select=gt(scene\,0.1),scale=-1:720',
'-frames:v', '1',
'-vsync', 'vfr',
'-y',
ffmpeg_output_file
]

try:
Expand Down