【问题标题】:ffmpeg user agent not workingffmpeg 用户代理不工作
【发布时间】:2017-06-02 01:11:30
【问题描述】:

我在 CentOS 上安装了 ffmpeg,去年它一直在愉快地编码文件音频文件,没问题。

但是,我现在想用它来访问音频流,以替换我目前使用的一些笨拙的 php 代码,但我想应用一个自定义用户代理,以便我的客户识别传入的连接。

我已经尝试过 -user-agent、-user_agent 和 -headers,但所有三个都返回“无法识别的选项”。

我正在使用的代码,不包括用户代理,是:

ffmpeg -t 3600 -i http://my.radio.com:8000/1 -vn -ar 44100 -ac 2 -ab 128k -f mp3 /var/www/vhosts/mywebsite.com/httpdocs/test.mp3

这没有问题,但是当我尝试添加 -user_agent、-user-agent 或 -headers 时,它会失败并出现上述错误。

如果有帮助,版本信息是:

FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
FFmpeg 0.6.5
libavutil     50.15. 1 / 50.15. 1
libavcodec    52.72. 2 / 52.72. 2
libavformat   52.64. 2 / 52.64. 2
libavdevice   52. 2. 0 / 52. 2. 0
libavfilter    1.19. 0 /  1.19. 0
libswscale     0.11. 0 /  0.11. 0
libpostproc   51. 2. 0 / 51. 2. 0

提前致谢!

【问题讨论】:

    标签: php ffmpeg centos6


    【解决方案1】:

    您可以使用 -headers 选项:

    ffmpeg -headers 'User-Agent: Mozilla' -i http://my.radio.com:8000/1
    

    请注意,您将收到警告:

    [http @ 00000000004795c0] No trailing CRLF found in HTTP header.
    

    从 FFmpeg 2.8 版开始,如果需要,CRLF is added。你可以 如果需要,请使警告静音:

    ffmpeg -v error -stats
    

    或者您可以自己包含 CRLF:

    q=$(printf 'User-Agent: Mozilla\r\nx')
    ffmpeg -headers "${q%x}"
    

    【讨论】:

      【解决方案2】:

      我正在回答我自己的问题,因为经过一个小时或更长时间的挖掘,我正在运行的旧版本的 ffmpeg 似乎是我从一个众所周知的存储库中获得的,不支持 -user_agent 选项/开关, -headers 也没有切换(感谢 Steven Penny)。

      所以,我从官方网站下载了 ffmpeg 的 Linux 静态版本。在通过 SSH 将其反弹到服务器上并记住将权限更改为 755 之后,我设法让 -user_agent 选项/开关起作用。

      我希望我自己对我的问题的回答能在未来对其他人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-07-11
        • 1970-01-01
        • 2019-04-28
        • 2017-08-25
        • 2018-04-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多