summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ffmpeg-embed-cmd14
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/ffmpeg-embed-cmd b/bin/ffmpeg-embed-cmd
index 83b6c1e..6950003 100755
--- a/bin/ffmpeg-embed-cmd
+++ b/bin/ffmpeg-embed-cmd
@@ -1,16 +1,26 @@
#!/usr/bin/env python3
+import os
+import shlex
import subprocess
import sys
if __name__ == '__main__':
ffmpeg_cli = ['ffmpeg'] + sys.argv[1:]
+
if len(ffmpeg_cli) > 1:
ffmpeg_ver = subprocess.run(['ffmpeg', '-version'], capture_output=True, text=True)
ffmpeg_ver = ffmpeg_ver.stdout.splitlines()[0]
- ffmpeg_str = ' '.join(ffmpeg_cli)
+ ffmpeg_str = ' '.join(shlex.quote(arg) for arg in ffmpeg_cli)
ffmpeg_cli[-1:-1] = [
'-metadata', f'FFMPEG_VER={ffmpeg_ver}',
'-metadata', f'FFMPEG_CMD={ffmpeg_str}',
]
- subprocess.run(ffmpeg_cli)
+
+ out_path = ffmpeg_cli[-1]
+ out_dir = os.path.dirname(out_path)
+ if out_dir:
+ os.makedirs(out_dir, exist_ok=True)
+
+ result = subprocess.run(ffmpeg_cli)
+ sys.exit(result.returncode)