none
How to get the duration for video files uploaded to SharePoint library ? RRS feed

  • Question

  • HI!,

    I am trying to get the video file duration for the list of video files uploaded to a document library. This library can be a asset / any document library. I am using below script to get the required details. However, could not find a way to get the video file duration. Any help would be highly appreciated.

    asnp **share*

    Get-SPSite -Identity "https://<My_SiteCollection_Url.com>" | 
    Get-SPWeb -Limit All | 
    Select -ExpandProperty Lists | 

    Select -ExpandProperty Items | Where {  $_.Name -Like "*.avi" -or $_.Name -Like "*.mpg" -or $_.Name -Like "*.Mp4" -or $_.Name -Like "*.mov" -or $_.Name -Like "*.wmv" -or $_.Name -Like "*.flv" -or $_.Name -Like "*.mkv" -or $_.Name -Like "*.avchd" -or $_.Name -Like "*.webm" } |
    Select name, URL, {$_.File.Length / 1MB}, FirstUniqueAncestor, {$_.ParentList.ParentWeb.Url + "/" + $_.Url} | Export-csv -NoTypeInformation -Path E:\Temp\mp4test.csv

    AbdulRazak Shaikh

    Friday, July 3, 2020 3:49 PM

All replies

  • Hi AbdulRazak,
    Do I understand correctly that you have multiple video files in different file formats in Asset en Document libraries in a SharePoint 2013 system and you want to extract the video duration of each file?

    Are the durations available as SharePoint columns or do you need to extract them from each file?

    The latter would obviously make things much more complex.

    Paul | SLIM Applications

    Saturday, July 4, 2020 7:45 AM
  • Hello Paul,

    Thank you for looking into this issue.

    We don't have any column with this data.

    Unfortunately, we need to extract this data from each file.


    AbdulRazak Shaikh

    Sunday, July 5, 2020 4:56 PM
  • Hi AbdulRazak Shaikh,

    I do not think there is such a property in SPListItem or SP file object. When i click "Open with Explorer", the window will show video duration:

    In powershell, we can get it through below script:

    $Folder = '\\sp\DavWWWRoot\Shared Documents'
    $File = 'file_examp.mp4'
    $LengthColumn = 27
    $objShell = New-Object -ComObject Shell.Application 
    $objFolder = $objShell.Namespace($Folder)
    $objFile = $objFolder.ParseName($File)
    $objFolder.GetDetailsOf($objFile, $LengthColumn)

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 6, 2020 4:22 AM
  • This looks promising.

    Do you know if this works with all the video formats present?
    .avi
    .mpg
    .mp4
    .mov
    .wmv
    .flv
    .mkv
    .avchd
    .webm

    Paul


    Monday, July 6, 2020 7:09 AM
  • This looks promising.

    Do you know if this works with all the video formats present?
    .avi
    .mpg
    .mp4
    .mov
    .wmv
    .flv
    .mkv
    .avchd
    .webm

    Paul


    Some types(such as .flv) cannot be recognized by file explorer by default. We can add a 3rd party codecs. I installed K-Lite Codec and it can support the above videos.

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 7, 2020 9:39 AM
  • The use of 3rd party codecs is very good news. Smart.

    Does the extraction of the duration require the full video file to be transferred from SharePoint?

    @AbdulRazak, can you check if the properties of the video's in SharePoint also contain the duration?
    e.g. construct a url like and open that in your browser
    https://slimapplications.sharepoint.com/_api/Web/GetFileByServerRelativePath(decodedurl='/DocLibEmailMetadata/0NeuEon/VID-20180217-WA0000/VID-20180217-WA0000.mp4')/properties

    Paul

    Tuesday, July 7, 2020 11:01 AM
  • Hi AbdulRazak Shaikh,

    We have not heard from you for a long time. Is above info helpful to the issue? If it has been resolved, it's appreciated that you can mark it as Answer so that others who stuck in similar issue could get answered quickly.

    And we'd like to notify you that This forum will be locked down, if you still have issues about this question, you can continue to post in here before 8/10/2020. It is recommended to create a new question on Microsoft Q&A, we will continue to support you on the new home.

    Best Regards,

    Baker Kong


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Wednesday, August 5, 2020 2:54 AM