+ if (!audio_from_video.empty() && detect_ltc) {
+ std::vector<LTCFileReader::LTCMap> ltc_seq;
+
+ try {
+ /* TODO ask user about TV standard (LTC alignment if any) */
+ LTCFileReader ltcr (audio_from_video, video_timeline->get_video_file_fps());
+ /* TODO ASK user which channel: 0 .. ltcr->channels() - 1 */
+
+ ltc_seq = ltcr.read_ltc (/*channel*/ 0, /*max LTC frames to decode*/ 15);
+
+ /* TODO seek near end of file, and read LTC until end.
+ * if it fails to find any LTC frames, scan complete file
+ *
+ * calculate drift of LTC compared to video-duration,
+ * ask user for reference (timecode from start/mid/end)
+ */
+ } catch (...) {
+ // LTCFileReader will have written error messages
+ }
+
+ ::g_unlink(audio_from_video.c_str());
+
+ if (ltc_seq.size() == 0) {
+ PBD::error << _("No LTC detected, video will not be aligned.") << endmsg;
+ } else {
+ /* the very first TC in the file is somteimes not aligned properly */
+ int i = ltc_seq.size() -1;
+ ARDOUR::frameoffset_t video_start_offset =
+ _session->nominal_frame_rate() * (ltc_seq[i].timecode_sec - ltc_seq[i].framepos_sec);
+ PBD::info << string_compose (_("Align video-start to %1 [samples]"), video_start_offset) << endmsg;
+ video_timeline->set_offset(video_start_offset);
+ }
+ }
+