round A/V offset to video-frames.
authorRobin Gareus <robin@gareus.org>
Wed, 2 Jul 2014 18:26:13 +0000 (20:26 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 2 Jul 2014 21:36:06 +0000 (23:36 +0200)
gtk2_ardour/export_video_dialog.cc
gtk2_ardour/transcode_ffmpeg.cc
gtk2_ardour/transcode_ffmpeg.h

index e5f189073724075d3044b5d46fcfe784692f2886..6868b488cd059c46042f5cdfd6d8831f266aae3a 100644 (file)
@@ -611,7 +611,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()) {
@@ -731,11 +732,7 @@ 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 || insnd_combo.get_active_row_number() == 2) {
                framepos_t start, snend;
index cee42163f117c5fd100e1fbfbaffd6e7171a02a7..736a2a5872c8e8fa26d3b4b5bcd6f10b610fbf8e 100644 (file)
@@ -348,6 +348,12 @@ TranscodeFfmpeg::encode (std::string outfile, std::string inf_a, std::string inf
                argp[a++] = strdup("-metadata");
                argp[a++] = format_metadata(it->first.c_str(), it->second.c_str());
        }
+
+       if (m_fps > 0) {
+               m_lead_in  = rint (m_lead_in * m_fps) / m_fps;
+               m_lead_out = rint (m_lead_out * m_fps) / m_fps;
+       }
+
        if (m_lead_in != 0 && m_lead_out != 0) {
                std::ostringstream osstream;
                argp[a++] = strdup("-vf");
index b54d9e54c79fd961fd23ac31d831908b05f2de3e..2ee7529dc51e83507fcb9ee11d2dc05326e43ef7 100644 (file)
@@ -122,6 +122,7 @@ class TranscodeFfmpeg : public sigc::trackable
                void set_avoffset(double av_offset) { m_avoffset = av_offset; }
                void set_leadinout(double lead_in, double lead_out) { m_lead_in = lead_in; m_lead_out = lead_out; }
 
+               void set_fps(double fps) { m_fps = fps; } // on export, used for rounding only.
 
 #if 1 /* tentative debug mode */
                void   set_debug (bool onoff) { debug_enable = onoff; }