From 77e716943fb8ec086e4b5c158841b6dd49b423f4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 2 Jul 2014 20:26:13 +0200 Subject: [PATCH] round A/V offset to video-frames. --- gtk2_ardour/export_video_dialog.cc | 9 +++------ gtk2_ardour/transcode_ffmpeg.cc | 6 ++++++ gtk2_ardour/transcode_ffmpeg.h | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index e5f1890737..6868b488cd 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -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; diff --git a/gtk2_ardour/transcode_ffmpeg.cc b/gtk2_ardour/transcode_ffmpeg.cc index cee42163f1..736a2a5872 100644 --- a/gtk2_ardour/transcode_ffmpeg.cc +++ b/gtk2_ardour/transcode_ffmpeg.cc @@ -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"); diff --git a/gtk2_ardour/transcode_ffmpeg.h b/gtk2_ardour/transcode_ffmpeg.h index b54d9e54c7..2ee7529dc5 100644 --- a/gtk2_ardour/transcode_ffmpeg.h +++ b/gtk2_ardour/transcode_ffmpeg.h @@ -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; }