X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fexport_video_dialog.cc;h=ce85fad81ef5c6129cb861c7bc00092239703740;hb=cb7bcb6d9f3a9f67b23066e3fd0c36db394c00fe;hp=99da86c289483eea3a862d4545b45b4a2ff48844;hpb=7b99abb05d5ce94fff48edf42332d3fc93c43fd0;p=ardour.git diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index 99da86c289..ce85fad81e 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -17,8 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef WITH_VIDEOTIMELINE - #include #include #include @@ -93,7 +91,6 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) set_session (s); set_name ("ExportVideoDialog"); - set_position (Gtk::WIN_POS_MOUSE); set_modal (true); set_skip_taskbar_hint (true); set_resizable (false); @@ -144,13 +141,13 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) vbox->pack_start (*path_hbox, false, false, 2); insnd_combo.set_name ("PaddedButton"); - insnd_combo.append_text("from ardour session-start to session-end"); + insnd_combo.append_text (string_compose (_("from the %1 session's start to the session's end"), PROGRAM_NAME)); frameoffset_t av_offset = ARDOUR_UI::instance()->video_timeline->get_offset(); if (av_offset < 0 ) { - insnd_combo.append_text("from 00:00:00:00 to video-end"); + insnd_combo.append_text (_("from 00:00:00:00 to the video's end")); } else { - insnd_combo.append_text("from video-start to video-end"); + insnd_combo.append_text (_("from the video's start to the video's end")); } insnd_combo.set_active(0); @@ -158,12 +155,29 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi"); XMLNode* node = _session->extra_xml (X_("Videotimeline")); - if (node && node->property(X_("Filename"))) { - std::string filename = node->property(X_("Filename"))->value(); - if (filename.at(0) != G_DIR_SEPARATOR) { - filename = Glib::build_filename (_session->session_directory().video_path(), filename); + if (node) { + bool filenameset = false; + if (node->property(X_("OriginalVideoFile"))) { + std::string filename = node->property(X_("OriginalVideoFile"))->value(); + if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { + invid_path_entry.set_text (filename); + filenameset = true; + } + } + else if (!filenameset + && node->property(X_("Filename")) + && node->property(X_("LocalFile")) + && node->property(X_("LocalFile"))->value() == X_("1") + ) { + std::string filename = node->property(X_("Filename"))->value(); + 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; + } } - invid_path_entry.set_text (filename); } l = manage (new Label (_("Settings:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false)); @@ -350,9 +364,41 @@ ExportVideoDialog::update_progress (framecnt_t c, framecnt_t a) if (a == 0 || c > a) { pbar.set_pulse_step(.1); pbar.pulse(); - return; + } else { + double progress = (double)c / (double) a; + progress = progress / ((twopass ? 2.0 : 1.0) + (normalize ? 2.0 : 1.0)); + if (normalize && twopass) progress += (firstpass ? .5 : .75); + else if (normalize) progress += 2.0/3.0; + else if (twopass) progress += (firstpass ? 1.0/3.0 : 2.0/3.0); + else progress += .5; + + pbar.set_fraction (progress); } - pbar.set_fraction ((double)c / (double) a); +} + + +gint +ExportVideoDialog::audio_progress_display () +{ + std::string status_text; + double progress = 0.0; + if (status->normalizing) { + pbar.set_text (_("Normalizing audio")); + progress = ((float) status->current_normalize_cycle) / status->total_normalize_cycles; + progress = progress / (twopass ? 4.0 : 3.0) + (twopass ? .25 : 1.0/3.0); + } else { + pbar.set_text (_("Exporting audio")); + progress = ((float) status->processed_frames_current_timespan) / status->total_frames_current_timespan; + progress = progress / ((twopass ? 2.0 : 1.0) + (normalize ? 2.0 : 1.0)); + } + if (progress < previous_progress) { + // Work around gtk bug + pbar.hide(); + pbar.show(); + } + previous_progress = progress; + pbar.set_fraction (progress); + return TRUE; } void @@ -361,10 +407,9 @@ ExportVideoDialog::finished () if (aborted) { unlink(outfn_path_entry.get_text().c_str()); unlink (insnd.c_str()); - warning << _("Video Export Failed or Was Aborted") << endmsg; Gtk::Dialog::response(RESPONSE_CANCEL); - } else if (twopass) { - twopass = false; + } else if (twopass && firstpass) { + firstpass = false; if (transcoder) { delete transcoder; transcoder = 0;} encode_pass(2); } else { @@ -388,10 +433,12 @@ ExportVideoDialog::launch_export () cancel_button->hide(); transcode_button.hide(); pbar.set_size_request(300,-1); - pbar.set_text(_("Exporting Audio..")); + pbar.set_text(_("Exporting Audio...")); progress_box->show(); aborted = false; twopass = twopass_checkbox.get_active(); + firstpass = true; + normalize = normalize_checkbox.get_active(); /* export audio track */ ExportTimespanPtr tsp = _session->get_export_handler()->add_timespan(); @@ -400,7 +447,7 @@ ExportVideoDialog::launch_export () boost::shared_ptr b; XMLTree tree; std::string vtl_samplerate = audio_samplerate_combo.get_active_text(); - std::string vtl_normalize = normalize_checkbox.get_active()?"true":"false"; + std::string vtl_normalize = normalize ? "true" : "false"; tree.read_buffer(std::string( "" "" @@ -492,41 +539,26 @@ ExportVideoDialog::launch_export () /* do sound export */ _session->get_export_handler()->add_export_config (tsp, ccp, fmp, fnp, b); _session->get_export_handler()->do_export(); - boost::shared_ptr status = _session->get_export_status (); - //status->running = true; + status = _session->get_export_status (); - float previous_progress = 0.0; + audio_progress_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ExportVideoDialog::audio_progress_display), 100); + previous_progress = 0.0; while (status->running) { if (aborted) { status->abort(); } - - float progress = 0.0; - if (status->normalizing) { - pbar.set_text (_("Normalizing audio")); - progress = ((float) status->current_normalize_cycle) / status->total_normalize_cycles; - } else { - pbar.set_text (_("Exporting audio")); - progress = ((float) status->processed_frames_current_timespan) / status->total_frames_current_timespan; - } - if (progress < previous_progress) { - // Work around gtk bug - pbar.hide(); - pbar.show(); - } - previous_progress = progress; - pbar.set_fraction (progress); if (gtk_events_pending()) { gtk_main_iteration (); } else { usleep (10000); } } + audio_progress_connection.disconnect(); status->finish (); if (status->aborted()) { unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); return; } - pbar.set_text (_("Encoding Video..")); + pbar.set_text (_("Encoding Video...")); encode_pass(1); } @@ -566,7 +598,7 @@ ExportVideoDialog::encode_pass (int pass) ffs["-acodec"] = audio_codec_combo.get_active_text(); if (video_bitrate_combo.get_active_text() == "retain" ) { - ffs["-sameq"] = "-y"; // we use '-y' as dummy parameter for non key/value options + ffs["-qscale"] = "0"; } else { ffs["-b:v"] = video_bitrate_combo.get_active_text(); } @@ -948,5 +980,3 @@ ExportVideoDialog::open_invid_dialog () } } } - -#endif /* WITH_VIDEOTIMELINE */