Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
19 
20 #include <string>
21 
22 #include "ardour/system_exec.h"
23 #include "ardour/types.h"
24 
33 class TranscodeFfmpeg : public sigc::trackable, public PBD::ScopedConnectionList
34 {
35 public:
36  struct FFAudioStream {
37  std::string name;
38  std::string stream_id;
39  uint32_t channels;
40  };
41 
42  typedef std::vector<FFAudioStream> FFAudioStreams;
43  typedef std::map<std::string, std::string> FFSettings;
44 
50  TranscodeFfmpeg (std::string f);
51 
60  bool transcode (std::string outfile, const int width = 0, const int height = 0, const int kbitps = 0);
61 
69  bool extract_audio (std::string outfile, ARDOUR::samplecnt_t samplerate, unsigned int stream = 0);
70 
83  bool encode (std::string outfile, std::string inf_a, std::string inf_v, FFSettings ffs, FFSettings meta, bool map = true);
84 
86  void cancel ();
87 
90 
93 
95  bool probe_ok ()
96  {
97  return probeok;
98  }
99 
101  bool ffexec_ok ()
102  {
103  return ffexecok;
104  }
105 
106  double get_fps ()
107  {
108  return m_fps;
109  }
110 
111  double get_aspect ()
112  {
113  return m_aspect;
114  }
115 
116  int get_width ()
117  {
118  return m_width;
119  }
120 
121  int get_height ()
122  {
123  return m_height;
124  }
125 
127  {
128  return m_duration;
129  }
130 
131  std::string get_codec ()
132  {
133  return m_codec;
134  }
135 
137  {
138  return m_audio;
139  }
140 
145  {
146  m_duration = d;
147  }
148 
149  /* offset, lead-in/out are in seconds */
150  void set_avoffset (double av_offset)
151  {
152  m_avoffset = av_offset;
153  }
154 
155  void set_leadinout (double lead_in, double lead_out)
156  {
157  m_lead_in = lead_in;
158  m_lead_out = lead_out;
159  }
160 
161  void set_debug (bool onoff)
162  {
163  debug_enable = onoff;
164  }
165 
171 
173  PBD::Signal<void(int)> Finished;
174 
175 protected:
176  bool probe ();
177  void ffmpegparse_v (std::string d, size_t s);
178  void ffmpegparse_a (std::string d, size_t s);
179  void ffprobeparse (std::string d, size_t s);
180  void ffexit ();
181 
182  std::string infile;
184  double m_fps;
185  std::string m_fps_str;
186  double m_aspect;
187  std::string m_sar;
189  int m_width;
190  int m_height;
191  std::string m_codec;
193  double m_avoffset;
194  double m_lead_in;
195  double m_lead_out;
196  bool ffexecok;
197  bool probeok;
199  std::string ffoutput;
200  std::string ffmpeg_exe;
201  std::string ffprobe_exe;
203 };
204 
wrapper around ffmpeg and ffprobe command-line utils
void set_duration(ARDOUR::samplecnt_t d)
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)
PBD::Signal< void(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)> Progress
bool extract_audio(std::string outfile, ARDOUR::samplecnt_t samplerate, unsigned int stream=0)
PBD::Signal< void(int)> Finished
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
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