Exemple #1
0
        public InputMediaFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new ArgumentException($"The file ({filePath}) does not exists!", nameof(filePath));
            }

            int errorCode;

            fixed(AVFormatContext **formatContextPointerPointer = &this.avFormatContextPtr)
            {
                errorCode = ffmpeg.avformat_open_input(formatContextPointerPointer, filePath, null, null);
                FFmpegWrapperException.ThrowInCaseOfError(errorCode);
            }

            errorCode = ffmpeg.avformat_find_stream_info(this.avFormatContextPtr, null);
            FFmpegWrapperException.ThrowInCaseOfError(errorCode);

            Streams = CreateStreams();

            MediaStream firstVideoStream = Streams.FirstOrDefault(s => s.CodecType == MediaType.AVMEDIA_TYPE_VIDEO);

            if (firstVideoStream == null)
            {
                throw new NotSupportedException($"The video file ({filePath}) does not contain video stream!");
            }

            FrameTime = TimeSpan.FromSeconds(1 / firstVideoStream.FrameRate.Value);
        }
Exemple #2
0
        public bool TryFindStream(Guid streamId, out StreamAction stream)
        {
            stream = Streams
                     .FirstOrDefault(x => x.Id == streamId);

            return(stream != null);
        }
Exemple #3
0
        public bool TryFindStream(string streamKey, out StreamAction stream)
        {
            stream = Streams
                     .FirstOrDefault(x => x.Key == streamKey);

            return(stream != null);
        }
Exemple #4
0
        public Task RemoveStreamFromCollectionAndDatabase(StreamMedia stream)
        {
            var collectionStream = Streams?.FirstOrDefault(x => x.Path == stream.Path);

            if (collectionStream != null)
            {
                Streams?.Remove(collectionStream);
            }
            return(DeleteStream(stream));
        }
 public StreamInformation InformationFromResolution(string reolution)
 {
     return(Streams.FirstOrDefault(e => e.Resolution == reolution));
 }