Foxtable(狐表)用户栏目专家坐堂 → 如何获取音频播放时长


  共有3674人关注过本帖平板打印复制链接

主题:如何获取音频播放时长

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


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

比较麻烦。

 

1、下载ffmpeg

 

http://dx.ouyaoxiazai.com:89/xiazaidian/ffmpeg.sfx.rar

 

2、把ffmpeg.exe文件放到你的项目下

 

3、全局代码

 

Public result As new Stringbuilder
Public Sub OutputCallback(sender As object, e As System.Diagnostics.DataReceivedEventArgs)
    If e.Data > "" Then
        result.append(e.Data)
    End If
End Sub

 

4、执行代码

 

Dim vFileName As String = "c:\test.mp3"
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)


 回到顶部
总数 23 1 2 3 下一页