5 Commits

Author SHA1 Message Date
kelciour 129a948f02 Revert "Replace Popen with check_call"
This reverts commit 34a99fdec0.
2021-02-14 17:31:02 +03:00
kelciour 34a99fdec0 Replace Popen with check_call 2020-10-20 16:39:56 +03:00
kelciour 15db01096f Escape double quotes in filenames 2020-10-20 15:50:28 +03:00
kelciour 588fa17eb2 Use --sort-files with rg 2020-10-20 15:08:42 +03:00
kelciour b8326b9c73 Map only video and audio streams 2020-10-10 13:09:20 +03:00
+4 -3
View File
@@ -196,7 +196,7 @@ def create_fragments(search_phrase, clips, export_mode, output_dir):
subprocess_call(cmd)
if export_mode["video"]:
cmd = ["ffmpeg", "-y", "-ss", str(ss), "-i", video_file, "-strict", "-2", "-t", str(t), "-map", "0", "-c:v", "libx264", "-preset", video_encoding_mode, "-c:a", "aac", "-ac", "2", "-af", af, fragment_filename + ".mp4"]
cmd = ["ffmpeg", "-y", "-ss", str(ss), "-i", video_file, "-strict", "-2", "-t", str(t), "-map", "0:v", "-map", "0:a", "-c:v", "libx264", "-preset", video_encoding_mode, "-c:a", "aac", "-ac", "2", "-af", af, fragment_filename + ".mp4"]
subprocess_call(cmd)
if export_mode["video-sub"]:
@@ -212,7 +212,7 @@ def create_fragments(search_phrase, clips, export_mode, output_dir):
vf = "subtitles=" + srt_filename + ":force_style='" + srt_style + "',setpts=PTS-STARTPTS"
af = "afade=t=in:st=%s:d=%s,afade=t=out:st=%s:d=%s,asetpts=PTS-STARTPTS" % (ss, t_fade, to - t_fade, t_fade)
cmd = ["ffmpeg", "-y", "-ss", str(ss), "-i", video_file, "-strict", "-2", "-t", str(t), "-map", "0", "-c:v", "libx264", "-preset", video_encoding_mode, "-c:a", "aac", "-ac", "2", "-vf", vf, "-af", af, "-copyts", fragment_filename + ".sub.mp4"]
cmd = ["ffmpeg", "-y", "-ss", str(ss), "-i", video_file, "-strict", "-2", "-t", str(t), "-map", "0:v", "-map", "0:a", "-c:v", "libx264", "-preset", video_encoding_mode, "-c:a", "aac", "-ac", "2", "-vf", vf, "-af", af, "-copyts", fragment_filename + ".sub.mp4"]
subprocess_call(cmd)
if export_mode["subtitles"]:
@@ -243,6 +243,7 @@ def play_clips(clips, ending_mode, mpv_options):
with open(pipe_name, "wb", 0) as f_pipe:
for clip_filename, clip_start, clip_end in clips:
clip_filename = clip_filename.replace("\\","/")
clip_filename = clip_filename.replace("\"", "\\\"")
cmd = ["loadfile", '"' + clip_filename + '"']
if ending_mode:
@@ -282,7 +283,7 @@ def main(media_dir, search_phrase, phrase_mode, phrases_gap, padding, limit, out
rg = shutil.which('rg')
if rg:
cmd = ["rg", "--no-heading", "--null-data", "-N", "-o", "-i", "-g", "*.txt", "-P", search_phrase_in_grep, media_dir]
cmd = ["rg", "--sort-files", "--no-heading", "--null-data", "-N", "-o", "-i", "-g", "*.txt", "-P", search_phrase_in_grep, media_dir]
else:
cmd = ["grep", "-r", "-z", "-o", "-i", "--include", "*.txt", "-P", search_phrase_in_grep, media_dir]
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, bufsize=-1)