This commit is contained in:
Elghinnarisa
2022-08-01 20:39:41 +02:00
commit cccbd45f1b
7 changed files with 264 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
ffmpeg.exe
ffplay.exe
ffprobe.exe
sam_overlord_bluraysource - Copy.mkv
sam_overlord_bluraysource.mkv
test - Copy.mkv
test.mkv
test123.mkv
*.jpg

51
audio_rm_drop.py Normal file
View File

@@ -0,0 +1,51 @@
import re
import subprocess
import sys
from pathlib import Path
import os
regex = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
skipto = " -ss "
#droppedFile = "test.mkv"
del sys.argv[0]
for i, each in enumerate(sys.argv):
arg_list = 'ffprobe.exe -i "{each}"'.format(each=each)
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
subprocess_err = cmd.communicate()[1]
print("file", i+1)
for r, match in enumerate(regex.finditer(subprocess_err)):
print("Track", r, match.group(0))
print('\n')
x = (int(x) for x in input ("Enter tracks to keep: ").split())
track = "".join(" -map 0:a:{}".format(y) for y in x)
for each in sys.argv:
path = each
basename = os.path.basename(path)
arg_list = 'ffmpeg.exe -i "{each}" -map 0:v {track} -c copy -map 0:s "E:/Projects/ffmpeg_tests/audio_tracks/out/{basename}"'.format(each=each, track=track, basename=basename)
print(arg_list)
subprocess.run(arg_list)
input("press enter to exit")

38
bulk_covert_drop.py Normal file
View File

@@ -0,0 +1,38 @@
import subprocess
import sys
from pathlib import Path
import os
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
skipto = ""
duration = ""
del sys.argv[0]
#vid:
for each in sys.argv:
i = 0
path = each
basename = os.path.basename(path)
print(each)
arguments = ( "ffmpeg.exe ", " -i ", '"', each, '"',skipto, duration, " -map 0:v ", " -c:v libx265 -preset slow -crf 21 -x265-params "'level=51:no-sao:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6'" -pix_fmt yuv420p10le ", " -map 0:a -c:a copy -map 0:s -c:s copy -f matroska ",'"',"E:/Projects/python/ffmpeg_by_textfile/out_done/", basename, '"' )
arg_list = "".join(map(str, arguments))
print(arg_list)
#print(each)
subprocess.run(arg_list)
i += 1
k=input("press close to exit")

13
encode_By_file.py Normal file
View File

@@ -0,0 +1,13 @@
import subprocess
from tkinter import Y
with open ("input.txt" ,"r") as file:
lines = file.readlines()
lines = [line.rstrip() for line in lines]
lines = (line for line in lines if line)
print(lines)
for i in lines:
print(i)
subprocess.run(i)

48
screenshot_drop.py Normal file
View File

@@ -0,0 +1,48 @@
import re
import subprocess
import sys
from pathlib import Path
import os
regex = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
#droppedFile = ['sam_overlord_bluraysource.mkv']
del sys.argv[0]
number_of_ss=int(input("Number of ss: "))
print(number_of_ss)
for i, file in enumerate(sys.argv):
arg_list = 'ffprobe.exe -show_entries format=duration -i "{file}"'.format(file=file)
print(arg_list)
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
subprocess_std = cmd.communicate()[0]
print("stdout printing: " , subprocess_std)
video_duration = [int(s) for s in re.findall(r"[0-9]+", subprocess_std)][0]
print("video_duration: ", video_duration, "s")
duration_percent = video_duration / 100
print(duration_percent)
time = duration_percent * 15
skip = ((duration_percent * 90) - (duration_percent* 15)) / (number_of_ss -1)
for i in range(0, number_of_ss):
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -q:v 1 "{file}{i}.jpg"'.format(time=skip*i+time, file=file, i=i)
print(args)
run = subprocess.Popen(args)
print('\n')
input("press enter to exit")

54
sub-and-audio_drop.py Normal file
View File

@@ -0,0 +1,54 @@
import re
import subprocess
import sys
from pathlib import Path
import os
regex_subtitle = re.compile("Stream #0:\d(\(\w*\))?: Subtitle:.*")
regex_audio = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
skipto = " -ss "
#droppedFile = "test.mkv"
del sys.argv[0]
for i, each in enumerate(sys.argv):
arg_list = 'ffprobe.exe -i "{each}"'.format(each=each)
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
subprocess_err = cmd.communicate()[1]
print("file", i+1)
for r, match in enumerate(regex_audio.finditer(subprocess_err)):
print("Audio Track", r,": ", match.group(0))
for r, match in enumerate(regex_subtitle.finditer(subprocess_err)):
print("Subtitle Track", r,": ", match.group(0))
print('\n')
x = (int(x) for x in input ("Enter audio tracks to keep: ").split())
audio_track = "".join(" -map 0:a:{}".format(y) for y in x)
z = (int(z) for z in input ("Enter subtitle tracks to keep: ").split())
subtitle_track = "".join(" -map 0:s:{}".format(y) for y in z)
for each in sys.argv:
path = each
basename = os.path.basename(path)
arg_list = 'ffmpeg.exe -i "{each}" -map 0:v {audio_track} {subtitle_track} -c copy "E:/Projects/ffmpeg_tests/audio_tracks/out/{basename}"'.format(each=each, audio_track=audio_track, subtitle_track=subtitle_track, basename=basename)
print(arg_list)
subprocess.run(arg_list)
input("press enter to exit")

51
subtitle_rm_drop.py Normal file
View File

@@ -0,0 +1,51 @@
import re
import subprocess
import sys
from pathlib import Path
import os
regex = re.compile("Stream #0:\d(\(\w*\))?: Subtitle:.*")
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
skipto = " -ss "
#droppedFile = "test.mkv"
del sys.argv[0]
for i, each in enumerate(sys.argv):
arg_list = 'ffprobe.exe -i "{each}"'.format(each=each)
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
subprocess_err = cmd.communicate()[1]
print("file", i+1)
for r, match in enumerate(regex.finditer(subprocess_err)):
print("Track", r, match.group(0))
print('\n')
x = (int(x) for x in input ("Enter tracks to keep: ").split())
track = "".join(" -map 0:s:{}".format(y) for y in x)
for each in sys.argv:
path = each
basename = os.path.basename(path)
arg_list = 'ffmpeg.exe -i "{each}" -map 0:v {track} -c copy -map 0:a "E:/Projects/ffmpeg_tests/audio_tracks/out/{basename}"'.format(each=each, track=track, basename=basename)
print(arg_list)
subprocess.run(arg_list)
input("press enter to exit")