【问题标题】:Difference between ffmpeg and avconv for rawvideo image2piperawvideo image2pipe的ffmpeg和avconv之间的区别
【发布时间】:2016-07-16 01:44:47
【问题描述】:

我不知道为什么,但avconv 似乎并没有像我预期的那样播放原始视频。

我正在尝试将视频从ffmpeg 传输到python(最终我想从x11grab 读取,而不是视频文件)。它在我的 Macbook 上使用 ffmpeg 运行良好,但是当我在 Debian Jessie 上使用 avconv 时,流提前中断了!

这是我的基本 python,它在 this guide 之后:

input_resolution_shape = (1280,800,3)
input_bytes = reduce(mul, input_resolution_shape, 1)
print input_bytes

# Prints 3072000

import subprocess as sp
command = [ FFMPEG_BIN,   # This is either "avconv" or "ffmpeg".
            '-i', 'test_video.mp4',
            '-f', 'image2pipe',
            '-pix_fmt', 'rgb24',
            '-vcodec', 'rawvideo', '-']
pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)

import numpy
for _ in range(100):  # read 100 frames
    # read 1280*800*3 bytes (= 1 frame)
    raw_image = pipe.stdout.read(input_bytes)
    # transform the byte read into a numpy array
    image = numpy.fromstring(raw_image, dtype='uint8')
    if image.size != 0:
        print image.size

        # Prints 1015808

在 mac 上,打印的 image.sizeinput_bytes 相同,3072000。但在 debian 上,它是 1015808。任何想法为什么会发生这种情况?

有趣的是,3072000/1015808 大约是 3:

In [1]:    3072000./1015808.
Out[1]:    3.024193548387097

【问题讨论】:

  • acvonv 不等同于ffmpeg。你为什么不直接使用ffmpeg?您可以简单地download a static ffmpeg binary 并将您的脚本指向它。
  • 因为我在 Debian 上,我不知道如何正确安装 ffmpeg。 :(

标签: python video ffmpeg avconv


【解决方案1】:

我遇到了这个问题,因为我是从 Docker 实例内部运行的,该实例是基于 Debian 构建的。 ffmpeg 在我运行的 Debian 版本中默认不打包。

根据上面@LordNeckbeard 的评论,我通过下载ffmpeg 二进制文件设法解决了这个问题。我已将这些行添加到我的 Dockerfile 中,这为我解决了问题:

# Install FFMPEG
RUN wget http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz
RUN tar xvfJ ffmpeg-release-64bit-static.tar.xz
USER root
RUN ln ffmpeg-3.1.2-64bit-static/ffmpeg /usr/local/bin/ffmpeg

谢谢。

【讨论】:

    猜你喜欢
    • 2012-03-17
    • 2018-11-15
    • 2014-12-08
    • 2020-09-23
    • 2011-11-06
    • 1970-01-01
    • 2018-03-05
    • 1970-01-01
    • 2021-12-25
    相关资源
    最近更新 更多