Python accessing data in JSON object

前端 未结 3 993
既然无缘
既然无缘 2021-02-13 12:53

so I do this in my script:

import json
info = json.loads(get_info())
print info

Which outputs:

richard@richard-desktop:~/projec         


        
3条回答
  •  孤街浪徒
    2021-02-13 13:54

    To print codec_long_name and duration from the second stream do the following:

    details = subprocess.check_output(["C:/FFmpeg/bin/ffprobe.exe",
        "-loglevel", "quiet", "-print_format", "json", "-show_streams", 
        file_path])
    info = json.loads(details)
    print info['streams'][1]['codec_long_name'], info['streams'][1]['duration']
    

提交回复
热议问题