Vuo  0.8.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Macros | Functions
VuoMovie.cc File Reference

Description

VuoMovie implementation.

Classes

class  VuoMovieDecoder
 Instance class used to control the playback of video. More...
 
struct  VuoMovieDecoder::VuoPacketList
 A replacement for the FFMPEG AVPacketList which uses deprecated functionality. More...
 
struct  VuoMovieDecoder::PacketQueue
 Holds audio AVPackets for decoding. More...
 
struct  VuoMovieDecoder::AVContainer
 Internal struct which contains context and current playback status of VuoMovieDecoder. More...
 

Macros

#define SEC_PER_USEC   .000001
 Seconds per microsecond. Vuo nodes want information in seconds, where ffmpeg operates in microseconds.
 
#define REWIND   .1
 How many seconds behind the requested frame to seek.
 
#define REWIND_INCREMENT   .2
 If the REWIND value does not seek far enough, increment by this value.
 
#define AVCODEC_MAX_AUDIO_FRAME_SIZE   192000
 https://github.com/chelyaev/ffmpeg-tutorial/issues/13
 
#define AV_SYNC_THRESHOLD   0.01
 The maximum allowable latency in either direction for audio offset.
 
#define AV_NOSYNC_THRESHOLD   10.0
 If the audio track is offset by greater than this amount, give up synching and reset.
 
#define SAMPLE_CORRECTION_PERCENT_MAX   10
 Maximum number of samples to add or subtract from a buffer when synching.
 
#define AUDIO_DIFF_AVG_NB   20
 Used in calculating audio offset.
 
#define MAX_PACKET_QUEUE_LENGTH   100
 If we're not using a particular stream, keep the queue only up to this amount.
 

Functions

static void __attribute__ ((constructor)) VuoMovie_initFfmpeg(void)
 Initializes the FFMPEG libraries.
 
void VuoMovie_free (void *movie)
 Releases ffmpeg resources created during this object's lifecycle.
 
VuoMovie VuoMovie_make (const char *path)
 VuoMovie_make: Creates a new VuoMovieDecoder object and returns itself.
 
bool VuoMovie_getNextVideoFrame (VuoMovie movie, VuoImage *image, double *nextFrame)
 VuoMovie_getNextFrame gets the next full frame's image and presentation timestamp (in seconds).
 
bool VuoMovie_containsAudio (VuoMovie movie)
 Returns true if audio channels are present in file, false if not.
 
bool VuoMovie_getNextAudioSample (VuoMovie movie, VuoList_VuoAudioSamples *audioSamples, double *frameTimestampInSeconds)
 Return the next available chunk of audio samples.
 
bool VuoMovie_getPreviousVideoFrame (VuoMovie movie, VuoImage *image, double *previousFrame)
 Returns the frame prior to the internal currently queued frame, and the presentation timestamp associated.
 
bool VuoMovie_seekToSecond (VuoMovie movie, double second)
 Seeks the video to the specified second.
 
double VuoMovie_getCurrentSecond (VuoMovie movie)
 Returns the last successfully decoded timestamp.
 
double VuoMovie_getDuration (VuoMovie movie)
 Returns the duration of the movie in seconds.
 
bool VuoMovie_getInfo (const char *path, double *duration)
 Given a path, this will open and close a video stream and return the duration.
 

Class Documentation

struct VuoMovieDecoder::VuoPacketList
Class Members
VuoPacketList * next
AVPacket pkt
struct VuoMovieDecoder::PacketQueue
Class Members
VuoPacketList * first_pkt
VuoPacketList * last_pkt
int nb_packets
int size
struct VuoMovieDecoder::AVContainer
Class Members
AVCodecContext * aCodecCtx
double audio_diff_avg_coef
int audio_diff_avg_count
double audio_diff_cum
double audio_diff_threshold
AVStream * audio_st
PacketQueue audioPacketQueue
int audioStreamIndex
int64_t avOffset
int bytesPerAudioSample
int64_t currentAudioPTS
int64_t currentAudioTimestampUSEC
int64_t currentVideoPTS
int64_t currentVideoTimestampUSEC
double duration
int64_t firstAudioFrame
int64_t firstVideoFrame
int64_t lastAudioFrame
int64_t lastVideoFrame
int packetDuration
char * path
AVCodecContext * pCodecCtx
AVFormatContext * pFormatCtx
int previousPacketDuration
bool seekUnavailable
int64_t startPts
struct SwrContext * swr_ctx
AVStream * video_st
PacketQueue videoPacketQueue
int videoStreamIndex

Macro Definition Documentation

#define AUDIO_DIFF_AVG_NB   20

Used in calculating audio offset.

#define AV_NOSYNC_THRESHOLD   10.0

If the audio track is offset by greater than this amount, give up synching and reset.

#define AV_SYNC_THRESHOLD   0.01

The maximum allowable latency in either direction for audio offset.

#define AVCODEC_MAX_AUDIO_FRAME_SIZE   192000
#define MAX_PACKET_QUEUE_LENGTH   100

If we're not using a particular stream, keep the queue only up to this amount.

#define REWIND   .1

How many seconds behind the requested frame to seek.

#define REWIND_INCREMENT   .2

If the REWIND value does not seek far enough, increment by this value.

#define SAMPLE_CORRECTION_PERCENT_MAX   10

Maximum number of samples to add or subtract from a buffer when synching.

#define SEC_PER_USEC   .000001

Seconds per microsecond. Vuo nodes want information in seconds, where ffmpeg operates in microseconds.

Function Documentation

static void __attribute__ ( (constructor)  )
static

Initializes the FFMPEG libraries.

bool VuoMovie_containsAudio ( VuoMovie  movie)

Returns true if audio channels are present in file, false if not.

void VuoMovie_free ( void *  movie)

Releases ffmpeg resources created during this object's lifecycle.

Todo:
Close movie file and free memory. (https://b33p.net/kosada/node/6595)
double VuoMovie_getCurrentSecond ( VuoMovie  movie)

Returns the last successfully decoded timestamp.

double VuoMovie_getDuration ( VuoMovie  movie)

Returns the duration of the movie in seconds.

bool VuoMovie_getInfo ( const char *  path,
double *  duration 
)

Given a path, this will open and close a video stream and return the duration.

bool VuoMovie_getNextAudioSample ( VuoMovie  movie,
VuoList_VuoAudioSamples audioSamples,
double *  frameTimestampInSeconds 
)

Return the next available chunk of audio samples.

If none are available, return false.

bool VuoMovie_getNextVideoFrame ( VuoMovie  movie,
VuoImage image,
double *  nextFrame 
)

VuoMovie_getNextFrame gets the next full frame's image and presentation timestamp (in seconds).

Will return true if next frame is found and false if not.

bool VuoMovie_getPreviousVideoFrame ( VuoMovie  movie,
VuoImage image,
double *  previousFrame 
)

Returns the frame prior to the internal currently queued frame, and the presentation timestamp associated.

VuoMovie VuoMovie_make ( const char *  path)

VuoMovie_make: Creates a new VuoMovieDecoder object and returns itself.

Parameters
pathAn absolute path to the video file to open.
Returns
A new VuoMovie object, which may be used to control playback of the film. If the video file fails to open for any reason, this returns NULL.
bool VuoMovie_seekToSecond ( VuoMovie  movie,
double  second 
)

Seeks the video to the specified second.