// Copyright (c) Meta Platforms, Inc. and affiliates. // All rights reserved. // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. #pragma once #include #include #include extern "C" { #include #include #include } namespace facebook::torchcodec { struct StreamMetadata { // Common (video and audio) fields derived from the AVStream. int streamIndex; // See this link for what various values are available: // https://ffmpeg.org/doxygen/trunk/group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48 AVMediaType mediaType; std::optional codecId; std::optional codecName; std::optional durationSecondsFromHeader; std::optional beginStreamSecondsFromHeader; std::optional numFramesFromHeader; std::optional numKeyFrames; std::optional averageFpsFromHeader; std::optional bitRate; // More accurate duration, obtained by scanning the file. // These presentation timestamps are in time base. std::optional beginStreamPtsFromContent; std::optional endStreamPtsFromContent; // These presentation timestamps are in seconds. std::optional beginStreamPtsSecondsFromContent; std::optional endStreamPtsSecondsFromContent; // This can be useful for index-based seeking. std::optional numFramesFromContent; // Video-only fields derived from the AVCodecContext. std::optional width; std::optional height; std::optional sampleAspectRatio; // Audio-only fields std::optional sampleRate; std::optional numChannels; std::optional sampleFormat; }; struct ContainerMetadata { std::vector allStreamMetadata; int numAudioStreams = 0; int numVideoStreams = 0; // Note that this is the container-level duration, which is usually the max // of all stream durations available in the container. std::optional durationSecondsFromHeader; // Total BitRate level information at the container level in bit/s std::optional bitRate; // If set, this is the index to the default audio stream. std::optional bestAudioStreamIndex; // If set, this is the index to the default video stream. std::optional bestVideoStreamIndex; }; } // namespace facebook::torchcodec