From 7910f0e70c3bb2cabd92d1bd76dffc28d51adc6f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 12 Jul 2020 18:03:47 +0200 Subject: [PATCH] mkvextract: USF: format_timestamp expects timestamps in nanoseconds Fixes #2875. --- NEWS.md | 2 ++ src/extract/xtr_textsubs.cpp | 6 +++--- tests/results.txt | 1 + tests/test-700X_usf.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100755 tests/test-700X_usf.rb diff --git a/NEWS.md b/NEWS.md index 785d56fdc..afb3c19da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,8 @@ tree-like structure" mode, the GUI always stopped at the first cluster regardless of the setting of the "verbosity" option. * Windows installer: the images are shown again. Fixes #2868. +* mkvextract: USF subtitles: start & end timestamps were too high by a factor + of 1.000.000. Fixes #2875. # Version 48.0.0 "Sick Of Losing Soulmates" 2020-06-27 diff --git a/src/extract/xtr_textsubs.cpp b/src/extract/xtr_textsubs.cpp index 0f54110ae..df8b177de 100644 --- a/src/extract/xtr_textsubs.cpp +++ b/src/extract/xtr_textsubs.cpp @@ -366,13 +366,13 @@ xtr_usf_c::finish_track() { std::stringstream text_in(text); pugi::xml_document subtitle_doc; if (!subtitle_doc.load(text_in, pugi::parse_default | pugi::parse_declaration | pugi::parse_doctype | pugi::parse_pi | pugi::parse_comments)) { - mxwarn(fmt::format(Y("Track {0}: An USF subtitle entry starting at timestamp {1} is not well-formed XML and will be skipped.\n"), m_tid, mtx::string::format_timestamp(entry.m_start * 1000000, 3))); + mxwarn(fmt::format(Y("Track {0}: An USF subtitle entry starting at timestamp {1} is not well-formed XML and will be skipped.\n"), m_tid, mtx::string::format_timestamp(entry.m_start, 3))); continue; } auto subtitle = subtitles.append_child("subtitle"); - subtitle.append_attribute("start").set_value(mtx::string::format_timestamp(entry.m_start * 1000000, 3).c_str()); - subtitle.append_attribute("stop"). set_value(mtx::string::format_timestamp(entry.m_end * 1000000, 3).c_str()); + subtitle.append_attribute("start").set_value(mtx::string::format_timestamp(entry.m_start, 3).c_str()); + subtitle.append_attribute("stop"). set_value(mtx::string::format_timestamp(entry.m_end, 3).c_str()); for (auto child : subtitle_doc.document_element()) subtitle.append_copy(child); diff --git a/tests/results.txt b/tests/results.txt index 0e0b814c3..274d4a952 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -545,3 +545,4 @@ T_696wavpack5:167606e4e11fef79a9cb859a371d4d8a-009b8b5a53f51ddf0f8fd3be3bf808cb- T_697dts_es_xch:true:passed:20200622-160456:0.0 T_698ac3_dolby_surround_ex:true-true-true:passed:20200622-173931:0.051167592 T_699default_track_forced_off_vs_default_by_type:59aea3a8b7c10b1e64e6e241f2dc979c-true-59aea3a8b7c10b1e64e6e241f2dc979c-true-c4e85aed908bbe688fe6949c442cdbba-true:passed:20200629-201706:0.073934952 +T_700X_usf:c57150efb37908136e2c9a05944bc307-46001697d31d3a435ac65008cd37ea5a:passed:20200712-180338:0.023615368 diff --git a/tests/test-700X_usf.rb b/tests/test-700X_usf.rb new file mode 100755 index 000000000..aa6c42a28 --- /dev/null +++ b/tests/test-700X_usf.rb @@ -0,0 +1,11 @@ +#!/usr/bin/ruby -w + +# T_700X_usf +describe "mkextract / USF subtitles" + +test_merge "data/subtitles/usf/u.usf", :keep_tmp => true + +test "USF extraction" do + extract tmp, 0 => "#{tmp}-1" + hash_file "#{tmp}-1" +end