请求文件的头信息
无论如何,我只能请求任何媒体的标头信息。例如,我只想请求任何视频文件的标头信息,以便找到其视频长度。我尝试使用 ffmpeg -i {video_url} 并完成了工作,但我注意到它实际上将给定的媒体下载到本地存储中并返回标头信息,这显然增加了往返时间。
因此,如果有任何想法可以找到苍蝇中媒体的长度,我将非常感激。顺便说一句,我有一个 ruby on Rails 应用程序,我需要在其中实现此功能。
is there anyway I can 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用
ffprobe -show_format
。 ffprobe 与 ffmpeg 一起提供,并且应该与其一起编译和安装。You could try with
ffprobe -show_format
. ffprobe comes with ffmpeg, and should have been compiled and installed along with it.您也可以尝试 mediainfo。您可以从以下位置下载:http://mediainfo.sourceforge.net/en。
还有一个媒体信息的包装宝石,但它对我来说效果不佳。我刚刚使用过:
response = '#{mediainfo_path} #{source.path} --output=json 2>&1'
然后您可以在响应中搜索您想要的属性,例如“持续时间”等。
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.