Reads a ffmpeg video file More...
#include <filmstro_ffmpeg_FFmpegVideoReader.h>
Classes | |
class | DecoderThread |
class for FFmpegReader to decode audio and images asynchronously This is to keep the audio thread as fast as possible More... | |
Public Member Functions | |
FFmpegVideoReader (const int audioFifoSize=192000, const int videoFifoSize=20) | |
Constructs a FFmpegVideoReader. More... | |
virtual | ~FFmpegVideoReader () |
bool | loadMovieFile (const juce::File &inputFile) |
void | closeMovieFile () |
juce::File | getVideoFileName () const |
Returns the currently opened video file. More... | |
double | getFramesPerSecond () const |
Return the framerate. More... | |
double | getCurrentTimeStamp () const |
Get current presentation timecode according to audio stream. More... | |
double | getVideoDuration () const |
returns the duration of the video in seconds according to the container context More... | |
int | getVideoSamplingRate () const |
returns the sampling rate as specified in the video file. More... | |
int | getVideoChannels () const |
returns the number of audio channels in the video file. More... | |
enum AVSampleFormat | getSampleFormat () const |
returns the audio sample format in the video file. More... | |
void | addVideoListener (FFmpegVideoListener *listener) |
add a listener to receive video frames for displaying and to get timestamp notifications. More... | |
void | removeVideoListener (FFmpegVideoListener *listener) |
remove a video listener More... | |
double | getLastVideoPTS () const |
int | getVideoWidth () const |
get the width of the video images according to decoder More... | |
int | getVideoHeight () const |
get the height of the video images according to decoder More... | |
double | getVideoAspectRatio () const |
returns the aspect ratio video frame More... | |
double | getVideoPixelAspect () const |
This will return the aspect ratio of each pixel. More... | |
enum AVPixelFormat | getPixelFormat () const |
get the pixel format of the video images according to decoder, will be converted to BGR0 to be displayed as juce::Image More... | |
AVRational | getVideoTimeBase () const |
This will return the time_base from the video stream. More... | |
void | prepareToPlay (int samplesPerBlockExpected, double sampleRate) override |
void | releaseResources () override |
void | getNextAudioBlock (const juce::AudioSourceChannelInfo &bufferToFill) override |
decodes packets to fill the audioFifo. More... | |
bool | waitForNextAudioBlockReady (const juce::AudioSourceChannelInfo &bufferToFill, const int msecs) const |
Wait until the decoder thread has finished enough data. More... | |
void | setNextReadPosition (juce::int64 newPosition) override |
Seeks in the stream. More... | |
juce::int64 | getNextReadPosition () const override |
Returns the sample count of the next sample to be returned by getNextAudioBlock. More... | |
juce::int64 | getTotalLength () const override |
Returns the total length in samples. More... | |
bool | isLooping () const override |
Returns true if this source is actually playing in a loop. More... | |
void | setLooping (bool shouldLoop) override |
Tells the source whether you'd like it to play in a loop. More... | |
AVCodecContext * | getVideoContext () const |
AVCodecContext * | getAudioContext () const |
AVCodecContext * | getSubtitleContext () const |
Static Public Member Functions | |
static juce::String | formatTimeCode (const double tc) |
Friends | |
class | juce::WeakReference< FFmpegVideoReader > |
Reads a ffmpeg video file
The FFmpegVideoReader opens a ffmpeg stream for reading. It acts as regular juce::AudioSource and can be played like that. Additionally it provides a FFmpegVideoSource which can be used to display the video frames or to write the file back using a FFmpegVideoWriter.
FFmpegVideoReader::FFmpegVideoReader | ( | const int | audioFifoSize = 192000 , |
const int | videoFifoSize = 20 |
||
) |
Constructs a FFmpegVideoReader.
Because usually audio and video frames may be in arbitrary order, the reader provides a FIFO for audio samples and a FIFO for video frames.
|
virtual |
void FFmpegVideoReader::addVideoListener | ( | FFmpegVideoListener * | listener | ) |
add a listener to receive video frames for displaying and to get timestamp notifications.
The video frames will happen synchronously to getNextAudioBlock
void FFmpegVideoReader::closeMovieFile | ( | ) |
|
static |
AVCodecContext * FFmpegVideoReader::getAudioContext | ( | ) | const |
double FFmpegVideoReader::getCurrentTimeStamp | ( | ) | const |
Get current presentation timecode according to audio stream.
double FFmpegVideoReader::getFramesPerSecond | ( | ) | const |
Return the framerate.
If framerate in the decoder context is not set, this will return the timebase of the video stream.
double FFmpegVideoReader::getLastVideoPTS | ( | ) | const |
|
override |
decodes packets to fill the audioFifo.
If a video packet is found it will be forwarded to VideoDecoderThread
|
override |
Returns the sample count of the next sample to be returned by getNextAudioBlock.
enum AVPixelFormat FFmpegVideoReader::getPixelFormat | ( | ) | const |
get the pixel format of the video images according to decoder, will be converted to BGR0 to be displayed as juce::Image
enum AVSampleFormat FFmpegVideoReader::getSampleFormat | ( | ) | const |
returns the audio sample format in the video file.
The FFmpegVideoReader will convert into discrete channels of float values
AVCodecContext * FFmpegVideoReader::getSubtitleContext | ( | ) | const |
|
override |
Returns the total length in samples.
May not be accurate, because it uses ffmpegs duration property multiplied with the samplerate
double FFmpegVideoReader::getVideoAspectRatio | ( | ) | const |
returns the aspect ratio video frame
int FFmpegVideoReader::getVideoChannels | ( | ) | const |
returns the number of audio channels in the video file.
Make sure you call getNextAudioBuffer with the same number of channels
AVCodecContext * FFmpegVideoReader::getVideoContext | ( | ) | const |
double FFmpegVideoReader::getVideoDuration | ( | ) | const |
returns the duration of the video in seconds according to the container context
juce::File FFmpegVideoReader::getVideoFileName | ( | ) | const |
Returns the currently opened video file.
int FFmpegVideoReader::getVideoHeight | ( | ) | const |
get the height of the video images according to decoder
double FFmpegVideoReader::getVideoPixelAspect | ( | ) | const |
This will return the aspect ratio of each pixel.
int FFmpegVideoReader::getVideoSamplingRate | ( | ) | const |
returns the sampling rate as specified in the video file.
This can be different from the samplingrate the prepareToPlay was called with. The FFmpegVideoReader will not resample.
AVRational FFmpegVideoReader::getVideoTimeBase | ( | ) | const |
This will return the time_base from the video stream.
int FFmpegVideoReader::getVideoWidth | ( | ) | const |
get the width of the video images according to decoder
|
override |
Returns true if this source is actually playing in a loop.
bool FFmpegVideoReader::loadMovieFile | ( | const juce::File & | inputFile | ) |
|
override |
|
override |
void FFmpegVideoReader::removeVideoListener | ( | FFmpegVideoListener * | listener | ) |
remove a video listener
|
override |
Tells the source whether you'd like it to play in a loop.
|
override |
Seeks in the stream.
bool FFmpegVideoReader::waitForNextAudioBlockReady | ( | const juce::AudioSourceChannelInfo & | bufferToFill, |
const int | msecs | ||
) | const |
Wait until the decoder thread has finished enough data.
This is needed for non-realtime processing.
|
friend |