Search code examples
pythonpython-3.xsubprocessffprobe

the output of subprocess is different from the ffprob outptu


I am trying the find the bitrate of each video and for this I used the following python command:

subprocess.call(['ffprobe', '-i',pname1,'-v', 'quiet', '-show_entries', 'format=bit_rate', '-hide_banner', '-of', 'default=noprint_wrappers=1:nokey=1'])

pname1 is the name of the file. but the output is zero for all files while when I used the same code in the shell the output is true and shows the true value for bitrate.

ffprobe -i 1.mkv -v quiet -show_entries format=bit_rate -hide_banner -of default=noprint_wrappers=1:nokey=1

do you know what is the problem?


Solution

  • You get the return value of call() method and that is 0 which is succesfull. To get bitrate value as output, you can use subprocess.check_output()

    output=subprocess.check_output(['ffprobe', '-i',pname1,'-v', 'quiet', '-show_entries', 'format=bit_rate', '-hide_banner', '-of', 'default=noprint_wrappers=1:nokey=1'])
    
    print(output)