private static IContainer LoadMetadataFromFFprobe(this IContainer resource) { var mediaLoader = new MediaLoader(resource); if (mediaLoader.HasAudio) { resource.Streams.AddRange(mediaLoader.BaseData.Streams .OfType <AudioStreamMetadata>() .Select(audioMetadata => AudioStream.Create(MetadataInfo.Create(audioMetadata)))); } if (mediaLoader.HasVideo) { resource.Streams.AddRange(mediaLoader.BaseData.Streams .OfType <VideoStreamMetadata>() .Select(videoMetadata => VideoStream.Create(MetadataInfo.Create(videoMetadata)))); } if (mediaLoader.HasData) { resource.Streams.AddRange(mediaLoader.BaseData.Streams .OfType <DataStreamMetadata>() .Select(dataMetadata => DataStream.Create(MetadataInfo.Create(dataMetadata)))); } return(resource); }
public MetadataInfoTreeContainer EditInfo(MetadataInfoTreeContainer infoToUpdate, List <MetadataInfoTreeContainer> suppliedInfo) { var emptyMetadataInfo = MetadataInfo.Create(); emptyMetadataInfo.AudioMetadata = new AudioStreamMetadata { SampleRate = SampleRate ?? 44100, Duration = TimeSpan.MaxValue, DurationTs = long.MaxValue, }; return(MetadataInfoTreeContainer.Create(AudioStream.Create(emptyMetadataInfo))); }
public void Initialize(params Encoder[] encoders) { if (encoders is null) { throw new ArgumentNullException(nameof(encoders)); } var streams = new MediaStream[encoders.Length]; for (var i = 0; i < streams.Length; i++) { var encoder = encoders[i]; // Ensure a stream was intilized... if (encoder.Stream is null) { MediaStream stream; switch (encoder) { case AudioEncoder _: stream = VideoStream.Create(this, encoder); break; case VideoEncoder _: stream = AudioStream.Create(this, encoder); break; default: throw new Exception("Invalid encoder type:" + encoder.GetType().Name); } stream.TimeBase = encoder.Context.TimeBase; } if (Context.OutputFormat.Flags.HasFlag(OutputFormatFlags.GlobalHeader)) { encoder.Context.Flags |= (int)OutputFormatFlags.GlobalHeader; } streams[i] = encoder.Stream; encoder.Open(); ffmpeg.avcodec_parameters_from_context(encoder.Stream.Pointer->codecpar, encoder.Context.Pointer); } this.Context.Streams = streams; }
private static IContainer LoadMetadataFromFFprobe(this IContainer resource) { var mediaLoader = new Metadata.FFprobe.MediaLoader(resource); if (mediaLoader.HasAudio) { var audioStreamMetadata = MetadataInfo.Create(mediaLoader.AudioStream); resource.Streams.Add(AudioStream.Create(audioStreamMetadata)); } if (mediaLoader.HasVideo) { var videoStreamMetadata = MetadataInfo.Create(mediaLoader.VideoStream); resource.Streams.Add(VideoStream.Create(videoStreamMetadata)); } return(resource); }