Fix mediainfo failing on non-ascii filenames (empty child env + missing locale)#554
Open
ranke96 wants to merge 1 commit into
Open
Fix mediainfo failing on non-ascii filenames (empty child env + missing locale)#554ranke96 wants to merge 1 commit into
ranke96 wants to merge 1 commit into
Conversation
…ng locale) exec()/startJob() replaced the child process environment entirely, so mediainfo ran with no PATH and no locale. Under the C/POSIX locale mediainfo exits 1 on any filename containing non-ascii characters, which left duration permanently "Unknown" and caused every channel list request to retry mediainfo for each affected VOD. - Execute.ts: spawn with the parent env, overlaying any custom vars - Dockerfile: set LANG/LC_ALL=C.UTF-8 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested on master (1cd7e8f, server 1.7.5.1 / client 2.4.3), official Docker image on x86_64. My archive has hundreds of VODs with mostly Chinese filenames, which is how this surfaced.
Root cause (three things combine)
C/POSIX locale.Clocale — it exits with code 1. WithLANG=C.UTF-8it works fine. Reproducible inside the image:exec()inserver/src/Helpers/Execute.tsspawned withenv: env, and callers pass{}— the child got a completely empty environment (no PATH, no locale).startJob()likewise replaced the entire environment whenever a non-emptyenvwas passed.Impact
durationis derived fromvideo_metadata, so every affected VOD showed "(Unknown)" duration in the UI.BaseVOD.toAPI()callsgetDuration(true)and that falls through togetMediainfo()when metadata is missing, every/api/v0/channelsrequest re-ran mediainfo for every affected VOD (each attempt also creates a Job, writes its pid file and broadcasts). With a few hundred VODs my dashboard took 26+ seconds TTFB on every single load, and the log accumulated 13,000+Could not find durationlines.Fix
Execute.ts: spawn withenv: { ...process.env, ...env }in bothexec()andstartJob(), so children inherit PATH/locale and custom vars overlay them.Dockerfile:ENV LANG=C.UTF-8 LC_ALL=C.UTF-8.Verified locally: mediainfo now succeeds on Chinese filenames inside the container, and durations populate correctly.
Kept this PR minimal (just the env/locale fix). One possible follow-up: metadata repair currently happens inside
toAPI()during list requests, so a file that keeps failing gets retried on every dashboard load — moving that backfill to a background task and serving only stored values from list requests would decouple page load time from individual broken files. Happy to open that as a separate PR/discussion if useful, didn't want to bundle it in here.