【问题标题】:File type not recognized when using ffprobe with Python将 ffprobe 与 Python 一起使用时无法识别文件类型
【发布时间】:2018-05-12 08:12:22
【问题描述】:

这是我的 python 脚本:

#!/usr/bin/python3
import os, sys, subprocess, shlex, re
from subprocess import call

def probe_file(filename):
    cmnd = ['ffprobe', '-show_packets', '-show_frames', '-print_format', filename]
    p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    print filename
    out, err =  p.communicate()
    print "Output:"
    print out
    if err:
        print "Error:"
        print err

probe_file(sys.argv[1])

正在使用此命令运行:

python parse_frames_and_packets.py mux_test.ts

我得到以下错误输出:

Unknown output format with name 'mux_test.ts'

在 Python 中使用 ffprobe 时不能使用 .ts 文件类型吗?因为我已经使用这个确切的文件单独运行 ffprobe 并且它工作正常。

有人有什么建议吗?

编辑: 它似乎无法识别所有类型的视频,而不仅仅是传输流(我刚刚尝试使用 .avi 并得到相同的响应)。

【问题讨论】:

    标签: python image-processing ffmpeg ffprobe transport-stream


    【解决方案1】:

    -print_format(或-of 别名)需要格式。可用格式有:default、compact、csv、flat、ini、json、xml。

    例子:

    ffprobe -loglevel error -show_streams -print_format csv=p=0 input.mkv
    

    请参阅ffprobe documentation 了解更多信息。

    【讨论】:

    • 我不敢相信我错过了这么愚蠢的事情。非常感谢,你摇滚!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 2013-06-05
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 2018-12-01
    相关资源
    最近更新 更多