26 #include <sys/types.h>
30 #include <sigc++/bind.h>
32 #include <glib/gstdio.h>
58 , path_label (
_(
"Output File:"),
Gtk::ALIGN_LEFT)
59 , browse_button (
_(
"Browse"))
60 , transcode_button (
_(
"OK"))
61 , abort_button (
_(
"Abort"))
63 , aspect_checkbox (
_(
"Height = "))
64 , height_adjustment (128, 0, 1920, 1, 16, 0)
65 , height_spinner (height_adjustment)
66 , bitrate_checkbox (
_(
"Manual Override"))
67 , bitrate_adjustment (2000, 500, 10000, 10, 100, 0)
68 , bitrate_spinner (bitrate_adjustment)
70 , debug_checkbox (
_(
"Debug Mode: Print ffmpeg command and output to stdout."))
80 set_name (
"TranscodeVideoDialog");
82 set_skip_taskbar_hint (
true);
83 set_resizable (
false);
86 vbox = manage (
new VBox);
87 VBox* options_box = manage (
new VBox);
88 HBox* path_hbox = manage (
new HBox);
94 path_hbox->pack_start (
path_label,
false,
false, 3);
95 path_hbox->pack_start (
path_entry,
true,
true, 3);
107 l = manage (
new Label (
_(
"<b>File Information</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
108 l->set_use_markup ();
109 options_box->pack_start (*l,
false,
true, 4);
113 l = manage (
new Label (
_(
"No ffprobe or ffmpeg executables could be found on this system. Video Import is not possible until you install those tools. See the Log window for more information."), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
115 options_box->pack_start (*l,
false,
true, 4);
120 l = manage (
new Label (
string_compose(
_(
"File-info can not be read. Most likely '%1' is not a valid video-file or an unsupported video codec or format."),
infn), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
121 options_box->pack_start (*l,
false,
true, 4);
131 Table* t = manage (
new Table (4, 2));
133 options_box->pack_start (*t,
true,
true, 4);
134 l = manage (
new Label (
_(
"FPS:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
135 t->attach (*l, 0, 1, 0, 1);
136 l = manage (
new Label (
_(
"Duration:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
137 t->attach (*l, 2, 3, 0, 1);
138 l = manage (
new Label (
_(
"Codec:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
139 t->attach (*l, 0, 1, 1, 2);
140 l = manage (
new Label (
_(
"Geometry:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
141 t->attach (*l, 2, 3, 1, 2);
143 std::ostringstream osstream;
145 l = manage (
new Label (osstream.str(), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
146 t->attach (*l, 1, 2, 0, 1);
149 osstream << w <<
"x" << h;
150 l = manage (
new Label (osstream.str(), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
151 t->attach (*l, 3, 4, 1, 2);
158 osstream << setfill(
'0') << setw(2);
159 osstream << (sec / 3600) <<
":";
160 osstream << setfill(
'0') << setw(2);
161 osstream << ((sec /60 )%60) <<
":";
162 osstream << setfill(
'0') << setw(2);
163 osstream << (sec%60) <<
":";
164 osstream << setfill(
'0') << setw(2);
167 l = manage (
new Label (osstream.str(), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
168 t->attach (*l, 3, 4, 0, 1);
172 l = manage (
new Label (osstream.str(), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
173 t->attach (*l, 1, 2, 1, 2);
176 l = manage (
new Label (
_(
"<b>Import Settings</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
177 l->set_use_markup ();
178 options_box->pack_start (*l,
false,
true, 4);
181 video_combo.append_text(
_(
"Reference From Current Location (Previously Transcoded Files Only)"));
183 video_combo.append_text(
_(
"Import/Transcode Video to Session"));
191 video_combo.append_text(
_(
"Do Not Import Video (Audio Import Only)"));
194 options_box->pack_start (
video_combo,
false,
false, 4);
196 Table* t = manage (
new Table (4, 3));
198 options_box->pack_start (*t,
true,
true, 4);
200 l = manage (
new Label (
_(
"Scale Video: Width = "), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
201 t->attach (*l, 0, 1, 0, 1);
208 if (w > 1920) {
scale_combo.append_text(
"1920 (hd1080)"); }
209 if (w > 1408) {
scale_combo.append_text(
"1408 (16cif)"); }
210 if (w > 1280) {
scale_combo.append_text(
"1280 (sxga, hd720)"); }
211 if (w > 1024) {
scale_combo.append_text(
"1024 (xga)"); }
212 if (w > 852) {
scale_combo.append_text(
" 852 (hd480)"); }
213 if (w > 768) {
scale_combo.append_text(
" 768 (PAL)"); }
214 if (w > 720) {
scale_combo.append_text(
" 720 (PAL)"); }
215 if (w > 640) {
scale_combo.append_text(
" 640 (vga, ega)"); }
216 if (w > 352) {
scale_combo.append_text(
" 352 (cif)"); }
217 if (w > 320) {
scale_combo.append_text(
" 320 (cga, qvga)"); }
218 if (w > 176) {
scale_combo.append_text(
" 176 (qcif)"); }
222 l = manage (
new Label (
_(
"Bitrate (KBit/s):"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
223 t->attach (*l, 0, 1, 1, 2);
227 l = manage (
new Label (
_(
"Extract Audio:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
228 t->attach (*l, 0, 1, 2, 3);
231 if (as.size() == 0) {
236 for (TranscodeFfmpeg::FFAudioStreams::iterator it = as.begin(); it < as.end(); ++it) {
246 vbox->pack_start (*path_hbox,
false,
false);
247 vbox->pack_start (*options_box,
false,
true);
249 get_vbox()->set_spacing (4);
250 get_vbox()->pack_start (*
vbox,
false,
false);
273 show_all_children ();
298 if (a == 0 || c > a) {
299 pbar.set_pulse_step(.5);
303 pbar.set_fraction ((
double)c / (
double) a);
314 Gtk::Dialog::response(RESPONSE_CANCEL);
319 Gtk::Dialog::response(RESPONSE_ACCEPT);
349 audio_stream =
audio_combo.get_active_row_number() -1;
355 Gtk::Dialog::response(RESPONSE_CANCEL);
366 pbar.set_size_request(300,-1);
393 int scale_width, scale_height, bitrate;
414 Gtk::Dialog::response(RESPONSE_CANCEL);
436 if (i == 2 &&
audio_combo.get_active_row_number() == 0) {
503 Gtk::FileChooserDialog dialog(
_(
"Save Transcoded Video File"), Gtk::FILE_CHOOSER_ACTION_SAVE);
506 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
507 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
509 int result = dialog.run();
511 if (result == Gtk::RESPONSE_OK) {
512 std::string filename = dialog.get_filename();
514 if (filename.length()) {
std::string video_get_docroot(ARDOUR::RCConfiguration *config)
framecnt_t nominal_frame_rate() const
Gtk::SpinButton bitrate_spinner
int atoi(const string &s)
Gtk::Label progress_label
std::string video_dest_file(const std::string, const std::string)
Gtk::SpinButton height_spinner
wrapper around ffmpeg and ffprobe command-line utils
const std::string video_path() const
TranscodeFfmpeg * transcoder
static ARDOUR_UI * instance()
Gtk::ComboBoxText audio_combo
void audio_combo_changed()
void dialog_progress_mode()
PBD::Signal2< void, ARDOUR::framecnt_t, ARDOUR::framecnt_t > Progress
Gtk::CheckButton aspect_checkbox
LIBARDOUR_API RCConfiguration * Config
void open_browse_dialog()
bool confirm_video_outfn(std::string, std::string docroot="")
Gtk::Button browse_button
void update_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t)
common functions used for video-file im/export
Gtk::Button * cancel_button
Gtk::CheckButton debug_checkbox
bool transcode(std::string, const int outwidth=0, const int outheight=0, const int kbitps=0)
std::string video_dest_dir(const std::string, const std::string)
FFAudioStreams get_audio()
bool extract_audio(std::string outfile, ARDOUR::framecnt_t samplerate, unsigned int stream=0)
bool pending_audio_extract
PBD::Signal0< void > StartNextStage
void video_combo_changed()
void scale_combo_changed()
void set_debug(bool onoff)
std::vector< FFAudioStream > FFAudioStreams
Gtk::Button transcode_button
virtual void set_session(ARDOUR::Session *)
PBD::Signal0< void > Finished
Gtk::ComboBoxText scale_combo
void aspect_checkbox_toggled()
TranscodeVideoDialog(ARDOUR::Session *, std::string)
const SessionDirectory & session_directory() const
Gtk::CheckButton bitrate_checkbox
ARDOUR::Session * _session
void bitrate_checkbox_toggled()
Gtk::ComboBoxText video_combo
std::string string_compose(const std::string &fmt, const T1 &o1)
double atof(const string &s)
ARDOUR::framecnt_t get_duration()
VtlTranscodeOption import_option()
void popup_error(const std::string &text)