0

I want to get the duration of the video using ffmpeg or ffprobe with vb.net. but I don't know how to use ffmpeg or ffprobe at all. Is there anyone who can help? this can be a starting point for people like me

Sonero41
  • 1
  • 1

1 Answers1

0
Private Function lengthOfAudioFile(locOfFFPROBE As String, fileLoc As String) As String

    Dim myprocess As New Process
    Dim lines As String = ""

    With myprocess
        .StartInfo.FileName = locOfFFPROBE & "ffprobe.exe"
        .StartInfo.Arguments = " -i " & fileLoc & " -show_entries format=duration -v quiet -of csv=" & """p=0"""
        .StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        .StartInfo.CreateNoWindow = True
        .StartInfo.RedirectStandardOutput = True
        .StartInfo.UseShellExecute = False
        .Start()
    End With

    lines = myprocess.StandardOutput.ReadToEnd

    lengthOfAudioFile = lines.ToString

End Function

' This subroutine is fired on when a button is clicked to test the length of the audiofile.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MsgBox(lengthOfAudioFile("ENTER YOUR FFPROBE LOCATION", "ENTER THE AUDIO FILE YOU WANT TO TEST"))
End Sub

FFPROBE location is like "C:\FFMPEG\" Audio file location is like "C:\AudioFile\test.mp3" Output is length in seconds.

Shout out to Ivan's answer here: How to extract duration time from ffmpeg output?

No Body
  • 11
  • 2