-
Notifications
You must be signed in to change notification settings - Fork 57
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
Output files including file extensions #76
Comments
I made a simple workaround in bash until this request is implemented...
You can set a function alias for this in your .bashrc
then use it like this
|
Had the same problem here, but on windows. I'm using PowerShell in Powertoys and this works, too:
This goes down all folders and executes on every mp4 file. |
@pascaldulieu here's a quick hack. It adds a keep_extension.patchdiff --git a/vcsi/vcsi.py b/vcsi/vcsi.py
index cf9d934..349a77c 100755
--- a/vcsi/vcsi.py
+++ b/vcsi/vcsi.py
@@ -10,6 +10,7 @@ import os
import shutil
import subprocess
import sys
+from pathlib import Path
from argparse import ArgumentTypeError
from concurrent.futures import ThreadPoolExecutor
from copy import deepcopy
@@ -1609,6 +1610,14 @@ def main():
default="{TIME}",
dest="timestamp_format"
)
+ parser.add_argument(
+ "-k",
+ "--keep-video-ext",
+ help="Preserve the video file's original extension, e.g. 'video.mp4.png'",
+ action="store_true",
+ default=False,
+ dest="keep_ext",
+ )
args = parser.parse_args()
@@ -1670,9 +1679,14 @@ def process_file(path, args):
output_path = args.output_path
if not output_path:
- output_path = path + "." + args.image_format
+ output_path = path
elif os.path.isdir(output_path):
- output_path = os.path.join(output_path, os.path.basename(path) + "." + args.image_format)
+ output_path = os.path.join(output_path, os.path.basename(path))
+
+ if not args.keep_ext:
+ output_path = str(Path(output_path).with_suffix("." + args.image_format))
+ else:
+ output_path += f".{args.image_format}"
if args.no_overwrite:
if os.path.exists(output_path):
@@ -1784,13 +1798,23 @@ def process_file(path, args):
if thumbnail_output_path is not None:
os.makedirs(thumbnail_output_path, exist_ok=True)
print("Copying thumbnails to {} ...".format(thumbnail_output_path))
- for i, frame in enumerate(sorted(selected_frames, key=lambda x_frame: x_frame.timestamp)):
+ for i, frame in enumerate(
+ sorted(selected_frames, key=lambda x_frame: x_frame.timestamp)
+ ):
print(frame.filename)
thumbnail_file_extension = frame.filename.lower().split(".")[-1]
- thumbnail_filename = "{filename}.{number}.{extension}".format(filename=os.path.basename(path),
- number=str(i).zfill(4),
- extension=thumbnail_file_extension)
- thumbnail_destination = os.path.join(thumbnail_output_path, thumbnail_filename)
+ if args.keep_ext:
+ fname_base: str = os.path.basename(path)
+ else:
+ fname_base: str = str(Path(path).stem)
+ thumbnail_filename = "{filename}.{number}.{extension}".format(
+ filename=fname_base,
+ number=str(i).zfill(4),
+ extension=thumbnail_file_extension,
+ )
+ thumbnail_destination = os.path.join(
+ thumbnail_output_path, thumbnail_filename
+ )
shutil.copyfile(frame.filename, thumbnail_destination)
print("Cleaning up temporary files...") |
This sounds great! |
Would it be possible to have it so the file extension is not added to the output file name?
for example, if I process Test.mp4 the output file will be Test.mp4.jpg.
Would it be possible to have a flag to remove the video file extension from the output so it would just show Test.jpg?
The text was updated successfully, but these errors were encountered: