X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Fexport_video_dialog.cc;h=df05eed8073f1d192a0ad91c279060f550b91a3c;hb=5f9e81b105e84988a92c1f448fa46d9054893b55;hp=f54232a681e12fd7c4efab4aaec805c498afcab6;hpb=bb826f4beebfcedc50570b818c305560d2233e47;p=ardour.git diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index f54232a681..df05eed807 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -28,7 +28,6 @@ #include #include -#include #include @@ -52,7 +51,6 @@ #include "ardour/session_metadata.h" #include "ardour/broadcast_info.h" -#include "utils.h" #include "opts.h" #include "export_video_dialog.h" #include "utils_videotl.h" @@ -64,9 +62,9 @@ using namespace PBD; using namespace ARDOUR; using namespace VideoUtils; -ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) +ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range) : ArdourDialog (_("Export Video File ")) - , editor (ed) + , export_range (tme) , outfn_path_label (_("File:"), Gtk::ALIGN_LEFT) , outfn_browse_button (_("Browse")) , invid_path_label (_("Video:"), Gtk::ALIGN_LEFT) @@ -152,7 +150,14 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) } else { insnd_combo.append_text (_("from the video's start to the video's end")); } - insnd_combo.set_active(0); + if (!export_range.empty()) { + insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_frame() + } + if (range) { + insnd_combo.set_active(2); + } else { + insnd_combo.set_active(0); + } outfn_path_entry.set_width_chars(38); outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi"); @@ -509,6 +514,10 @@ ExportVideoDialog::launch_export () } end += av_offset; } + else if (insnd_combo.get_active_row_number() == 2) { + start = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(export_range.start()); + end = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(export_range.end_frame()); + } if (end <= 0) { start = _session->current_start_frame(); end = _session->current_end_frame(); @@ -517,6 +526,15 @@ ExportVideoDialog::launch_export () printf("audio export-range %lld -> %lld\n", start, end); #endif + const frameoffset_t vstart = ARDOUR_UI::instance()->video_timeline->get_offset(); + const frameoffset_t vend = vstart + ARDOUR_UI::instance()->video_timeline->get_duration(); + + if ( (start >= end) || (end < vstart) || (start > vend)) { + warning << _("Export Video: export-range does not include video.") << endmsg; + Gtk::Dialog::response(RESPONSE_CANCEL); + return; + } + tsp->set_range (start, end); tsp->set_name ("mysession"); tsp->set_range_id ("session"); @@ -542,6 +560,7 @@ ExportVideoDialog::launch_export () insnd = fnp->get_path(fmp); /* do sound export */ + fmp->set_soundcloud_upload(false); _session->get_export_handler()->add_export_config (tsp, ccp, fmp, fnp, b); _session->get_export_handler()->do_export(); status = _session->get_export_status (); @@ -553,7 +572,7 @@ ExportVideoDialog::launch_export () if (gtk_events_pending()) { gtk_main_iteration (); } else { - usleep (10000); + Glib::usleep (10000); } } audio_progress_connection.disconnect(); @@ -593,7 +612,8 @@ ExportVideoDialog::encode_pass (int pass) ffs.clear(); if (fps_checkbox.get_active()) { - ffs["-r"] = fps_combo.get_active_text(); + ffs["-r"] = fps_combo.get_active_text(); + transcoder->set_fps(atof(fps_combo.get_active_text())); } if (scale_checkbox.get_active()) { @@ -681,7 +701,7 @@ ExportVideoDialog::encode_pass (int pass) ffs["-an"] = "-y"; ffs["-passlogfile"] = Glib::path_get_dirname (outfn) + G_DIR_SEPARATOR + "ffmpeg2pass"; ffs["-f"] = get_file_extension(invid).empty()?"mov":get_file_extension(invid); -#ifdef _OS_WIN32 +#ifdef PLATFORM_WINDOWS outfn = "NUL"; #else outfn = "/dev/null"; @@ -696,9 +716,14 @@ ExportVideoDialog::encode_pass (int pass) double duration_s = 0; if (insnd_combo.get_active_row_number() == 0) { + /* session start to session end */ framecnt_t duration_f = _session->current_end_frame() - _session->current_start_frame(); duration_s = (double)duration_f / (double)_session->nominal_frame_rate(); + } else if (insnd_combo.get_active_row_number() == 2) { + /* selected range */ + duration_s = export_range.length() / (double)_session->nominal_frame_rate(); } else { + /* video start to end */ framecnt_t duration_f = ARDOUR_UI::instance()->video_timeline->get_duration(); if (av_offset < 0 ) { duration_f += av_offset; @@ -708,16 +733,18 @@ ExportVideoDialog::encode_pass (int pass) std::ostringstream osstream; osstream << duration_s; ffs["-t"] = osstream.str(); - if (fps_checkbox.get_active()) { - transcoder->set_duration(duration_s * atof(fps_combo.get_active_text())); - } else { - transcoder->set_duration(duration_s * transcoder->get_fps()); - } + transcoder->set_duration(duration_s * transcoder->get_fps()); - if (insnd_combo.get_active_row_number() == 0) { - const framepos_t start = _session->current_start_frame(); - const framepos_t snend = _session->current_end_frame(); + if (insnd_combo.get_active_row_number() == 0 || insnd_combo.get_active_row_number() == 2) { + framepos_t start, snend; const frameoffset_t vid_duration = ARDOUR_UI::instance()->video_timeline->get_duration(); + if (insnd_combo.get_active_row_number() == 0) { + start = _session->current_start_frame(); + snend = _session->current_end_frame(); + } else { + start = export_range.start(); + snend = export_range.end_frame(); + } #if 0 /* DEBUG */ printf("AV offset: %lld Vid-len: %lld Vid-end: %lld || start:%lld || end:%lld\n", @@ -732,9 +759,17 @@ ExportVideoDialog::encode_pass (int pass) } else if (av_offset + vid_duration < snend) { transcoder->set_leadinout(0, (snend - (av_offset + vid_duration)) / (double)_session->nominal_frame_rate()); transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate()); - } else { + } +#if 0 + else if (start > av_offset) { + std::ostringstream osstream; osstream << ((start - av_offset) / (double)_session->nominal_frame_rate()); + ffs["-ss"] = osstream.str(); + } +#endif + else { transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate()); } + } else if (av_offset < 0) { /* from 00:00:00:00 to video-end */ transcoder->set_avoffset(av_offset / (double)_session->nominal_frame_rate());