ardour
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TranscodeFfmpeg Class Reference

wrapper around ffmpeg and ffprobe command-line utils More...

#include <transcode_ffmpeg.h>

Inheritance diagram for TranscodeFfmpeg:
PBD::ScopedConnectionList

Classes

struct  FFAudioStream
 

Public Types

typedef std::vector
< FFAudioStream
FFAudioStreams
 
typedef std::map< std::string,
std::string > 
FFSettings
 

Public Member Functions

 TranscodeFfmpeg (std::string f)
 
virtual ~TranscodeFfmpeg ()
 
bool transcode (std::string, const int outwidth=0, const int outheight=0, const int kbitps=0)
 
bool extract_audio (std::string outfile, ARDOUR::framecnt_t samplerate, unsigned int stream=0)
 
bool encode (std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map=true)
 
FFSettings default_encoder_settings ()
 
FFSettings default_meta_data ()
 
void cancel ()
 
bool probe_ok ()
 
bool ffexec_ok ()
 
double get_fps ()
 
double get_aspect ()
 
int get_width ()
 
int get_height ()
 
ARDOUR::framecnt_t get_duration ()
 
std::string get_codec ()
 
FFAudioStreams get_audio ()
 
void set_duration (ARDOUR::framecnt_t d)
 
void set_avoffset (double av_offset)
 
void set_leadinout (double lead_in, double lead_out)
 
void set_fps (double fps)
 
void set_debug (bool onoff)
 
- Public Member Functions inherited from PBD::ScopedConnectionList
 ScopedConnectionList ()
 
virtual ~ScopedConnectionList ()
 
void add_connection (const UnscopedConnection &c)
 
void drop_connections ()
 

Public Attributes

PBD::Signal2< void,
ARDOUR::framecnt_t,
ARDOUR::framecnt_t
Progress
 
PBD::Signal0< void > Finished
 

Protected Member Functions

bool probe ()
 
char * format_metadata (std::string, std::string)
 
void ffmpegparse_v (std::string d, size_t s)
 
void ffmpegparse_a (std::string d, size_t s)
 
void ffprobeparse (std::string d, size_t s)
 
void ffexit ()
 

Protected Attributes

std::string infile
 
ARDOUR::SystemExecffcmd
 
double m_fps
 
double m_aspect
 
std::string m_sar
 
ARDOUR::framecnt_t m_duration
 
int m_width
 
int m_height
 
std::string m_codec
 
int m_videoidx
 
double m_avoffset
 
double m_lead_in
 
double m_lead_out
 
bool ffexecok
 
bool probeok
 
FFAudioStreams m_audio
 
std::string ffoutput
 
std::string ffmpeg_exe
 
std::string ffprobe_exe
 
bool debug_enable
 

Detailed Description

wrapper around ffmpeg and ffprobe command-line utils

This class includes parsers for stdi/o communication with 'ffmpeg' and 'ffprobe' and provide an abstraction to transcode video-files and extract aufio tracks and query file information.

Definition at line 36 of file transcode_ffmpeg.h.

Member Typedef Documentation

Definition at line 46 of file transcode_ffmpeg.h.

typedef std::map<std::string,std::string> TranscodeFfmpeg::FFSettings

Definition at line 47 of file transcode_ffmpeg.h.

Constructor & Destructor Documentation

TranscodeFfmpeg::TranscodeFfmpeg ( std::string  f)

instantiate a new transcoder. If a file-name is given, the file's attributes (fps, duration, geometry etc) are read.

Parameters
fpath to the video-file to probe or use as input for extract_audio and transcode.

Definition at line 39 of file transcode_ffmpeg.cc.

TranscodeFfmpeg::~TranscodeFfmpeg ( )
virtual

Definition at line 79 of file transcode_ffmpeg.cc.

Member Function Documentation

void TranscodeFfmpeg::cancel ( )

abort any running transcoding process

Definition at line 511 of file transcode_ffmpeg.cc.

TranscodeFfmpeg::FFSettings TranscodeFfmpeg::default_encoder_settings ( )
Returns
array with default encoder settings

Definition at line 260 of file transcode_ffmpeg.cc.

TranscodeFfmpeg::FFSettings TranscodeFfmpeg::default_meta_data ( )
Returns
array with default meta data

Definition at line 272 of file transcode_ffmpeg.cc.

bool TranscodeFfmpeg::encode ( std::string  outfile,
std::string  inf_a,
std::string  inf_v,
TranscodeFfmpeg::FFSettings  ffs,
TranscodeFfmpeg::FFSettings  meta,
bool  map = true 
)

transcode video and mux audio files into a new video-file.

Parameters
outfilefull-path of output file to create (existing files are overwritten)
inf_afilename of input audio-file
inf_vfilename of input video-file
ffsadditional command-line parameters for 'ffmpeg'. key/value pairs eg ffs["-vcodec"] = "mpeg4"
metaadditional meta-data results in -metadata "<key>"="<value>" command-line arguments
mapif set to true stream mapping from input streams to output streams is set to use only the first available stream from the audio & video file (-map 0.0 -map 1.0).
Returns
true if the encoder process was successfully started.

Definition at line 306 of file transcode_ffmpeg.cc.

bool TranscodeFfmpeg::extract_audio ( std::string  outfile,
ARDOUR::framecnt_t  samplerate,
unsigned int  stream = 0 
)

Extract an audio track from the given input file to a new 32bit float little-endian PCM WAV file.

Parameters
outfilefull-path (incl. file-extension) to .wav file to write
sampleratetarget samplerate
streamStream-ID of the audio-track to extract specified as element-number in get_audio().
Returns
true if the transcoder process was successfully started.

Definition at line 403 of file transcode_ffmpeg.cc.

bool TranscodeFfmpeg::ffexec_ok ( )
inline
Returns
true if the ffmpeg/ffparse executables are avail on this system

Definition at line 97 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::ffexit ( )
protected

Definition at line 526 of file transcode_ffmpeg.cc.

void TranscodeFfmpeg::ffmpegparse_a ( std::string  d,
size_t  s 
)
protected

Definition at line 540 of file transcode_ffmpeg.cc.

void TranscodeFfmpeg::ffmpegparse_v ( std::string  d,
size_t  s 
)
protected

Definition at line 564 of file transcode_ffmpeg.cc.

void TranscodeFfmpeg::ffprobeparse ( std::string  d,
size_t  s 
)
protected

Definition at line 534 of file transcode_ffmpeg.cc.

char * TranscodeFfmpeg::format_metadata ( std::string  key,
std::string  value 
)
protected

Definition at line 281 of file transcode_ffmpeg.cc.

double TranscodeFfmpeg::get_aspect ( )
inline

Definition at line 108 of file transcode_ffmpeg.h.

FFAudioStreams TranscodeFfmpeg::get_audio ( )
inline

Definition at line 114 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::get_codec ( )
inline

Definition at line 112 of file transcode_ffmpeg.h.

ARDOUR::framecnt_t TranscodeFfmpeg::get_duration ( )
inline

Definition at line 111 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::get_fps ( )
inline

Definition at line 107 of file transcode_ffmpeg.h.

int TranscodeFfmpeg::get_height ( )
inline

Definition at line 110 of file transcode_ffmpeg.h.

int TranscodeFfmpeg::get_width ( )
inline

Definition at line 109 of file transcode_ffmpeg.h.

bool TranscodeFfmpeg::probe ( )
protected

Definition at line 85 of file transcode_ffmpeg.cc.

bool TranscodeFfmpeg::probe_ok ( )
inline
Returns
true if the input file was parsed correctly on class creation.

Definition at line 95 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::set_avoffset ( double  av_offset)
inline

Definition at line 122 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::set_debug ( bool  onoff)
inline

Definition at line 128 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::set_duration ( ARDOUR::framecnt_t  d)
inline

override file duration used with the Progress signal.

Parameters
dduration in video-frames = length_in_seconds * get_fps()

Definition at line 119 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::set_fps ( double  fps)
inline

Definition at line 125 of file transcode_ffmpeg.h.

void TranscodeFfmpeg::set_leadinout ( double  lead_in,
double  lead_out 
)
inline

Definition at line 123 of file transcode_ffmpeg.h.

bool TranscodeFfmpeg::transcode ( std::string  outfile,
const int  outwidth = 0,
const int  outheight = 0,
const int  kbitps = 0 
)

transcode/import a video-file

Parameters
outfilefull-path (incl. file-extension)
outwidthvideo-width, <0 no scaling)
outheightvideo-height <0 use aspect outwidth /c / aspect-ratio
kbitpsvideo bitrate 0 calculate to use 0.7 bits per pixel on average
Returns
true if the transcoder process was successfully started.

Definition at line 452 of file transcode_ffmpeg.cc.

Member Data Documentation

bool TranscodeFfmpeg::debug_enable
protected

Definition at line 163 of file transcode_ffmpeg.h.

ARDOUR::SystemExec* TranscodeFfmpeg::ffcmd
protected

Definition at line 132 of file transcode_ffmpeg.h.

bool TranscodeFfmpeg::ffexecok
protected

Definition at line 148 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::ffmpeg_exe
protected

Definition at line 160 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::ffoutput
protected

Definition at line 158 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::ffprobe_exe
protected

Definition at line 161 of file transcode_ffmpeg.h.

PBD::Signal0<void> TranscodeFfmpeg::Finished

signal emitted when the transcoder process terminates.

Definition at line 105 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::infile
protected

Definition at line 131 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::m_aspect
protected

Definition at line 137 of file transcode_ffmpeg.h.

FFAudioStreams TranscodeFfmpeg::m_audio
protected

Definition at line 151 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::m_avoffset
protected

Definition at line 145 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::m_codec
protected

Definition at line 142 of file transcode_ffmpeg.h.

ARDOUR::framecnt_t TranscodeFfmpeg::m_duration
protected

Definition at line 139 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::m_fps
protected

Definition at line 136 of file transcode_ffmpeg.h.

int TranscodeFfmpeg::m_height
protected

Definition at line 141 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::m_lead_in
protected

Definition at line 146 of file transcode_ffmpeg.h.

double TranscodeFfmpeg::m_lead_out
protected

Definition at line 147 of file transcode_ffmpeg.h.

std::string TranscodeFfmpeg::m_sar
protected

Definition at line 138 of file transcode_ffmpeg.h.

int TranscodeFfmpeg::m_videoidx
protected

Definition at line 144 of file transcode_ffmpeg.h.

int TranscodeFfmpeg::m_width
protected

Definition at line 140 of file transcode_ffmpeg.h.

bool TranscodeFfmpeg::probeok
protected

Definition at line 149 of file transcode_ffmpeg.h.

PBD::Signal2<void, ARDOUR::framecnt_t, ARDOUR::framecnt_t> TranscodeFfmpeg::Progress

signal emitted when ffmpeg reports progress updates during encode transcode and extract_audio The parameters are current and last video-frame.

Definition at line 103 of file transcode_ffmpeg.h.


The documentation for this class was generated from the following files: