2012-02-08 35 views
0

我想看看文件是否已使用RVideo庫的有效視頻流:如何判斷文件是否是使用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) 

我得到這個錯誤:

[email protected]:~$ 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 

即使我在每個空格字符和括號之前加上一個反斜槓,我就會得到這個錯誤。

回答

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" 
相關問題