Skip to content

Commit

Permalink
v4.06
Browse files Browse the repository at this point in the history
- Batch window, when all tracks loaded into the batch window are identical tracks (for a series or something) it'll show additional information for track 1, track 2, etc...
If all tracks are not identical it'll work like before
- Fixed a small bug created earlier for file dropping
  • Loading branch information
jessielw committed Jan 12, 2023
1 parent ec0c7d9 commit 948a38b
Showing 1 changed file with 54 additions and 8 deletions.
62 changes: 54 additions & 8 deletions FFMPEGAudioEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
)

# Set main window title variable
main_root_title = "FFMPEG Audio Encoder v4.05"
main_root_title = "FFMPEG Audio Encoder v4.06"

# default an empty variable to be updated based off user input
batch_mode = None
Expand Down Expand Up @@ -1819,7 +1819,10 @@ def close_audio_cancel(): # Function is used when 'Cancel' is clicked
else:
delay_string = str("[delay 0ms]")
else:
if track_selection_mediainfo.delay_relative_to_video is not None:
if (
track_selection_mediainfo.delay_relative_to_video
is not None
):
delay_string = f"[delay {str(track_selection_mediainfo.delay_relative_to_video)}ms]"
else:
delay_string = str("[delay 0ms]")
Expand Down Expand Up @@ -10896,6 +10899,10 @@ def create_track_count():
global acodec_stream_track_counter
# create empty list
max_common_audio_track = []
audio_track_info = {}

# common var
all_common = True

# get total of files in the list box
total_tracks_to_parse = batch_listbox.size()
Expand All @@ -10912,6 +10919,30 @@ def create_track_count():
audio_track_count = media_info.general_tracks[0].count_of_audio_streams
max_common_audio_track.append(audio_track_count)

# let's try to update languages
# let's parse all tracks for each file
for num, x in enumerate(range(int(audio_track_count))):
# get data
same_language_string = media_info.audio_tracks[num].language
same_format_string = media_info.audio_tracks[num].format
same_channel_string = media_info.audio_tracks[num].channel_s
compiled_audio_track_info = [
same_language_string,
same_format_string,
same_channel_string,
]

# check for all common files
if not audio_track_info:
audio_track_info.update({str(num): compiled_audio_track_info})
else:
try:
if audio_track_info[str(num)] != compiled_audio_track_info:
all_common = False
audio_track_info.update({str(num): compiled_audio_track_info})
except KeyError:
audio_track_info.update({str(num): compiled_audio_track_info})

max_common_audio_track.sort() # sort from least to greatest
max_total_tracks = Counter(
max_common_audio_track
Expand All @@ -10920,7 +10951,18 @@ def create_track_count():
# update track counter for codec settings window based off of max_total_tracks
acodec_stream_track_counter = {}
for i in range(int(max_total_tracks.most_common(1)[0][0])):
acodec_stream_track_counter[f"Track #{i + 1}"] = f" -map 0:a:{i} "
if all_common:
additional_audio_info_string = (
f" ({str(audio_track_info[str(i)][0])}, "
f"{str(audio_track_info[str(i)][1])}, "
f"chnl {str(audio_track_info[str(i)][2])})"
)
elif not all_common:
additional_audio_info_string = ""

acodec_stream_track_counter[
f"Track #{i + 1}{additional_audio_info_string}"
] = f" -map 0:a:{i} "

def enable_disable_batch_win_btns(mode):
"""function to enable/disable buttons while batch window is loading the files"""
Expand All @@ -10947,11 +10989,13 @@ def process_batch_file_input_information(*args):
list_of_batch_files = []

# update empty lists
for directory in args:
if pathlib.Path(directory).is_dir():
for x in pathlib.Path(directory).rglob("*.*"):
for input_args in args:
if pathlib.Path(input_args).is_dir():
for x in pathlib.Path(input_args).rglob("*.*"):
if x.is_file():
list_of_batch_files.append(x)
elif pathlib.Path(input_args).is_file():
list_of_batch_files.append(input_args)

# sort list
list_of_batch_files.sort()
Expand Down Expand Up @@ -11310,7 +11354,9 @@ def thread_adding_to_manager():
try:
if "mp4" in str(pathlib.Path(batch_file).suffix):
if track_selection_mediainfo.source_delay:
delay_string = f"[delay {str(track_selection_mediainfo.source_delay)}ms]"
delay_string = (
f"[delay {str(track_selection_mediainfo.source_delay)}ms]"
)
else:
delay_string = str("[delay 0ms]")
else:
Expand Down Expand Up @@ -12568,7 +12614,7 @@ def add_to_jobs():
audio_filter_function()
collect_final_job_commands()

# add total duration ass argumeent to pass
# add total duration as argument to pass
media_info = MediaInfo.parse(pathlib.Path(file_input)) # Parse input file
track_selection_mediainfo = media_info.audio_tracks[
int(acodec_stream_choices[acodec_stream.get()].strip()[-1])
Expand Down

0 comments on commit 948a38b

Please sign in to comment.