Foxtable(狐表)用户栏目专家坐堂 → 怎么获取视频文件的尺寸时长信息


  共有2449人关注过本帖树形打印复制链接

主题:怎么获取视频文件的尺寸时长信息

帅哥哟,离线,有人找我吗?
淡月斜阳
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:221 积分:1921 威望:0 精华:0 注册:2015/4/8 8:18:00
怎么获取视频文件的尺寸时长信息  发帖心情 Post By:2018/11/5 13:17:00 [只看该作者]

怎么获取视频文件的,画面尺寸,比如320*240
视频时长
[此贴子已经被作者于2018/11/5 13:16:54编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/5 15:09:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
淡月斜阳
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:221 积分:1921 威望:0 精华:0 注册:2015/4/8 8:18:00
  发帖心情 Post By:2018/11/5 17:21:00 [只看该作者]

参考用ffmpeg,avi格式的可以正常读取
mp4,wmv,mkv,格式的没有这个参数
[此贴子已经被作者于2018/11/5 17:21:40编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/5 17:32:00 [只看该作者]

MP4,用这个可以

 

Dim shell As New Shell32.Shell()
Dim folder As Shell32.Folder = shell.[NameSpace](System.IO.Path.GetDirectoryName("c:\videotest.mp4"))
Dim item As Shell32.FolderItem = folder.ParseName("videotest.mp4")
msgbox(folder.GetDetailsOf(item, -1))

 

用这个,也可以

 

Dim vFileName As String = "c:\videotest.mp4"
Dim ffmpeg As String = ProjectPath & "ffmpeg.exe"
Dim p As new System.Diagnostics.Process
p.StartInfo.FileName = ffmpeg
p.StartInfo.UseShellExecute = False '关闭Shell的使用
p.StartInfo.RedirectStandardInput = True '重定向标准输入
p.StartInfo.RedirectStandardOutput = True '重定向标准输出
p.StartInfo.RedirectStandardError = True '重定向错误输出
p.StartInfo.CreateNoWindow = True '设置不显示窗口
addhandler p.ErrorDataReceived, addressof OutputCallback
p.StartInfo.Arguments = String.Concat("-i ", vfilename)
result.remove(0, result.length)
p.Start()
p.BeginErrorReadLine()
p.WaitForExit()
p.Close()
p.Dispose()
msgbox(result.Tostring)

Dim mc = System.Text.RegularExpressions.Regex.Matches(result.Tostring, "(?<=Duration:)\s(\d{2}:\d{2}:\d{2}.\d+)")
Dim s = mc(0).value
msgbox(s)

 

认认真真看这个帖子 http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=126485&skin=0

 


 回到顶部
帅哥哟,离线,有人找我吗?
淡月斜阳
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:221 积分:1921 威望:0 精华:0 注册:2015/4/8 8:18:00
  发帖心情 Post By:2018/11/5 17:43:00 [只看该作者]

我知道了,确实可以
刚才试的几个文件,文件名里含有- ! & 空格等字符,有这些字符,就显示no such file or ,找不到文件
改一下文件名就好了

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/5 18:58:00 [只看该作者]

如果有空格等特殊字符的话,参考

 

Dim vFileName As String = "c:\video test.mp4"
Dim ffmpeg As String = ProjectPath & "ffmpeg.exe"
Dim p As new System.Diagnostics.Process
p.StartInfo.FileName = ffmpeg
p.StartInfo.UseShellExecute = False '关闭Shell的使用
p.StartInfo.RedirectStandardInput = True '重定向标准输入
p.StartInfo.RedirectStandardOutput = True '重定向标准输出
p.StartInfo.RedirectStandardError = True '重定向错误输出
p.StartInfo.CreateNoWindow = True '设置不显示窗口
addhandler p.ErrorDataReceived, addressof OutputCallback
p.StartInfo.Arguments = String.Concat("-i ", """" & vfilename & """")
result.remove(0, result.length)
p.Start()
p.BeginErrorReadLine()
p.WaitForExit()
p.Close()
p.Dispose()
msgbox(result.Tostring)

Dim mc = System.Text.RegularExpressions.Regex.Matches(result.Tostring, "(?<=Duration:)\s(\d{2}:\d{2}:\d{2}.\d+)")
Dim s = mc(0).value
msgbox(s)


 回到顶部