2012-02-08 2 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 

를 I 각 공백 문자와 괄호 문자 앞에 백 슬래시를 넣으면 오류가 발생합니다.

답변

1

셸에서 오류가 발생했습니다. 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" 
관련 문제