ardour
transcode_ffmpeg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3  Author: Robin Gareus <robin@gareus.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19 */
20 #ifndef __ardour_transcode_ffmpeg_h__
21 #define __ardour_transcode_ffmpeg_h__
22 
23 #include <string>
24 #include "ardour/system_exec.h"
25 #include "ardour/types.h"
26 
27 
36 class TranscodeFfmpeg : public sigc::trackable
38 {
39  public:
40 
41  struct FFAudioStream {
42  std::string name;
43  std::string stream_id;
44  uint32_t channels;
45  };
46  typedef std::vector<FFAudioStream> FFAudioStreams;
47  typedef std::map<std::string,std::string> FFSettings;
48 
49 
56  TranscodeFfmpeg (std::string f);
57  virtual ~TranscodeFfmpeg ();
65  bool transcode (std::string, const int outwidth=0, const int outheight=0, const int kbitps =0);
73  bool extract_audio (std::string outfile, ARDOUR::framecnt_t samplerate, unsigned int stream=0);
86  bool encode (std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map = true);
88  FFSettings default_encoder_settings ();
90  FFSettings default_meta_data ();
92  void cancel();
95  bool probe_ok () { return probeok; }
97  bool ffexec_ok () { return ffexecok; }
98 
103  PBD::Signal2<void, ARDOUR::framecnt_t, ARDOUR::framecnt_t> Progress;
105  PBD::Signal0<void> Finished;
106 
107  double get_fps () { return m_fps; }
108  double get_aspect () { return m_aspect; }
109  int get_width() { return m_width; }
110  int get_height() { return m_height; }
112  std::string get_codec() { return m_codec; }
113 
114  FFAudioStreams get_audio() { return m_audio; }
115 
120 
121  /* offset, lead-in/out are in seconds */
122  void set_avoffset(double av_offset) { m_avoffset = av_offset; }
123  void set_leadinout(double lead_in, double lead_out) { m_lead_in = lead_in; m_lead_out = lead_out; }
124 
125  void set_fps(double fps) { m_fps = fps; } // on export, used for rounding only.
126 
127 #if 1 /* tentative debug mode */
128  void set_debug (bool onoff) { debug_enable = onoff; }
129 #endif
130  protected:
131  std::string infile;
133 
134  bool probe ();
135 
136  double m_fps;
137  double m_aspect;
138  std::string m_sar;
140  int m_width;
141  int m_height;
142  std::string m_codec;
143 
145  double m_avoffset;
146  double m_lead_in;
147  double m_lead_out;
148  bool ffexecok;
149  bool probeok;
150 
151  FFAudioStreams m_audio;
152 
153  char *format_metadata (std::string, std::string);
154  void ffmpegparse_v (std::string d, size_t s);
155  void ffmpegparse_a (std::string d, size_t s);
156  void ffprobeparse (std::string d, size_t s);
157  void ffexit ();
158  std::string ffoutput;
159 
160  std::string ffmpeg_exe;
161  std::string ffprobe_exe;
162 #if 1 /* tentative debug mode */
164 #endif
165 };
166 
167 #endif /* __ardour_transcode_ffmpeg_h__ */
void ffmpegparse_v(std::string d, size_t s)
std::string ffmpeg_exe
int ffs(int x)
Definition: ffs.cc:28
wrapper around ffmpeg and ffprobe command-line utils
FFSettings default_encoder_settings()
FFAudioStreams m_audio
ARDOUR::framecnt_t m_duration
void set_duration(ARDOUR::framecnt_t d)
tuple f
Definition: signals.py:35
virtual ~TranscodeFfmpeg()
bool encode(std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map=true)
std::string ffoutput
std::string m_codec
TranscodeFfmpeg(std::string f)
PBD::Signal2< void, ARDOUR::framecnt_t, ARDOUR::framecnt_t > Progress
int64_t framecnt_t
Definition: types.h:76
void ffmpegparse_a(std::string d, size_t s)
std::map< std::string, std::string > FFSettings
void set_leadinout(double lead_in, double lead_out)
void set_fps(double fps)
bool transcode(std::string, const int outwidth=0, const int outheight=0, const int kbitps=0)
FFAudioStreams get_audio()
bool extract_audio(std::string outfile, ARDOUR::framecnt_t samplerate, unsigned int stream=0)
void ffprobeparse(std::string d, size_t s)
void set_debug(bool onoff)
std::vector< FFAudioStream > FFAudioStreams
void set_avoffset(double av_offset)
PBD::Signal0< void > Finished
char * format_metadata(std::string, std::string)
std::string infile
std::string get_codec()
FFSettings default_meta_data()
ARDOUR::SystemExec * ffcmd
std::string ffprobe_exe
ARDOUR::framecnt_t get_duration()