我正在尝试使用RVideo库查看文件是否包含有效的视频流:
read_file.rb:
require 'rubygems'
require 'rvideo'
file_path="/mnt/glusterfs/video/2012/02/04/2012-02-04 1000 CSPAN United Nations Security Council Meeting (337711).mp4"
puts file_path
file = RVideo::Inspector.new(:file => file_path)
我收到此错误:
rbennacer@services:~$ ruby read_file.rb
/mnt/glusterfs/video/2012/02/04/2012-02-04 1000 CSPAN United Nations Security Council Meeting (337711).mp4
sh: Syntax error: "(" unexpected
即使我在每个空格字符和括号字符前加上反斜杠,我也会收到错误。
答案 0 :(得分:1)
您的错误来自shell。 Rvideo将该文件路径发送到ffmpeg -i
。所以你的路径没有被正确转义
require 'shellwords'
"/mnt/glusterfs/video/2012/02/04/2012-02-04 1000 CSPAN United Nations Security Council Meeting (337711).mp4".shellescape
=> "/mnt/glusterfs/video/2012/02/04/2012-02-04\\ 1000\\ CSPAN\\ United\\ Nations\\ Security\\ Council\\ Meeting\\ \\(337711\\).mp4"