Skip to content

enh(mediafiles): eliminate shell=True subprocess calls - #3388

Open
MichaIng wants to merge 1 commit into
devfrom
noshell
Open

enh(mediafiles): eliminate shell=True subprocess calls#3388
MichaIng wants to merge 1 commit into
devfrom
noshell

Conversation

@MichaIng

@MichaIng MichaIng commented Jul 1, 2026

Copy link
Copy Markdown
Member
  • For the ffmpeg codecs list with hardcoded command, it was safe but unnecessary.
  • When defining the command as list in the first place, shlex.quote() is not needed, and .split() can be skipped.
  • For timelapse movies from a list of pictures, the FFmpeg's concat extension can be used instead of image2pipe, which allows to pipe the list of files to ffmpeg from Python, rather than the content of the files from shell, so that shell=True is not needed. Adding -y to let ffmpeg overwrite an existing output file automatically, renders the prior file removal obsolete as well.

This commit adds some typing as well.

@MichaIng MichaIng added this to the v0.45.0 milestone Jul 1, 2026
@MichaIng
MichaIng force-pushed the noshell branch 2 times, most recently from 12707e7 to 54259d1 Compare July 1, 2026 21:46

@zagrim zagrim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

* For the ffmpeg codecs list with hardcoded command, it was safe but unnecessary.
* When defining the command as list in the first place, `shlex.quote()` is not needed, and `.split()` can be skipped.
* For timelapse movies from a list of pictures, the FFmpeg's concat extension can be used instead of image2pipe, which allows to pipe the list of files to ffmpeg from Python, rather than the content of the files from shell, so that shell=True is not needed. Adding `-y` to let ffmpeg overwrite an existing output file automatically, renders the prior file removal obsolete as well.

This commit adds some typing as well.

Signed-off-by: MichaIng <micha@dietpi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants