ffmpeg atempo 过滤器不起作用

ffmpeg atempo 过滤器不起作用

当我运行以下命令时:

ffmpeg -i input.mp3 -filter:a "atempo=2.0" -vn output.mp3

-filter:a "atempo=2.0"我预计 output.mp3 的速度是 input.mp3 的两倍(长度是 input.mp3 的一半),但它的速度和长度与 input.mp3 完全相同。事实上,它生成的文件与不使用时完全相同。我也在 wav 输出上对其进行了测试。

我在输出中看到两个类似的警告(Truncating packet of size 1024 to 597),但并不严重。

如何让过滤器工作?

编辑

以下是 ffmpeg 的输出:

ffmpeg -i "1-02 Ein Junge überlebt.mp3" -filter:a "atempo=2.0"  -vn "converted/music.mp3"
ffmpeg version 0.10.12-7:0.10.12-1~saucy1 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 26 2014 09:54:16 with gcc 4.8.1
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~saucy1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mp3 @ 0x216f740] max_analyze_duration 5000000 reached at 5004000
Input #0, mp3, from '1-02 Ein Junge überlebt.mp3':
  Duration: 00:05:22.20, start: 0.000000, bitrate: 57 kb/s
    Stream #0:0: Audio: mp3, 32000 Hz, mono, s16, 56 kb/s
File 'converted/music.mp3' already exists. Overwrite ? [y/N] y
Output #0, mp3, to 'converted/music.mp3':
  Metadata:
    TSSE            : Lavf53.32.100
    Stream #0:0: Audio: mp3, 32000 Hz, mono, s16, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
Truncating packet of size 1024 to 597ate= 128.0kbits/s    
Truncating packet of size 1024 to 1
size=    5036kB time=00:05:22.27 bitrate= 128.0kbits/s    
video:0kB audio:5036kB global headers:0kB muxing overhead 0.011849%

答案1

这类问题似乎可以通过更新 ffmpeg 来解决,但我对更新/更改系统上的任何编解码器都很担心,因此决定通过 wine 使用 ffmpeg 的 Windows 二进制文件。它似乎运行良好。

Python Wine 包装器:

我已经编写了以下 Python 包装器,必须是

  • 放在与 相同的目录中ffmpeg.exe

  • 授予执行权限并

  • 符号链接到 /usr/bin/wineffmpeg。

源代码:

#!/usr/bin/env python
import subprocess
import sys
import os

#Robust against: ln ... --symbolic
base_dir = os.path.dirname(os.path.realpath(__file__))
ffmpegbin = os.path.join(base_dir, 'ffmpeg.exe')

def wine_path(path):
    return subprocess.check_output(['winepath', '-w', path]).strip()

for i in range(1, len(sys.argv)):
    if sys.argv[i][:8].lower() == 'linpath:':
        sys.argv[i] = wine_path(sys.argv[i][8:].strip())

subprocess.call(['wine', ffmpegbin]+sys.argv[1:])

它会逐字传递所有命令行参数,除非您以 的形式提供参数linpath:/linux/path/to/x。然后它会将其转换为Z:\wine\path\to\x。但这很少是必要的,因为用 表示的相对路径(最常用)/似乎开箱即用。

这是一次成功的运行:

wineffmpeg -i "1-02 Ein Junge überlebt.mp3" -
filter:a "atempo=2.0"  -vn "converted/music.mp3"
ffmpeg version N-69672-g078be09 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 18.100 / 54. 18.100
  libavcodec     56. 21.102 / 56. 21.102
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  9.104 /  5.  9.104
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mp3, from '1-02 Ein Junge ├╝berlebt.mp3':
  Duration: 00:05:22.20, start: 0.034531, bitrate: 57 kb/s
    Stream #0:0: Audio: mp3, 32000 Hz, mono, s16p, 57 kb/s
    Metadata:
      encoder         : LAME3.96r
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
Output #0, mp3, to 'converted/music.mp3':
  Metadata:
    TSSE            : Lavf56.19.100
    Stream #0:0: Audio: mp3 (libmp3lame), 32000 Hz, mono, s16p
    Metadata:
      encoder         : Lavc56.21.102 libmp3lame
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
size=     944kB time=00:02:41.06 bitrate=  48.0kbits/s    
video:0kB audio:944kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.023277%

相关内容