+ if (_transcoder) { delete _transcoder; _transcoder = 0;}
+}
+
+void
+ExportVideoDialog::set_original_file_information()
+{
+ assert(_transcoder == 0);
+ std::string infile = invid_path_entry.get_text();
+
+ if (scale_checkbox.get_active()) {
+ // user may have set custom values already, don't touch.
+ return;
+ }
+ if (infile == "" || !Glib::file_test(infile, Glib::FILE_TEST_EXISTS)) {
+ return;
+ }
+
+ _transcoder = new TranscodeFfmpeg(infile);
+ if (_transcoder->probe_ok()) {
+ _video_source_aspect_ratio = -1;
+ width_spinner.set_value(_transcoder->get_width());
+ height_spinner.set_value(_transcoder->get_height());
+ _video_source_aspect_ratio = _transcoder->get_aspect();
+ }
+
+ delete _transcoder; _transcoder = 0;
+}
+void
+ExportVideoDialog::apply_state (TimeSelection &tme, bool range)
+{
+ _suspend_dirty = true; // TODO really just queue 'dirty' and mark session dirty on "Export"
+
+ export_range = tme;
+ _video_source_aspect_ratio = -1;
+
+ outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi");
+
+ // TODO remember setting for export-range.. somehow, (let explicit range override)
+ sampleoffset_t av_offset = ARDOUR_UI::instance()->video_timeline->get_offset();
+
+ insnd_combo.remove_all ();
+
+ insnd_combo.append_text (_("from session start marker to session end marker"));
+
+ if (av_offset < 0 ) {
+ insnd_combo.append_text (_("from 00:00:00:00 to the video end"));
+ } else {
+ insnd_combo.append_text (_("from video start to video end"));
+ }
+ if (!export_range.empty()) {
+ insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_sample()
+ }
+ if (range) {
+ insnd_combo.set_active(2);
+ } else {
+ insnd_combo.set_active(0);
+ }
+
+ preset_combo.set_active(0);
+ audio_codec_combo.set_active(0);
+ video_codec_combo.set_active(0);
+ audio_bitrate_combo.set_active(0);
+ audio_samplerate_combo.set_active(2);
+ video_bitrate_combo.set_active(0);
+ aspect_combo.set_active(1);
+
+ scale_checkbox.set_active(false);
+ scale_aspect.set_active(true);
+ aspect_checkbox.set_active(false);
+ normalize_checkbox.set_active(false);
+ twopass_checkbox.set_active(false);
+ optimizations_checkbox.set_active(false);
+ deinterlace_checkbox.set_active(false);
+ bframes_checkbox.set_active(false);
+ fps_checkbox.set_active(false);
+ meta_checkbox.set_active(false);
+
+ float tcfps = _session->timecode_frames_per_second();
+
+ XMLNode* node = _session->extra_xml (X_("Videotimeline"));
+ bool filenameset = false;
+ if (node) {
+ std::string filename;
+ if (node->get_property(X_("OriginalVideoFile"), filename)) {
+ if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
+ invid_path_entry.set_text (filename);
+ filenameset = true;
+ }
+ }
+
+ bool local_file;
+
+ if (!filenameset && node->get_property (X_("Filename"), filename) &&
+ node->get_property (X_("LocalFile"), local_file) && local_file) {
+ if (filename.at(0) != G_DIR_SEPARATOR)
+ {
+ filename = Glib::build_filename (_session->session_directory().video_path(), filename);
+ }
+ if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS))
+ {
+ invid_path_entry.set_text (filename);
+ filenameset = true;
+ }
+ }
+ }
+ if (!filenameset) {
+ invid_path_entry.set_text (X_(""));
+ }
+
+ node = _session->extra_xml (X_("Videoexport"));
+ if (node) {
+ bool yn;
+ if (node->get_property (X_("ChangeGeometry"), yn)) {
+ scale_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("KeepAspect"), yn)) {
+ scale_aspect.set_active (yn);
+ }
+ if (node->get_property (X_("ChangeAspect"), yn)) {
+ aspect_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("NormalizeAudio"), yn)) {
+ normalize_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("TwoPassEncode"), yn)) {
+ twopass_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("CodecOptimzations"), yn)) {
+ optimizations_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("Deinterlace"), yn)) {
+ deinterlace_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("BSamples"), yn)) {
+ bframes_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("ChangeFPS"), yn)) {
+ fps_checkbox.set_active (yn);
+ }
+ if (node->get_property (X_("Metadata"), yn)) {
+ meta_checkbox.set_active (yn);
+ }
+
+ std::string str;
+ if (node->get_property (X_("Format"), str) && !str.empty()) {
+ change_file_extension ("." + str);
+ }
+
+ _suspend_signals = true;
+ double val;
+ if (node->get_property (X_("Width"), val)) {
+ width_spinner.set_value (val);
+ }
+ if (node->get_property (X_("Height"), val)) {
+ height_spinner.set_value (val);
+ }
+ _suspend_signals = false;
+
+ if (fps_checkbox.get_active () && node->get_property (X_("FPS"), val)) {
+ tcfps = val;
+ }
+
+ if (node->get_property (X_("Preset"), str)) {
+ preset_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("VCodec"), str)) {
+ video_codec_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("ACodec"), str)) {
+ audio_codec_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("VBitrate"), str)) {
+ video_bitrate_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("ABitrate"), str)) {
+ audio_bitrate_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("AspectRatio"), str)) {
+ aspect_combo.set_active_text (str);
+ }
+ if (node->get_property (X_("SampleRate"), str)) {
+ audio_samplerate_combo.set_active_text (str);
+ }
+ }
+
+ if (fabs(tcfps - 23.976) < 0.01) { fps_combo.set_active(0); }
+ else if (fabs(tcfps - 24.0 ) < 0.01) { fps_combo.set_active(1); }
+ else if (fabs(tcfps - 24.976) < 0.01) { fps_combo.set_active(2); }
+ else if (fabs(tcfps - 25.0 ) < 0.01) { fps_combo.set_active(3); }
+ else if (fabs(tcfps - 29.97 ) < 0.01) { fps_combo.set_active(4); }
+ else if (fabs(tcfps - 30.0 ) < 0.01) { fps_combo.set_active(5); }
+ else if (fabs(tcfps - 59.94 ) < 0.01) { fps_combo.set_active(6); }
+ else if (fabs(tcfps - 60.0 ) < 0.01) { fps_combo.set_active(7); }
+ else { fps_combo.set_active(5); }
+
+ set_original_file_information();
+
+ /* update sensitivity */
+ scale_checkbox_toggled();
+ aspect_checkbox_toggled();
+ fps_checkbox_toggled();
+ video_codec_combo_changed();
+
+ _suspend_dirty = false;
+
+ show_all_children ();
+ if (progress_box) {
+ progress_box->hide();
+ }
+}
+
+XMLNode&
+ExportVideoDialog::get_state ()
+{
+ XMLNode* node = new XMLNode (X_("Videoexport"));
+ node->set_property (X_("ChangeGeometry"), scale_checkbox.get_active());
+ node->set_property (X_("KeepAspect"), scale_aspect.get_active());
+ node->set_property (X_("ChangeAspect"), aspect_checkbox.get_active());
+ node->set_property (X_("NormalizeAudio"), normalize_checkbox.get_active());
+ node->set_property (X_("TwoPassEncode"), twopass_checkbox.get_active());
+ node->set_property (X_("CodecOptimzations"), optimizations_checkbox.get_active());
+ node->set_property (X_("Deinterlace"), deinterlace_checkbox.get_active());
+ node->set_property (X_("BSamples"), bframes_checkbox.get_active());
+ node->set_property (X_("ChangeFPS"), fps_checkbox.get_active());
+ node->set_property (X_("Metadata"), meta_checkbox.get_active());
+
+ node->set_property (X_("Format"), get_file_extension(outfn_path_entry.get_text()));
+
+ node->set_property (X_("Width"), width_spinner.get_value());
+ node->set_property (X_("Height"), height_spinner.get_value());
+
+ node->set_property (X_("Preset"), preset_combo.get_active_text());
+ node->set_property (X_("VCodec"), video_codec_combo.get_active_text());
+ node->set_property (X_("ACodec"), audio_codec_combo.get_active_text());
+ node->set_property (X_("VBitrate"), video_bitrate_combo.get_active_text());
+ node->set_property (X_("ABitrate"), audio_bitrate_combo.get_active_text());
+ node->set_property (X_("AspectRatio"), aspect_combo.get_active_text());
+ node->set_property (X_("SampleRate"), audio_samplerate_combo.get_active_text());
+ node->set_property (X_("FPS"), fps_combo.get_active_text());
+
+ return *node;
+}
+
+void
+ExportVideoDialog::set_state (const XMLNode &)
+{