python - 将 ffprobe 与 Python 一起使用时无法识别文件类型

标签 python image-processing ffmpeg ffprobe transport-stream

这是我的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 并得到相同的响应)。

最佳答案

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

例子:

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

ffprobe documentation了解更多信息。

关于python - 将 ffprobe 与 Python 一起使用时无法识别文件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47538889/

相关文章:

matlab - MATLAB 中图像的类型、大小、维度

ffmpeg - 如何使用 ffmpeg 在 NVenc(HEVC) 上设置 gop-size?

python - ffmpeg 在后台运行时挂起

python - MacPorts 说当运行 "python --version"时我仍然有 Python 2.7

python - 在 python 中为 Openrefine 创建 json

python - 在 flask 中嵌入 Bokeh 应用程序

c# - Bgr32 PixelFormat 中的第四个 channel 是什么

python - 静态文件 application_readable 用法

php - 使用 ImageMagick 压缩 PNG 图像

bash - 如何在 bash "for loop"中使用 ffmpeg 流复制?