I am trying to use if statement to display some video streams parameter(bitrate) in case it exists or displays a message( cannot measure bitrate) if there is no bit rate. and prevent my GUI from crashing.
where is the wrong in my code, or how can I make it better?
import json
import shlex
import subprocess
cmd = "ffprobe -v quiet -print_format json -show_streams"
args = shlex.split(cmd)
myurl = "udp://@239.168.2.6:2113"# this is my video stream
args.append(myurl)
ffprobeOutput = subprocess.check_output(args).decode('utf-8')
ffprobeOutput = json.loads(ffprobeOutput)
video_stream = next((stream for stream in ffprobeOutput['streams'] if
stream['codec_type'] == 'video'))
if int(video_stream['bit_rate']) == True:
bit_rate1=int(video_stream['bit_rate'])
print(bit_rate1)
else:
print('can not measure bitrate')
my video stream has a bitrate parameter but my if statement always give me the else (print('can not measure bitrate'))