Video File Duration

  • I have some files stored in Folder and the paths of this files stored in sql server:

    File path : E:\videofiles\123.mp4

    how to get the video duration using tsql, because i need to update the table with the duration for all records

  • Hi,

    I think this is impossible, SQL is a database tool, no video tool. I've never heard, that sql cmd could manage such a task.

    Kind regards,

    Andreas

  • You'll have to access the Extended File Properties of the file but I don't think you can do it with TSQL. The Extended Properties vary according to the type of file.

    In the old days, you would probably have to write some c#/vb but Powershell is the way to go now. Powershell can use the GetDetailsOf method to query folders. You might even be able to use a SSIS script component.

    You might be lucky and someone has written a similar script already.

  • You might be able to do it using the T-SQL commands to allow for OLE Automation. Start with sp_OACreate and work your way through. I warn you now, it'll be unpleasant.

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • DouglasH (5/25/2016)


    You'll have to access the Extended File Properties of the file but I don't think you can do it with TSQL. The Extended Properties vary according to the type of file.

    In the old days, you would probably have to write some c#/vb but Powershell is the way to go now. Powershell can use the GetDetailsOf method to query folders. You might even be able to use a SSIS script component.

    You might be lucky and someone has written a similar script already.

    that's how i would have tackled it as well. my first link i found:

    https://social.technet.microsoft.com/Forums/Windows/en-US/bad2dbb1-5deb-48b8-8f8c-45e2b353dba0/how-do-i-get-video-file-duration-in-powershell-script?forum=winserverpowershell

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • i used c# to do that using :

    http://www.nrecosite.com/video_info_net.aspx

    Download package and add reference to NReco.VideoInfo.dll assembly

    var ffProbe = new NReco.VideoInfo.FFProbe();

    var videoInfo = ffProbe.GetMediaInfo(pathToVideoFile);

    Console.WriteLine(videoInfo.FormatName);

    Console.WriteLine(videoInfo.Duration);

  • in sql if you use any extended procedure will cause many issue later.

    i suggest, while uploading the video file you can save the file path , name and duration in sql table will save lot of your extra effort which is very much possible using your C# or vb.net

  • Upload is done automatically , the user will select multiple files , then will press upload button, everything must be added to sql server table , this why i use ffmpeg tool

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply