Ardour  8.12
transcode_ffmpeg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-2018 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef __ardour_transcode_ffmpeg_h__
19 #define __ardour_transcode_ffmpeg_h__
20 
21 #include <string>
22 
23 #include "ardour/system_exec.h"
24 #include "ardour/types.h"
25 
34 class TranscodeFfmpeg : public sigc::trackable, public PBD::ScopedConnectionList
35 {
36 public:
37  struct FFAudioStream {
38  std::string name;
39  std::string stream_id;
40  uint32_t channels;
41  };
42 
43  typedef std::vector<FFAudioStream> FFAudioStreams;
44  typedef std::map<std::string, std::string> FFSettings;
45 
51  TranscodeFfmpeg (std::string f);
52 
61  bool transcode (std::string outfile, const int width = 0, const int height = 0, const int kbitps = 0);
62 
70  bool extract_audio (std::string outfile, ARDOUR::samplecnt_t samplerate, unsigned int stream = 0);
71 
84  bool encode (std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map = true);
85 
87  void cancel ();
88 
91 
94 
96  bool probe_ok ()
97  {
98  return probeok;
99  }
100 
102  bool ffexec_ok ()
103  {
104  return ffexecok;
105  }
106 
107  double get_fps ()
108  {
109  return m_fps;
110  }
111 
112  double get_aspect ()
113  {
114  return m_aspect;
115  }
116 
117  int get_width ()
118  {
119  return m_width;
120  }
121 
122  int get_height ()
123  {
124  return m_height;
125  }
126 
128  {
129  return m_duration;
130  }
131 
132  std::string get_codec ()
133  {
134  return m_codec;
135  }
136 
138  {
139  return m_audio;
140  }
141 
146  {
147  m_duration = d;
148  }
149 
150  /* offset, lead-in/out are in seconds */
151  void set_avoffset (double av_offset)
152  {
153  m_avoffset = av_offset;
154  }
155 
156  void set_leadinout (double lead_in, double lead_out)
157  {
158  m_lead_in = lead_in;
159  m_lead_out = lead_out;
160  }
161 
162  void set_debug (bool onoff)
163  {
164  debug_enable = onoff;
165  }
166 
171  PBD::Signal2<void, ARDOUR::samplecnt_t, ARDOUR::samplecnt_t> Progress;
172 
174  PBD::Signal1<void, int> Finished;
175 
176 protected:
177  bool probe ();
178  void ffmpegparse_v (std::string d, size_t s);
179  void ffmpegparse_a (std::string d, size_t s);
180  void ffprobeparse (std::string d, size_t s);
181  void ffexit ();
182 
183  std::string infile;
185  double m_fps;
186  std::string m_fps_str;
187  double m_aspect;
188  std::string m_sar;
190  int m_width;
191  int m_height;
192  std::string m_codec;
194  double m_avoffset;
195  double m_lead_in;
196  double m_lead_out;
197  bool ffexecok;
198  bool probeok;
200  std::string ffoutput;
201  std::string ffmpeg_exe;
202  std::string ffprobe_exe;
204 };
205 
206 #endif /* __ardour_transcode_ffmpeg_h__ */
wrapper around ffmpeg and ffprobe command-line utils
void set_duration(ARDOUR::samplecnt_t d)
PBD::Signal2< void, ARDOUR::samplecnt_t, ARDOUR::samplecnt_t > Progress
bool transcode(std::string outfile, const int width=0, const int height=0, const int kbitps=0)
std::string m_fps_str
bool encode(std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map=true)
bool extract_audio(std::string outfile, ARDOUR::samplecnt_t samplerate, unsigned int stream=0)
void ffmpegparse_a(std::string d, size_t s)
void set_leadinout(double lead_in, double lead_out)
std::string ffoutput
ARDOUR::samplecnt_t m_duration
TranscodeFfmpeg(std::string f)
void set_avoffset(double av_offset)
std::string infile
FFSettings default_encoder_settings()
void ffprobeparse(std::string d, size_t s)
void ffmpegparse_v(std::string d, size_t s)
void set_debug(bool onoff)
std::string m_codec
PBD::Signal1< void, int > Finished
std::string get_codec()
FFAudioStreams get_audio()
FFAudioStreams m_audio
std::string ffmpeg_exe
std::vector< FFAudioStream > FFAudioStreams
std::map< std::string, std::string > FFSettings
std::string ffprobe_exe
FFSettings default_meta_data()
ARDOUR::SystemExec * ffcmd
ARDOUR::samplecnt_t get_duration()
Temporal::samplecnt_t samplecnt_t
int ffs(int x)
gint height
Definition: xcursors.h:1
gint width
Definition: xcursors.h:1