0

您好我正在尝试使用 gem rvideo 对视频文件进行转码,但结果与我的预期不符。我已经从http://ffmpeg.zeranoe.com/builds/下载了 ffmpeg 文件,安装了 rvideo gem。

我发现如果不指定 ffmpeg_binary 它将无法工作并给出错误。我有几个问题,一个是我输入时的输出

require 'rvideo'

video = RVideo::Inspector.new(:file => "D:/The Vault/josh ruby/video transcoding/test1.mp4", :ffmpeg_binary => "C:/ffmpeg/bin/ffmpeg.exe")

当我输入上述命令时,我看到一团糟的输出,看起来像构建日期、配置选项等(包含在帖子底部)

但是我在文档中看到您可以输入类似的命令。

  • 视频.fps
  • 视频分辨率

他们只为我返回零。

你不能在 Windows 上使用 rvideo 吗?

从顶部输出:

=> #<RVideo::Inspector:0x213ba48 @ffmpeg_binary="C:/ffmpeg/bin/ffmpeg.exe",  @filename="test1.mp4", @path="D:/The Vau
lt/josh ruby/video transcoding", @full_filename="D:/The Vault/josh ruby/video transcoding/test1.mp4", @raw_response=
"ffmpeg version N-51106-g17c1881 Copyright (c) 2000-2013 the FFmpeg developers\n  built on Mar 19 2013 13:49:37 with
gcc 4.7.2 (GCC)\n  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bz
lib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable
-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-am
rwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspe
ex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-
libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib\n  libavutil      52. 19.101 / 52. 19.101\n
libavcodec     55.  1.100 / 55.  1.100\n  libavformat    55.  0.100 / 55.      0.100\n      libavdevice    55.  0.100 / 55.
 0.100\n  libavfilter     3. 47.104 /  3. 47.104\n  libswscale      2.  2.100 /  2.  2.100\n  libswresample   0. 17
.102 /  0. 17.102\n  libpostproc    52.  2.100 / 52.  2.100\nD:/The: No such file or directory\n", @unknown_format=t
rue>

更新:根据下面 rmtsukuru 的回答进行了更改,但最终得到了。另请注意,这是与上述文件不同的文件(在不同的电脑上)。

 irb(main):002:0> response = %x(C:/ffmpeg/bin/ffmpeg.exe -i "C:/Users/Josh/Desktop/joshruby/videoTranscoding/test1.mp4")
ffmpeg version N-51205-gac9b056 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 22 2013 00:04:52 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable- libgsm --enable-libilbc --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-libvo-aacenc --enable-libvo-amrwbenc  --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
libavutil      52. 22.100 / 52. 22.100
libavcodec     55.  1.100 / 55.  1.100
libavformat    55.  0.100 / 55.  0.100
libavdevice    55.  0.100 / 55.  0.100
libavfilter     3. 48.100 /  3. 48.100
libswscale      2.  2.100 /  2.  2.100
libswresample   0. 17.102 /  0. 17.102
libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/Josh/Desktop/joshruby  /videoTranscoding/test1.mp4':
  Metadata:
major_brand     : mp42
minor_version   : 1
compatible_brands: isommp41avc1
creation_time   : 2009-02-19 18:49:05
 Duration: 00:00:08.04, start: 0.000000, bitrate: 3129 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 3009 kb/s, 25 fps, 25 tbr, 600 tbn, 50 tbc
Metadata:
  creation_time   : 2009-02-19 18:49:05
  handler_name    : ?Apple Video Media Handler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
  creation_time   : 2009-02-19 18:49:05
  handler_name    : ?Apple Sound Media Handler
Stream #0:2(eng): Data: none (mp4s / 0x7334706D), 0 kb/s
Metadata:
  creation_time   : 2009-02-19 18:49:05
  handler_name    : ?
Stream #0:3(eng): Data: none (mp4s / 0x7334706D), 0 kb/s
Metadata:
  creation_time   : 2009-02-19 18:49:05
At least one output file must be specified
=> ""
4

1 回答 1

0

ffmpeg 不喜欢输入文件名中的空格,并且 rvideo 不会为您正确转义输入。如果您从 shell 手动运行命令,您可以让 ffmpeg 正确运行,然后将原始响应传递给 rvideo 检查器以正确实例化它:

response = %x('#{bin_path}' -i "#{filename}")
video = RVideo::Inspector.new(:raw_response => response)

替换bin_path为 ffmpeg 二进制filename文件的路径和输入文件的路径。ffmpeg 二进制路径不必用引号括起来,除非它包含空格。

于 2013-03-22T03:09:49.900 回答