Jump to content

Unicode (Cyriliic) characters in media path causing issues when trying to play media directly


Recommended Posts

Posted

Hello,

So I'm using Emby Server in docker container, current version is 4.9.1.80

I'm running this on Ubuntu Desktop 25.10

Same system used as HTPC, where I installed latest Emby Theater client app and I configured MVP to be used as external player;

Whenever I try to open media with Cyrillic symbols in path , Emby app complains that the file/path does not exists and it starts transcoding and I see the following in Emby app logs:

fs access result for path: Error: ENOENT: no such file or directory, access 
'/nas/movies/007 %D0%91%D1%80%D0%B8%D0%BB%D0%BB%D0%B8%D0%B0%D0%BD%D1%82%D1%8B 
%D0%BD%D0%B0%D0%B2%D1%81%D0%B5%D0%B3%D0%B4%D0%B0 (Diamonds Are Forever) [1971]/
Diamonds-Are-Forever_1971_Remux_1080p.mkv'

when the media path does not have Cyrillic symbols than everything works normally.

could you please check and let me know if there is known way to fix this?

PS. For anyone who might have the same issue, I have a workaround; which actually works quite well for me, perhaps even better then default behavior. I still decided to report this on forum as I think current behavior can be considered as a bug?

My workaround is to use intermediate bash script to analyze path Emby app passing, then call Emby API to get real media path (plus additional things like selected audio stream index, selected subtitles index, etc) and then open MVP passing all of this information. For this to work equally for both Cyrillic and standard ascii only characters paths I removed "network share" mapping from my libraries source folders; so now Emby app consider all titles as not available directly, and instead of actual path it passes URL like this

http://172.18.0.4:8096/emby/videos/612/original.mkv?DeviceId=emby-server
  &MediaSourceId=mediasource_612
  &PlaySessionId=[redacted]
  &api_key=[redacted]

or

http://172.18.0.4:8096/emby/videos/8/stream.mkv?DeviceId=emby-server
  &MediaSourceId=mediasource_8&PlaySessionId=[redacted]
  &api_key=[redacted]&VideoCodec=h264&AudioCodec=aac,mp3,ac3
  &VideoBitrate=199616000&AudioBitrate=384000&AudioStreamIndex=2

and I then parse it and get all information I need from Emby API.

My script looks like this

#!/bin/bash
# MPV wrapper for Emby Theater with BDMV Blu-ray support
# Handles bd:// protocol for proper Blu-ray menu/chapter navigation
# Queries Emby API to get real filesystem paths when HTTP URLs are passed

# Use XDG_RUNTIME_DIR for logs (cleaned on logout), fallback to /tmp
LOG_FILE="${XDG_RUNTIME_DIR:-/tmp}/mpv-emby-wrapper.log"
INPUT="$1"

echo "[$(date)] ==================== NEW REQUEST ====================" >> "$LOG_FILE"
echo "[$(date)] MPV Wrapper called with: $INPUT" >> "$LOG_FILE"

# Check if input is an HTTP URL to Emby server
if [[ "$INPUT" =~ ^http://.*emby/videos/([0-9]+).*api_key=([a-f0-9]+) ]]; then
    ITEM_ID="${BASH_REMATCH[1]}"
    API_KEY="${BASH_REMATCH[2]}"
    EMBY_SERVER="http://172.18.0.4:8096"

    echo "[$(date)] Detected Emby HTTP URL - Item ID: $ITEM_ID" >> "$LOG_FILE"

    # Extract audio and subtitle stream indexes from URL
    AUDIO_INDEX=""
    SUBTITLE_INDEX=""
    if [[ "$INPUT" =~ AudioStreamIndex=([0-9]+) ]]; then
        AUDIO_INDEX="${BASH_REMATCH[1]}"
        echo "[$(date)] Audio stream index: $AUDIO_INDEX" >> "$LOG_FILE"
    fi
    if [[ "$INPUT" =~ SubtitleStreamIndex=([0-9]+) ]]; then
        SUBTITLE_INDEX="${BASH_REMATCH[1]}"
        echo "[$(date)] Subtitle stream index: $SUBTITLE_INDEX" >> "$LOG_FILE"
    fi

    # Get UserId (query once and cache if possible)
    USER_ID=$(curl -s "${EMBY_SERVER}/emby/Users?api_key=${API_KEY}" | grep -o '"Id":"[^"]*"' | head -1 | sed 's/"Id":"//;s/"$//')

    echo "[$(date)] User ID: $USER_ID" >> "$LOG_FILE"

    # Query Emby API to get real file path (requires UserId in path)
    API_RESPONSE=$(curl -s "${EMBY_SERVER}/emby/Users/${USER_ID}/Items/${ITEM_ID}?api_key=${API_KEY}")

    # Extract Path field from JSON response
    MEDIA_PATH=$(echo "$API_RESPONSE" | grep -o '"Path":"[^"]*"' | head -1 | sed 's/"Path":"//;s/"$//')

    echo "[$(date)] Queried Emby API, got path: $MEDIA_PATH" >> "$LOG_FILE"

    # Path substitution: /data/movies -> /nas/movies, /data/series -> /nas/series
    MEDIA_PATH="${MEDIA_PATH/\/data\/movies/\/nas\/movies}"
    MEDIA_PATH="${MEDIA_PATH/\/data\/series/\/nas\/series}"

    echo "[$(date)] After path substitution: $MEDIA_PATH" >> "$LOG_FILE"
else
    # Direct path provided - decode URL encoding if present
    MEDIA_PATH=$(printf '%b' "${INPUT//%/\\x}")
    echo "[$(date)] Direct path (decoded): $MEDIA_PATH" >> "$LOG_FILE"
fi

# Check if path exists
if [[ ! -e "$MEDIA_PATH" ]]; then
    echo "[$(date)] ERROR: Path does not exist: $MEDIA_PATH" >> "$LOG_FILE"
    exit 1
fi

# Build MPV command with optional audio/subtitle track selection
MPV_ARGS=()

# Handle BDMV Blu-ray format with full menu support
if [[ -d "$MEDIA_PATH" ]] && [[ -d "$MEDIA_PATH/BDMV" ]]; then
    echo "[$(date)] Detected BDMV directory, using bd:// protocol" >> "$LOG_FILE"
    MPV_ARGS+=("bd://")
    MPV_ARGS+=("--bluray-device=$MEDIA_PATH")
elif [[ "$MEDIA_PATH" == *"/BDMV/"* ]]; then
    # Path points inside BDMV structure, extract parent directory
    PARENT_DIR=$(echo "$MEDIA_PATH" | sed 's|/BDMV/.*||')
    echo "[$(date)] Path inside BDMV, using bd:// protocol: $PARENT_DIR" >> "$LOG_FILE"
    MPV_ARGS+=("bd://")
    MPV_ARGS+=("--bluray-device=$PARENT_DIR")
else
    echo "[$(date)] Regular file playback: $MEDIA_PATH" >> "$LOG_FILE"
    MPV_ARGS+=("$MEDIA_PATH")
fi

# Add audio track selection if specified
if [[ -n "$AUDIO_INDEX" ]]; then
    MPV_ARGS+=("--aid=$AUDIO_INDEX")
    echo "[$(date)] Setting audio track: --aid=$AUDIO_INDEX" >> "$LOG_FILE"
fi

# Add subtitle track selection if specified
if [[ -n "$SUBTITLE_INDEX" ]]; then
    MPV_ARGS+=("--sid=$SUBTITLE_INDEX")
    echo "[$(date)] Setting subtitle track: --sid=$SUBTITLE_INDEX" >> "$LOG_FILE"
fi

# Start MPV in fullscreen mode and force it to stay on top of all windows
MPV_ARGS+=("--fs")
MPV_ARGS+=("--ontop")

echo "[$(date)] Executing: mpv ${MPV_ARGS[*]}" >> "$LOG_FILE"

# Launch MPV (blocks until playback finishes)
exec mpv "${MPV_ARGS[@]}"

 

Posted

hi, what version number of Emby Theater are you running?

Posted

I'm on Ubuntu Desktop - so I cant use windows app

Posted
5 hours ago, axlns said:

I'm on Ubuntu Desktop - so I cant use windows app

OK, we have a new Linux app coming soon, so stay tuned.

  • Like 1
  • 1 month later...
Posted
On 11/4/2025 at 8:08 PM, Luke said:

OK, we have a new Linux app coming soon, so stay tuned.

Hey Luke, is there any update on new Linux client app? Im having issue withy current linux app on Fedora, it doesnt start with the error 

❯ emby-theater
/opt/emby-theater/electron/emby-theater: symbol lookup error: /lib64/libpangoft2-1.0.so.0: undefined symbol: FcConfigSetDefaultSubstitute

Posted

Hi, yes any day now it will be available. Thanks.

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...