Jump to content

Get video duration programmatically


Go to solution Solved by jelum,

Recommended Posts

Posted

How can I get video duration executing internal (from the mediabrowser.server.core nuget) interfaces?

To run ffmpeg I use IFfmpegManager, but I didn't find a manager for ffprobe (the most obvious solution).

  • Solution
Posted

found

            var durationSec = (await _mediaProbeManager.GetMediaInfo(new MediaInfoRequest()
                    {
                        MediaType = DlnaProfileType.Video,
                        ExtractChapters = false,
                        MediaSource = new MediaSourceInfo()
                        {
                            Protocol = MediaProtocol.File,
                            Path = filePath,
                            Type = MediaSourceType.Default,
                            IsRemote = false
                        }
                    }, cancellationToken)
                ).RunTimeTicks / 10_000_000;

 

Posted

Hi, what is filePath from? This code will run ffprobe. If you already have an item from the server database then you should just use the database value and avoid probing the media file directly.

Posted

I'm adding a source for a new stream in the channel, but I want to add files shorter than X min only. The source is not in the system yet.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...