Ardour  9.0-pre0-582-g084a23a80d
TranscodeFfmpeg Class Reference

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

#include <transcode_ffmpeg.h>

Inheritance diagram for TranscodeFfmpeg:
[legend]

Classes

struct  FFAudioStream
 

Public Types

typedef std::vector< FFAudioStreamFFAudioStreams
 
typedef std::map< std::string, std::string > FFSettings
 

Public Member Functions

 TranscodeFfmpeg (std::string f)
 
bool transcode (std::string outfile, const int width=0, const int height=0, const int kbitps=0)
 
bool extract_audio (std::string outfile, ARDOUR::samplecnt_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)
 
void cancel ()
 
FFSettings default_encoder_settings ()
 
FFSettings default_meta_data ()
 
bool probe_ok ()
 
bool ffexec_ok ()
 
double get_fps ()
 
double get_aspect ()
 
int get_width ()
 
int get_height ()
 
ARDOUR::samplecnt_t get_duration ()
 
std::string get_codec ()
 
FFAudioStreams get_audio ()
 
void set_duration (ARDOUR::samplecnt_t d)
 
void set_avoffset (double av_offset)
 
void set_leadinout (double lead_in, double lead_out)
 
void set_debug (bool onoff)
 
- Public Member Functions inherited from PBD::ScopedConnectionList
 ScopedConnectionList ()
 
 ScopedConnectionList (const ScopedConnectionList &)=delete
 
ScopedConnectionListoperator= (const ScopedConnectionList &)=delete
 
virtual ~ScopedConnectionList ()
 
void add_connection (const UnscopedConnection &c)
 
void drop_connections ()
 

Public Attributes

PBD::Signal< void(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)> Progress
 
PBD::Signal< void(int)> Finished
 

Protected Member Functions

bool probe ()
 
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
 
std::string m_fps_str
 
double m_aspect
 
std::string m_sar
 
ARDOUR::samplecnt_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 33 of file transcode_ffmpeg.h.

Member Typedef Documentation

◆ FFAudioStreams

Definition at line 42 of file transcode_ffmpeg.h.

◆ FFSettings

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

Definition at line 43 of file transcode_ffmpeg.h.

Constructor & Destructor Documentation

◆ TranscodeFfmpeg()

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 .

Member Function Documentation

◆ cancel()

void TranscodeFfmpeg::cancel ( )

abort any running transcoding process

◆ default_encoder_settings()

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

◆ default_meta_data()

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

◆ encode()

bool TranscodeFfmpeg::encode ( std::string  outfile,
std::string  inf_a,
std::string  inf_v,
FFSettings  ffs,
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.

◆ extract_audio()

bool TranscodeFfmpeg::extract_audio ( std::string  outfile,
ARDOUR::samplecnt_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.

◆ ffexec_ok()

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

Definition at line 101 of file transcode_ffmpeg.h.

◆ ffexit()

void TranscodeFfmpeg::ffexit ( )
protected

◆ ffmpegparse_a()

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

◆ ffmpegparse_v()

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

◆ ffprobeparse()

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

◆ get_aspect()

double TranscodeFfmpeg::get_aspect ( )
inline

Definition at line 111 of file transcode_ffmpeg.h.

◆ get_audio()

FFAudioStreams TranscodeFfmpeg::get_audio ( )
inline

Definition at line 136 of file transcode_ffmpeg.h.

◆ get_codec()

std::string TranscodeFfmpeg::get_codec ( )
inline

Definition at line 131 of file transcode_ffmpeg.h.

◆ get_duration()

ARDOUR::samplecnt_t TranscodeFfmpeg::get_duration ( )
inline

Definition at line 126 of file transcode_ffmpeg.h.

◆ get_fps()

double TranscodeFfmpeg::get_fps ( )
inline

Definition at line 106 of file transcode_ffmpeg.h.

◆ get_height()

int TranscodeFfmpeg::get_height ( )
inline

Definition at line 121 of file transcode_ffmpeg.h.

◆ get_width()

int TranscodeFfmpeg::get_width ( )
inline

Definition at line 116 of file transcode_ffmpeg.h.

◆ probe()

bool TranscodeFfmpeg::probe ( )
protected

◆ probe_ok()

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.

◆ set_avoffset()

void TranscodeFfmpeg::set_avoffset ( double  av_offset)
inline

Definition at line 150 of file transcode_ffmpeg.h.

◆ set_debug()

void TranscodeFfmpeg::set_debug ( bool  onoff)
inline

Definition at line 161 of file transcode_ffmpeg.h.

◆ set_duration()

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

override file duration used with the Progress signal.

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

Definition at line 144 of file transcode_ffmpeg.h.

◆ set_leadinout()

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

Definition at line 155 of file transcode_ffmpeg.h.

◆ transcode()

bool TranscodeFfmpeg::transcode ( std::string  outfile,
const int  width = 0,
const int  height = 0,
const int  kbitps = 0 
)

transcode to (import a video-file)

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

Member Data Documentation

◆ debug_enable

bool TranscodeFfmpeg::debug_enable
protected

Definition at line 202 of file transcode_ffmpeg.h.

◆ ffcmd

ARDOUR::SystemExec* TranscodeFfmpeg::ffcmd
protected

Definition at line 183 of file transcode_ffmpeg.h.

◆ ffexecok

bool TranscodeFfmpeg::ffexecok
protected

Definition at line 196 of file transcode_ffmpeg.h.

◆ ffmpeg_exe

std::string TranscodeFfmpeg::ffmpeg_exe
protected

Definition at line 200 of file transcode_ffmpeg.h.

◆ ffoutput

std::string TranscodeFfmpeg::ffoutput
protected

Definition at line 199 of file transcode_ffmpeg.h.

◆ ffprobe_exe

std::string TranscodeFfmpeg::ffprobe_exe
protected

Definition at line 201 of file transcode_ffmpeg.h.

◆ Finished

PBD::Signal<void(int)> TranscodeFfmpeg::Finished

signal emitted when the transcoder process terminates.

Definition at line 173 of file transcode_ffmpeg.h.

◆ infile

std::string TranscodeFfmpeg::infile
protected

Definition at line 182 of file transcode_ffmpeg.h.

◆ m_aspect

double TranscodeFfmpeg::m_aspect
protected

Definition at line 186 of file transcode_ffmpeg.h.

◆ m_audio

FFAudioStreams TranscodeFfmpeg::m_audio
protected

Definition at line 198 of file transcode_ffmpeg.h.

◆ m_avoffset

double TranscodeFfmpeg::m_avoffset
protected

Definition at line 193 of file transcode_ffmpeg.h.

◆ m_codec

std::string TranscodeFfmpeg::m_codec
protected

Definition at line 191 of file transcode_ffmpeg.h.

◆ m_duration

ARDOUR::samplecnt_t TranscodeFfmpeg::m_duration
protected

Definition at line 188 of file transcode_ffmpeg.h.

◆ m_fps

double TranscodeFfmpeg::m_fps
protected

Definition at line 184 of file transcode_ffmpeg.h.

◆ m_fps_str

std::string TranscodeFfmpeg::m_fps_str
protected

Definition at line 185 of file transcode_ffmpeg.h.

◆ m_height

int TranscodeFfmpeg::m_height
protected

Definition at line 190 of file transcode_ffmpeg.h.

◆ m_lead_in

double TranscodeFfmpeg::m_lead_in
protected

Definition at line 194 of file transcode_ffmpeg.h.

◆ m_lead_out

double TranscodeFfmpeg::m_lead_out
protected

Definition at line 195 of file transcode_ffmpeg.h.

◆ m_sar

std::string TranscodeFfmpeg::m_sar
protected

Definition at line 187 of file transcode_ffmpeg.h.

◆ m_videoidx

int TranscodeFfmpeg::m_videoidx
protected

Definition at line 192 of file transcode_ffmpeg.h.

◆ m_width

int TranscodeFfmpeg::m_width
protected

Definition at line 189 of file transcode_ffmpeg.h.

◆ probeok

bool TranscodeFfmpeg::probeok
protected

Definition at line 197 of file transcode_ffmpeg.h.

◆ Progress

PBD::Signal<void(ARDOUR::samplecnt_t, ARDOUR::samplecnt_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 170 of file transcode_ffmpeg.h.


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