mkvtoolnix/tests/test-721mutli_chapter_language.rb
Moritz Bunkus b26c23c61e
mkmverge, mkvpropedit: only remove default-value mandatory elements if not multi
There are elements in Matroska that are mandatory, have a default
value and may occur multiple times within the same master, mainly the
"chapter language" element. The semantics in such a case are that the
default value must only be used if NO OTHER element of the same type
is present within the same master element.

If a "chapter display" contains, let's say, a string for the languages
German & English, two "chapter language" elements must be
used. Checking with the specs reveals that English is the default
value for "chapter languages". Therefore one might think we can omit
writing the instance for "chapter language" with value "English". But
that would leave one "chapter language" element present with "German"
as the value, and semantically that would be the value a reader must
use.

This patch changes how default elements are removed before writing a
master element. It now iterates over all elements keeping track of how
many elements of each type there are within the same master. Mandatory
elements set to their default value will now only then be removed if
there is only that one instance of the mandatory element.

Part of the fix of #3120.
2021-05-27 19:26:28 +02:00

16 lines
414 B
Ruby
Executable File

#!/usr/bin/ruby -w
# T_721mutli_chapter_language
src = "data/subtitles/srt/ven.srt"
chapters = "data/chapters/multi-language-in-display.xml"
describe "mkvmerge & mkvpropedit / chapter display with multiple chapter language, one of them 'eng'"
test_merge src, :args => "--chapters #{chapters}"
test_merge src, :keep_tmp => true
test "mkvpropedit" do
propedit tmp, "--chapters #{chapters}"
hash_tmp
end