开发者

Requesting header information of a file

开发者 https://www.devze.com 2023-04-01 18:23 出处:网络
is there anyway I ca开发者_开发百科n request only the header information of any media. For example I just want to request header information of any video file so as to find its video length. I tried u

is there anyway I ca开发者_开发百科n request only the header information of any media. For example I just want to request header information of any video file so as to find its video length. I tried using ffmpeg -i {video_url} and did the work but I noticed that it actually downloads the given media in local storage and returns back the header information which obviously increases roundtrip time.

So I would really appreciate if there is any idea for finding the length of media in a fly. BTW I have a ruby on rails application where I need to implement this.


You could try with ffprobe -show_format. ffprobe comes with ffmpeg, and should have been compiled and installed along with it.


You can also try mediainfo. you can download it from: http://mediainfo.sourceforge.net/en. There is also a wrapper gem for mediainfo but it didn't work well for me. I just used:
response = '#{mediainfo_path} #{source.path} --output=json 2>&1'
and you can then search the response for the properties you want such as "duration" etc.

0

精彩评论

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

关注公众号