X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fexport_video_dialog.cc;h=2f9df2fb1c6033fe74a04b7b997a2b1db3ea81c8;hb=c2b2953f8c051743729bfa3328336abf19a25587;hp=b8f94ac55c277193a489962c50f198a75077ca66;hpb=616f2a0370a10dcc7372a95f6bca9f5a45698980;p=ardour.git diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index b8f94ac55c..2f9df2fb1c 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -28,7 +28,6 @@ #include #include -#include #include "pbd/error.h" #include "pbd/convert.h" @@ -62,9 +61,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) @@ -104,7 +103,7 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) /* check if ffmpeg can be found */ transcoder = new TranscodeFfmpeg(""); if (!transcoder->ffexec_ok()) { - l = manage (new Label (_("No ffprobe or ffmpeg executables could be found on this system. Video Export is not possible until you install those tools. See the Log widow for more information."), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false)); + l = manage (new Label (_("No ffprobe or ffmpeg executables could be found on this system. Video Export is not possible until you install those tools. See the Log window for more information."), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false)); l->set_line_wrap(); vbox->pack_start (*l, false, false, 8); get_vbox()->pack_start (*vbox, false, false); @@ -150,7 +149,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"); @@ -165,7 +171,7 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) filenameset = true; } } - else if (!filenameset + if (!filenameset && node->property(X_("Filename")) && node->property(X_("LocalFile")) && node->property(X_("LocalFile"))->value() == X_("1") @@ -179,6 +185,9 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) filenameset = true; } } + if (!filenameset) { + invid_path_entry.set_text (X_("")); + } } l = manage (new Label (_("Settings:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false)); @@ -254,8 +263,7 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) video_codec_combo.append_text("mjpeg"); video_codec_combo.append_text("mpeg2video"); video_codec_combo.append_text("mpeg4"); - video_codec_combo.append_text("x264 (baseline)"); - video_codec_combo.append_text("x264 (hq)"); + video_codec_combo.append_text("h264"); video_codec_combo.append_text("vpx (webm)"); video_codec_combo.append_text("copy"); video_codec_combo.set_active(4); @@ -505,6 +513,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(); @@ -513,6 +525,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"); @@ -609,13 +630,8 @@ ExportVideoDialog::encode_pass (int pass) ffs["-strict"] = "-2"; } - if (video_codec_combo.get_active_text() == "x264 (hq)" ) { + if (video_codec_combo.get_active_text() == "h264" ) { ffs["-vcodec"] = "libx264"; - ffs["-vprofile"] = "high"; - } - else if (video_codec_combo.get_active_text() == "x264 (baseline)" ) { - ffs["-vcodec"] = "libx264"; - ffs["-vpre"] = "baseline"; } else if (video_codec_combo.get_active_text() == "vpx (webm)" ) { ffs["-vcodec"] = "libvpx"; @@ -697,9 +713,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; @@ -715,10 +736,16 @@ ExportVideoDialog::encode_pass (int pass) 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", @@ -733,9 +760,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());