Skip to content

xml: resolve relative root against document#1232

Closed
Komzpa wants to merge 1 commit into
mltframework:masterfrom
Komzpa:fixer-xml-relative-root
Closed

xml: resolve relative root against document#1232
Komzpa wants to merge 1 commit into
mltframework:masterfrom
Komzpa:fixer-xml-relative-root

Conversation

@Komzpa
Copy link
Copy Markdown
Contributor

@Komzpa Komzpa commented May 1, 2026

Summary

Resolve a relative <mlt root="..."> against the directory of the XML document being parsed, instead of leaving it relative to the process current working directory.

This matters for portable MLT/Kdenlive projects opened from a GUI or another caller whose cwd is unrelated to the project file. For example, if /tmp/project/output/repro.kdenlive contains root="." and a media resource ../media.mp4, the resource should resolve under /tmp/project/output, not under the caller's cwd.

The patch also reuses the same absolute-path helper for normal resource qualification and adds an avformat XML regression test using avformat-novalidate.

Reproducer

I reproduced this with a Kdenlive/MLT project shaped like this:

  • XML file: /tmp/mlt-root-repro/output/repro.kdenlive
  • XML root: <mlt root=".">
  • media resources: ../DJI_0884.MP4, 3.400000:../DJI_0884.MP4, and ../assets/audio/...
  • command launched from /tmp, deliberately not from the project directory

Current packaged MLT 7.38.0 resolves the paths against cwd and logs failures like:

[producer_xml] failed to load producer "./../DJI_0884.MP4"
[producer_xml] failed to load producer "3.400000:./../DJI_0884.MP4"

In that repro I got 28 failed to load producer lines.

With this patch and the same system modules:

MLT_REPOSITORY=/tmp/mlt-root-repro/modules \
MLT_DATA=/usr/share/mlt-7 \
build/out/bin/melt /tmp/mlt-root-repro/output/repro.kdenlive \
  -consumer xml:/tmp/mlt-root-repro/new.xml

The command exits 0 and the same grep finds 0 failed to load producer lines. The resolved resources go through paths such as /tmp/mlt-root-repro/output/./../DJI_0884.MP4, which is the document-relative location.

Validation

  • clang-format -i src/modules/xml/producer_xml.c src/tests/test_mod_avformat/test_mod_avformat.cpp
  • cmake --build build -j$(nproc)
  • git diff --check
  • Manual repro above: old packaged MLT fails to load the document-relative media; patched libmltxml.so resolves it correctly.

I could not run the new test_mod_avformat test locally because this machine lacks the FFmpeg development packages needed to configure MOD_AVFORMAT=ON in a fresh test build. The runtime repro used the patched XML module together with the system avformat module.

@ddennedy
Copy link
Copy Markdown
Member

ddennedy commented May 1, 2026

root is not supposed to be a relative path. The docs state that property is used to resolve relative paths within the document if not relative to the document location. Now, you are making it relative to relative, and that is not useful. Maybe you should fix the document generation.

@ddennedy
Copy link
Copy Markdown
Member

ddennedy commented May 1, 2026

In other words, it already works relative to the document without a root. Does kdenlive require root? Because melt and Shotcut do not.

@j-b-m
Copy link
Copy Markdown
Contributor

j-b-m commented May 2, 2026

Kdenlive will only write absolute path to the xml root property, or omit it when archiving a project, but I don't think there is a way to create a relative path.

@ddennedy
Copy link
Copy Markdown
Member

ddennedy commented May 2, 2026

Rejected

@ddennedy ddennedy closed this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants