vtl: export selected range
authorRobin Gareus <robin@gareus.org>
Thu, 12 Sep 2013 20:46:11 +0000 (22:46 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 12 Sep 2013 20:46:11 +0000 (22:46 +0200)
gtk2_ardour/editor_videotimeline.cc
gtk2_ardour/export_video_dialog.cc
gtk2_ardour/export_video_dialog.h

index 0a516fb748e08a7cd4fe3adf951f08321c5d0e01..6f3317eabd7c09ddd507eb2456e5b376f7bffbc5 100644 (file)
@@ -138,7 +138,7 @@ Editor::export_video ()
                                break;
                }
        }
-       ExportVideoDialog dialog (*this, _session);
+       ExportVideoDialog dialog (_session, get_selection().time);
        Gtk::ResponseType r = (Gtk::ResponseType) dialog.run();
        dialog.hide();
 #if 0
index c7ef6efd9ae344b972e12ba5a0f212591a7dc432..b1b59fa0888399fe0e26de8a0c1b37fe8eb41336 100644 (file)
@@ -62,9 +62,9 @@ using namespace PBD;
 using namespace ARDOUR;
 using namespace VideoUtils;
 
-ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
+ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme)
        : 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)
@@ -150,6 +150,9 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
        } else {
                insnd_combo.append_text (_("from the video's start to the video's end"));
        }
+       if (!export_range.empty()) {
+               insnd_combo.append_text (_("Selected range"));  // TODO show export_range.start() -> export_range.end_frame()
+       }
        insnd_combo.set_active(0);
 
        outfn_path_entry.set_width_chars(38);
@@ -507,6 +510,11 @@ ExportVideoDialog::launch_export ()
                }
                end += av_offset;
        }
+       else if (insnd_combo.get_active_row_number() == 2) {
+               // TODO quantize to video-frame ?!
+               start = export_range.start();
+               end   = export_range.end_frame();
+       }
        if (end <= 0) {
                start = _session->current_start_frame();
                end   = _session->current_end_frame();
@@ -694,9 +702,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;
@@ -712,10 +725,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",
@@ -730,9 +749,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());
index 2594c2073b530cea268f27ea6d6384f49d62c6cd..7e3cf442a777b8c823a49453cb9571cb45475e15 100644 (file)
@@ -28,6 +28,7 @@
 #include "ardour/template_utils.h"
 #include "ardour_dialog.h"
 
+#include "time_selection.h"
 #include "transcode_ffmpeg.h"
 
 /** @class ExportVideoDialog
 class ExportVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
 {
   public:
-       ExportVideoDialog (PublicEditor&, ARDOUR::Session*);
+       ExportVideoDialog (ARDOUR::Session*, TimeSelection &tme);
        ~ExportVideoDialog ();
 
        std::string get_exported_filename () { return outfn_path_entry.get_text(); }
 
   private:
-       PublicEditor& editor;
+       TimeSelection &export_range;
 
        void on_show ();
        void abort_clicked ();