在 Spring 或 J2EE 中上传到服务器时的视频文件时间长度(以分钟为单位)
我想在提交页面时上传到服务器时将具有多个扩展名(mp4、wav、flv 等)的视频文件的时间长度保存到数据库中。但我没有找到如何获取上传视频的长度?我尝试了这段代码,但它只适用于音频文件。
File f = new File(fileName);
Bitstream m_bitstream = new Bitstream(inputStream);
Header m_header = m_bitstream.readFrame();
int mediaLength = (int)f.length();
int nTotalMS = 0;
if (mediaLength != AudioSystem.NOT_SPECIFIED) {
nTotalMS = Math.round(m_header.total_ms(mediaLength));
}
你能帮我吗?
I want to save time length of the video files having several extension(mp4, wav, flv etc) in to database while uploading to server when submitting the page. But I did not find the how to get the length of the uploading video? I tried this code but it only works for audio files.
File f = new File(fileName);
Bitstream m_bitstream = new Bitstream(inputStream);
Header m_header = m_bitstream.readFrame();
int mediaLength = (int)f.length();
int nTotalMS = 0;
if (mediaLength != AudioSystem.NOT_SPECIFIED) {
nTotalMS = Math.round(m_header.total_ms(mediaLength));
}
Can you please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅这篇文章了解“wav”文件
如何学习Java媒体框架中的.wav时长?
mp3文件请参考:
如何在 Java 中获取 mp3 文件的总时间?
对于mp4请参考:
是否有Java API对于 mp4 文件?
Please refere to this post for "wav" files
How to learn .wav duration in Java media frame work?
For mp3 files please refere to:
How do I get a mp3 file's total time in Java?
For mp4 please refer to:
Is there a Java API for mp4 files?