This is a confusing question, however I will try to make it as clear as possible. Currently when I build my app, if I run it via the .py file it works perfectly. However, once I compile it some parts of my app aren't functioning, specifically this code here.
def ffprobe_run():
global output
global acodec_choices
run = subprocess.check_output("ffprobe " + videoinputquoted + " " + ffprobecommand, universal_newlines=True)
print(run)
if run[-2] == '3':
acodec_choices = {"One": "1",
"Two": "2",
"Three": "3"}
elif run[-2] == '2':
acodec_choices = {"One": "1",
"Two": "2",}
elif run[-2] == '1':
acodec_choices = {"One": "1",}
print(acodec_choices.values())
I am able to get the results I want with this command. Currently that's using FFPROBE to check for the amount of audio tracks there is in a file. It returns values like so
1
2
3
If there is 3 tracks. Or
1
2
If it's two tracks. I use the command[-2] which will give me the result of '2'
So I'm taking that result and defining a dictionary to automatically populate/change an OptionMenu
It defines this in my main app
# Audio Stream Selection
acodec_stream = StringVar(audio_window)
if ffprobeinfo[-2] == '1':
acodec_stream_choices = {'Track 1': "-map 0:a:0"}
elif ffprobeinfo[-2] == '2':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1"}
elif ffprobeinfo[-2] == '3':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2"}
elif ffprobeinfo[-2] == '4':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3"}
elif ffprobeinfo[-2] == '5':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4"}
elif ffprobeinfo[-2] == '6':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4",
'Track 6': "-map 0:a:5"}
elif ffprobeinfo[-2] == '7':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4",
'Track 6': "-map 0:a:5",
'Track 7': "-map 0:a:6"}
elif ffprobeinfo[-2] == '8':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4",
'Track 6': "-map 0:a:5",
'Track 7': "-map 0:a:6",
'Track 8': "-map 0:a:7"}
elif ffprobeinfo[-2] == '9':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4",
'Track 6': "-map 0:a:5",
'Track 7': "-map 0:a:6",
'Track 8': "-map 0:a:7",
'Track 9': "-map 0:a:8"}
elif ffprobeinfo[-2] == '10':
acodec_stream_choices = {'Track 1': "-map 0:a:0",
'Track 2': "-map 0:a:1",
'Track 3': "-map 0:a:2",
'Track 4': "-map 0:a:3",
'Track 5': "-map 0:a:4",
'Track 6': "-map 0:a:5",
'Track 7': "-map 0:a:6",
'Track 8': "-map 0:a:7",
'Track 9': "-map 0:a:8",
'Track 10': "-map 0:a:9"}
acodec_stream.set('Track 1') # set the default option
acodec_stream_label = Label(audio_window, text="Track :")
acodec_stream_label.grid(row=0, column=0, columnspan=1, padx=5, pady=5)
acodec_stream_menu = OptionMenu(audio_window, acodec_stream, *acodec_stream_choices.keys())
acodec_stream_menu.grid(row=1, column=0, columnspan=1, padx=5, pady=5)
This is all working great, If I am running the app via the .py file. Once I compile it's missing the entire defined dictionary selection.
This is what it's supposed to look like enter image description here
However, this is what it looks like with the code above. enter image description here
If I define the dictionary myself, it works fine. However, then I can't automatically input the correct amount of available audio tracks.
I hope this isn't too much code. I'm very new at this.
EDIT:
If I compile via pyinstaller and remove the -w flag, the program runs correctly, shows the tracks.
I'm assuming I'm not using subprocess/calling something correctly. The program I don't think is calling to FFPROBE when it doesn't have a console, vs calling it and getting the value when it has it's own console.