Skip to content

Add 3D test videos with a test that runs FFmpeg and MediaInfo on them, and fix what they found - #6400

Merged
SubJunk merged 4 commits into
UniversalMediaServer:mainfrom
Sparky-OS:stereo3d-test-files
Oct 16, 2026
Merged

SubJunk merged 4 commits into
UniversalMediaServer:mainfrom
Sparky-OS:stereo3d-test-files

Conversation

@danielcamposramos

Copy link
Copy Markdown
Contributor

Thank you again for merging #6389, @SubJunk, and for the idea of checking it with real files.

This adds 18 small 3D videos to src/test/resources/net/pms/parsers and tests that run FFmpeg and MediaInfo on them.
On their first run they found three gaps in the check of #6389, and the first three commits fix them.

The videos, 112,136 bytes in all (2,966 to 30,029 bytes each):

  • The frame packing arrangement SEI (H.264 D.2.26, H.265 D.3.16) with no container tag: side by side and top and bottom, left and right eye first, in H.264 and H.265, at half size (1280x720) and full size (2560x720 and 1280x1440), in MP4 and MPEG-TS.
  • The other arrangements of H.264 Table D-8 that x264 writes: checkerboard, column interleaving, row interleaving, temporal interleaving and 2D, plus the temporal interleaving of H.265 Table D.8.
    UMS has no 3D mode for these, so they must stay 2D.
    x264 also writes the tile format (type 7), but FFmpeg does not read it, so it is left out.
  • Matroska StereoMode (RFC 9559) with no SEI: the values 1, 2, 3 and 11, which are side by side and top and bottom in both eye orders.

They are made with FFmpeg from lavfi colour sources, one colour per eye with LEFT or RIGHT written on it, five frames at 25 fps (eight at 50 fps, one eye per frame, for temporal interleaving), so there is no third party content in them.
The names keep clear of the file name detection (no SBS, OU or TB between dots or spaces), so a layout can only come from the stream or the container.
Eleven of them can be made with stock FFmpeg: I made them again with the n8.1.3 build that the testing profile downloads, and they give the same layouts.
The other seven carry a right eye first SEI or an H.265 SEI, which x264 and x265 cannot write, so they were made with the frame_packing option of h264_metadata and hevc_metadata from our FFmpeg patch series.
All 18 were made with FFmpeg 9.0.2 and that series.
Run again, the script gives the same bytes for the MP4 and MPEG-TS videos and the same video packets for the Matroska ones.

The tests:

  • FramePackingParserTest.testFiles parses each video with MediaInfoParser.parse, the way UMS does, and checks getMultiViewLayout() and get3DLayout().
    MediaInfo answers for the Matroska videos and FFmpeg's showinfo for the SEI ones.
    Without FFmpeg it is skipped, like FFmpegParserTest.
  • FramePackingFilterTest.copyKeepsTheLayoutOfTheContainer copies the four Matroska videos to MPEG-TS with the -bsf:v value that FFMpegVideo adds on a copy, and checks that UMS finds the layout in the copy, which only has the SEI.
    It runs when FFmpeg has the frame_packing option, so for now it returns early in CI.
    Once the option is in FFmpeg, a change to its names fails this test before it breaks a copy.
  • FramePackingParserTest.olderFFmpegOutput checks the Stereo 3D lines of FFmpeg before 7.1, taken from real runs.

What the videos found:

  1. The Linux jobs of CI have no FFmpeg on the PATH, and then UmsConfiguration.getFFmpegPath() is null.
    When the configuration loads, the default type of the FFmpeg program info goes back to installed, and only the bundled one has a path.
    So the check of Write the frame packing SEI on every path that outputs 3D video, and find it in files that only signal 3D in the stream #6389 never ran on Linux with the bundled FFmpeg, and FFmpegVideoTest works around the same null with a fixed runner path.
    FramePackingParser now asks the FFmpeg engine for its executable, as FFmpegParser does.
  2. showinfo prints the Stereo 3D side data in three ways: stereoscopic information: type - side by side (inverted) up to FFmpeg 5.1, Stereo 3D: type - side by side (inverted) from 6.0 to 7.0, and Stereo 3D: type - side by side (inverted), view - packed, primary_eye - none since 7.1.
    The check read only the last one, so with the FFmpeg of Ubuntu 22.04 (4.4), Debian 12 (5.1) or Ubuntu 24.04 (6.1) on the PATH nothing was found.
    It reads all three now.
  3. A right eye first video up to 1920 pixels wide, or up to 1080 high, is "half side by side (right eye first)" or "half top-bottom (right eye first)", and get3DLayout() had no mode for them, so multiViewIsAnaglyph() took them for anaglyph.
    They map to SBS2R and AB2R now, and get 3D subtitles like their left eye first twins.

How it was checked, in containers with the sources at the runner's path:

  • The whole suite on Ubuntu 24.04 with JDK 17, MediaInfo 26.05 and the bundled FFmpeg n8.1.3, like the Linux 24.04 job: 523 tests, 0 failures, 0 errors, 8 skipped (the macOS ones).
  • FramePackingParserTest and FramePackingFilterTest pass with FFmpeg 4.4.2 (Ubuntu 22.04), 6.1.1 (Ubuntu 24.04), the bundled n8.1.3 on Ubuntu 22.04 and 24.04, and 9.0.2 with the frame_packing patches on Debian, where the copy test runs too.
  • The new test fails on main as merged.
    With the bundled FFmpeg it stops at the first SEI video, which has no layout.
    With FFmpeg 9.0.2 on the PATH it stops at the first half right eye first video, which has its layout but no 3D mode.
    With the first two commits and FFmpeg 6.1 on the PATH it stops at the first SEI video again.
  • Planted faults fail it too.
    With type: in place of type - in the pattern, as if FFmpeg changed its output, testFiles stops at the first SEI video.
    With the eyes swapped for SBSL in getFramePackingFilterOptions, the copy test with FFmpeg 9.0.2 gets "half side by side (right eye first)" for the left eye first video.
  • FFmpegParserTest fails with FFmpeg 4.4 and 6.1 on main too (the format profile of the FLV video), which is not about 3D.
The script that made the videos
#!/bin/sh
# Makes the 3D test videos of src/test/resources/net/pms/parsers.
# Each eye is a plain colour with its name written on it, five frames at 25 fps.
# usage: gen.sh <ffmpeg> <output folder>
set -eu
FFMPEG=$1
OUT=$2
FONT=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf
mkdir -p "$OUT"

# eyes <eye width> <eye height>: the filter graph of the [l] and [r] pictures
eyes() {
	size=$(( $1 / 4 < $2 / 3 ? $1 / 4 : $2 / 3 ))
	echo "color=c=0x1f4e79:s=$1x$2:r=25:d=0.2,drawtext=fontfile=$FONT:text=LEFT:fontsize=$size:fontcolor=white:x=(w-tw)/2:y=(h-th)/2[l];color=c=0x7a1f1f:s=$1x$2:r=25:d=0.2,drawtext=fontfile=$FONT:text=RIGHT:fontsize=$size:fontcolor=white:x=(w-tw)/2:y=(h-th)/2[r]"
}

h264() {
	graph=$1
	shift
	"$FFMPEG" -hide_banner -loglevel error -y -filter_complex "$graph" -c:v libx264 -preset veryslow -crf 32 -pix_fmt yuv420p -threads 1 "$@"
}

h265() {
	graph=$1
	shift
	"$FFMPEG" -hide_banner -loglevel error -y -filter_complex "$graph" -c:v libx265 -preset veryslow -crf 32 -pix_fmt yuv420p -x265-params info=0:log-level=error:pools=1:frame-threads=1 "$@"
}

# The frame packing arrangement SEI, ITU-T H.264 D.2.26 and Table D-8.
# x264 writes it, left eye first only (stock FFmpeg).
h264 "$(eyes 1280 720);[l][r]hstack" -x264-params frame-packing=3 "$OUT/video-h264_frame_packing_side_by_side_left_first.mp4"
h264 "$(eyes 1280 360);[l][r]vstack" -x264-params frame-packing=4 "$OUT/video-h264_frame_packing_top_bottom_left_first.mp4"
h264 "$(eyes 640 720);[l][r]hstack,stereo3d=sbsl:chl" -x264-params frame-packing=0 "$OUT/video-h264_frame_packing_checkerboard.mp4"
h264 "$(eyes 640 720);[l][r]hstack,stereo3d=sbsl:icl" -x264-params frame-packing=1 "$OUT/video-h264_frame_packing_column_interleaving.mp4"
h264 "$(eyes 1280 360);[l][r]hstack,stereo3d=sbsl:irl" -x264-params frame-packing=2 "$OUT/video-h264_frame_packing_row_interleaving.mp4"
h264 "$(eyes 1280 720);[l][r]hstack,stereo3d=sbsl:al" -x264-params frame-packing=5 "$OUT/video-h264_frame_packing_temporal_interleaving.mp4"
h264 "$(eyes 1280 720);[r]nullsink;[l]null" -x264-params frame-packing=6 "$OUT/video-h264_frame_packing_2d.mp4"

# Right eye first (content_interpretation_type 2) and H.265 (D.3.16 and Table D.8):
# written by h264_metadata and hevc_metadata with the frame_packing option (FFmpeg patch series).
h264 "$(eyes 640 720);[r][l]hstack" -bsf:v h264_metadata=frame_packing=insert:frame_packing_type=side_by_side:frame_packing_view=right_first "$OUT/video-h264_frame_packing_side_by_side_right_first.ts"
h264 "$(eyes 1280 720);[r][l]vstack" -bsf:v h264_metadata=frame_packing=insert:frame_packing_type=top_bottom:frame_packing_view=right_first "$OUT/video-h264_frame_packing_top_bottom_right_first.mp4"
h265 "$(eyes 640 720);[l][r]hstack" -bsf:v hevc_metadata=frame_packing=insert:frame_packing_type=side_by_side:frame_packing_view=left_first "$OUT/video-h265_frame_packing_side_by_side_left_first.ts"
h265 "$(eyes 1280 720);[r][l]hstack" -bsf:v hevc_metadata=frame_packing=insert:frame_packing_type=side_by_side:frame_packing_view=right_first "$OUT/video-h265_frame_packing_side_by_side_right_first.mp4"
h265 "$(eyes 1280 720);[l][r]vstack" -bsf:v hevc_metadata=frame_packing=insert:frame_packing_type=top_bottom:frame_packing_view=left_first "$OUT/video-h265_frame_packing_top_bottom_left_first.mp4"
h265 "$(eyes 1280 360);[r][l]vstack" -bsf:v hevc_metadata=frame_packing=insert:frame_packing_type=top_bottom:frame_packing_view=right_first "$OUT/video-h265_frame_packing_top_bottom_right_first.ts"
h265 "$(eyes 1280 720);[l][r]hstack,stereo3d=sbsl:al" -bsf:v hevc_metadata=frame_packing=insert:frame_packing_type=temporal:frame_packing_view=left_first "$OUT/video-h265_frame_packing_temporal_interleaving.mp4"

# Matroska StereoMode (RFC 9559), no SEI
h264 "$(eyes 640 720);[l][r]hstack" -metadata:s:v:0 stereo_mode=left_right "$OUT/video-h264_stereomode_side_by_side_left_first.mkv"
h264 "$(eyes 1280 360);[r][l]vstack" -metadata:s:v:0 stereo_mode=bottom_top "$OUT/video-h264_stereomode_top_bottom_right_first.mkv"
h265 "$(eyes 1280 720);[l][r]vstack" -metadata:s:v:0 stereo_mode=top_bottom "$OUT/video-h265_stereomode_top_bottom_left_first.mkv"
h265 "$(eyes 1280 720);[r][l]hstack" -metadata:s:v:0 stereo_mode=right_left "$OUT/video-h265_stereomode_side_by_side_right_first.mkv"

This text and the code were written with Claude (Anthropic) and checked by running them. I reviewed and submit it.

The frame packing check of UniversalMediaServer#6389 names a right eye first video up to 1920 pixels wide "half side by side (right eye first)" and one up to 1080 pixels high "half top-bottom (right eye first)", but get3DLayout() had no mode for them and multiViewIsAnaglyph() took them for anaglyph. Such a video was not converted and not signalled, and for an H.265 video with Output3DFormat set, StoreItem called toString() on the missing mode.

Map them to SBS2R and AB2R, like their left eye first twins, and draw 3D subtitles for them too.

Assisted-by: Claude Opus 5.5 via Claude Code
FramePackingParser asked UmsConfiguration.getFFmpegPath() for FFmpeg, which is null on Linux when there is no FFmpeg on the PATH and UMS uses the one it bundles: the default type of that program info goes back to the installed one, which has no path. So the check of UniversalMediaServer#6389 never ran there, and it did not follow the FFmpeg the user picked either.

Ask the FFmpeg engine for its executable, as FFmpegParser does, and as FFMpegVideo already does when it writes the SEI.

Assisted-by: Claude Opus 5.5 via Claude Code
showinfo prints the Stereo 3D side data three ways: "stereoscopic information: type - side by side (inverted)" up to FFmpeg 5.1, "Stereo 3D: type - side by side (inverted)" in 6.0 to 7.0, and "Stereo 3D: type - side by side (inverted), view - packed, primary_eye - none" since 7.1. The check of UniversalMediaServer#6389 read only the last, so with the FFmpeg of Ubuntu 22.04 (4.4) and 24.04 (6.1) or Debian 12 (5.1), which UMS runs on Linux when it is on the PATH, no file was found to be 3D.

Read all three. The view is still checked when FFmpeg prints it.

Assisted-by: Claude Opus 5.5 via Claude Code
…ir layout

Eighteen small videos made with FFmpeg from lavfi colour sources, LEFT and RIGHT written on each eye, five frames at 25 fps (eight at 50 fps, one eye per frame, for temporal interleaving), 112 KB in all.

The frame packing arrangement SEI (H.264 D.2.26, H.265 D.3.16): side by side and top and bottom, left and right eye first, half and full size, in H.264 and H.265, in MP4 and MPEG-TS. The other arrangements of H.264 Table D-8 that x264 writes (checkerboard, column and row interleaving, temporal interleaving, 2D) and the temporal interleaving of H.265 Table D.8, which have no 3D mode in UMS and must stay 2D. And Matroska's StereoMode without the SEI, side by side and top and bottom, both eye orders.

FramePackingParserTest parses them like any file, so MediaInfo reads StereoMode and FFmpeg's showinfo the SEI, and checks the layout and the 3D mode. FramePackingFilterTest copies the Matroska videos to MPEG-TS with the bitstream filter UMS adds, and checks that the copy is found to be 3D from the SEI alone; it runs when FFmpeg has the frame_packing option.

Assisted-by: Claude Opus 5.5 via Claude Code
@SubJunk

SubJunk commented Oct 16, 2026

Copy link
Copy Markdown
Member

Cool, nice one!

@SubJunk
SubJunk merged commit d45e8db into UniversalMediaServer:main Oct 16, 2026
9 checks passed
@danielcamposramos

Copy link
Copy Markdown
Contributor Author

Thank you for merging, SubJunk.

One offer, with no strings attached.
Sparky Stereo OS packages UMS for Debian: 15.9.0 with the 3D work from #6389, plus a small System Settings page for Plasma.
We would like to give that packaging a repository of its own under Sparky-OS on GitHub, with you as an admin, the same way Jeromy Streets now maintains the video wallpaper we ship.
You would decide what goes in and when.
If you prefer to keep packaging off your plate, we keep it and send every fix we find here as a pull request, as we did with #6400.
Either way works for us.

@SubJunk

SubJunk commented Oct 17, 2026

Copy link
Copy Markdown
Member

@danielcamposramos thanks for your offer. I have too much to do already so I won't take on more, and I really appreciate your contributions and collaboration :)

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.

2 participants