开发者

Get the output value of system

开发者 https://www.devze.com 2022-12-22 12:16 出处:网络
I am using the following method to get the time of the video with ffmpeg do not know what reason I can not put the output of the command

I am using the following method to get the time of the video with ffmpeg do not know what reason I can not put the output of the command

command =~ /Duration: ([\d][\d]):([\d][\d]):([\d][\d]).([\d]+)/

variable for time and then insert in the can someone give a help?

 def get_time_video

   command = system " ffmpeg -i video.flv 2>&1 "  
   command =~ /Duration: ([\d][\d]):([\d][\d]):([\d][\d]).([\d]+)/  
   time = " #{$1}:#{$2}:#{$3} "  
   puts time    # 00:00:30  
   update_attribute(:time, “#{time}”)开发者_StackOverflow社区  

end


The Kernel.system function returns true or false as seen in the Documentation. If you want to parse the output of a command, you can use the backtick notation:

system = `ffmpeg -i video.flv 2>&1`
0

精彩评论

暂无评论...
验证码 换一张
取 消