1 /*
2  * Copyright (C) 2013-2017 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 __gtk_ardour_export_video_dialog_h__
19 #define __gtk_ardour_export_video_dialog_h__
20 
21 #include <string>
22 
23 #include <gtkmm/box.h>
24 #include <gtkmm/button.h>
25 #include <gtkmm/comboboxtext.h>
26 #include <gtkmm/checkbutton.h>
27 #include <gtkmm/entry.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/progressbar.h>
30 
31 #include "ardour/types.h"
32 #include "ardour/template_utils.h"
33 #include "ardour_dialog.h"
34 
35 #include "time_selection.h"
36 #include "transcode_ffmpeg.h"
37 
38 /** @class ExportVideoDialog
39  *  @brief dialog box and controller for video-file export
40  *
41  *  The ExportVideoDialog includes audio export functions,
42  *  video-encoder presets, progress dialogs and uses
43  *  \ref TranscodeFfmpeg to communicate with ffmpeg.
44  */
45 class ExportVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
46 {
47 public:
48 	ExportVideoDialog ();
49 	~ExportVideoDialog ();
50 
get_exported_filename()51 	std::string get_exported_filename () { return outfn_path_entry.get_text(); }
52 
53 	void apply_state(TimeSelection &tme, bool range);
54 
55 	XMLNode& get_state ();
56 	void set_state (const XMLNode &);
57 
on_response(int response_id)58 	void on_response (int response_id) {
59 		Gtk::Dialog::on_response (response_id);
60 	}
61 
62 private:
63 	TimeSelection export_range;
64 
65 	void on_show ();
66 	void abort_clicked ();
67 	void launch_export ();
68 	void encode_pass (int);
69 	void change_file_extension (std::string);
70 	void width_value_changed ();
71 	void height_value_changed ();
72 
73 	void set_original_file_information ();
74 
75 	void open_outfn_dialog ();
76 	void open_invid_dialog ();
77 	void scale_checkbox_toggled ();
78 	void preset_combo_changed ();
79 	void video_codec_combo_changed ();
80 	void aspect_checkbox_toggled ();
81 	void fps_checkbox_toggled ();
82 
83 	bool _aborted;
84 	bool _twopass;
85 	bool _firstpass;
86 	bool _normalize;
87 
88 	void finished ();
89 	void update_progress (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
90 
91 	boost::shared_ptr<ARDOUR::ExportStatus> status;
92 	sigc::connection audio_progress_connection;
93 	gint audio_progress_display ();
94 	float _previous_progress;
95 
96 	TranscodeFfmpeg *_transcoder;
97 	std::string _insnd;
98 
99 	float _video_source_aspect_ratio;
100 	bool _suspend_signals;
101 	bool _suspend_dirty;
102 
103 	Gtk::Label        outfn_path_label;
104 	Gtk::Entry        outfn_path_entry;
105 	Gtk::Button       outfn_browse_button;
106 	Gtk::Label        invid_path_label;
107 	Gtk::Entry        invid_path_entry;
108 	Gtk::Button       invid_browse_button;
109 	Gtk::ComboBoxText insnd_combo;
110 	Gtk::Button       transcode_button;
111 
112 	Gtk::VBox* vbox;
113 	Gtk::Button *cancel_button;
114 	Gtk::Button abort_button;
115 
116 	Gtk::VBox*  progress_box;
117 	Gtk::ProgressBar pbar;
118 
119 	Gtk::ComboBoxText audio_codec_combo;
120 	Gtk::ComboBoxText video_codec_combo;
121 	Gtk::ComboBoxText video_bitrate_combo;
122 	Gtk::ComboBoxText audio_bitrate_combo;
123 	Gtk::ComboBoxText audio_samplerate_combo;
124 	Gtk::ComboBoxText preset_combo;
125 
126 	Gtk::CheckButton  scale_checkbox;
127 	Gtk::CheckButton  scale_aspect;
128 	Gtk::Adjustment   width_adjustment;
129 	Gtk::SpinButton   width_spinner;
130 	Gtk::Adjustment   height_adjustment;
131 	Gtk::SpinButton   height_spinner;
132 	Gtk::CheckButton  aspect_checkbox;
133 	Gtk::ComboBoxText aspect_combo;
134 	Gtk::CheckButton  normalize_checkbox;
135 	Gtk::CheckButton  twopass_checkbox;
136 	Gtk::CheckButton  optimizations_checkbox;
137 	Gtk::Label        optimizations_label;
138 	Gtk::CheckButton  deinterlace_checkbox;
139 	Gtk::CheckButton  bframes_checkbox;
140 	Gtk::CheckButton  fps_checkbox;
141 	Gtk::ComboBoxText fps_combo;
142 	Gtk::CheckButton  meta_checkbox;
143 #if 1 /* tentative debug mode */
144 	Gtk::CheckButton  debug_checkbox;
145 #endif
146 };
147 
148 #endif /* __gtk_ardour_export_video_dialog_h__ */
149