Skip to content

Video transcode fails on dual-mono PCM audio with positional channel layout #29269

Description

@timonrieger

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

Video transcoding fails for video files that contain dual-mono PCM audio where each track carries a positional channel layout. FFmpeg's native AAC encoder rejects the positional layout and no audio packets are written.

Immich then falls back to serving the original file. On the web the browser can't decode the Apple Intermediate Codec video, so the asset shows a frozen thumbnail with audio-only playback; the same clips are also affected on mobile. Re-running the transcode job fails identically every time. QuickTime and VLC play the originals fine.

The OS that Immich Server is running on

Debian 13.5

Version of Immich Server

v2.7.5

Version of Immich Mobile App

v2.7.5

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

Source footage from a Sanyo Xacti HX-WA10 camcorder, later processed through Apple software (Apple Intermediate Codec + dual-mono PCM).

Your docker-compose.yml content

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:v2.7.5@sha256:c15bff75068effb03f4355997d03dc7e0fc58720c2b54ad6f7f10d1bc57efaa5
    volumes:
      - ${UPLOAD_LOCATION}:/data
      - ${THUMB_LOCATION}:/data/thumbs
      - ${ENCODED_VIDEO_LOCATION}:/data/encoded-video
      - ${PROFILE_LOCATION}:/data/profile
      - ${BACKUP_LOCATION}:/data/backups
      - /etc/localtime:/etc/localtime:ro
      - /path/to/media/photos:/mnt/media/photos
      - /path/to/media/clips:/mnt/media/clips
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: unless-stopped
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:v2.7.5@sha256:a2501141440f10516d329fdfba2c68082e19eb9ba6016c061ac80d23beadf7f3
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: unless-stopped
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/valkey/valkey:9@sha256:4963247afc4cd33c7d3b2d2816b9f7f8eeebab148d29056c2ca4d7cbc966f2d9
    healthcheck:
      test: redis-cli ping || exit 1
    restart: unless-stopped

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    shm_size: 128mb
    restart: unless-stopped

volumes:
  model-cache:

Your .env content

# The location where your uploaded files are stored
UPLOAD_LOCATION=/path/to/immich/upload

# Custom locations for performance-sensitive, regeneratable data (SSD)
THUMB_LOCATION=/path/to/immich/thumbs
ENCODED_VIDEO_LOCATION=/path/to/immich/encoded-video
PROFILE_LOCATION=/path/to/immich/profile
BACKUP_LOCATION=/path/to/immich/backups

# The location where your database files are stored.
DB_DATA_LOCATION=/path/to/immich/postgres

TZ=Europe/Zurich
IMMICH_VERSION=v2
DB_PASSWORD=REDACTED

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

Reproduction steps

  1. Have a video file with Apple Intermediate Codec (aic) video plus two mono PCM tracks tagged with positional channel layouts (FL and FR) and a tmcd data track — i.e. typical iMovie/QuickTime-exported footage.
  2. Upload it to Immich.
  3. The transcoding job runs (the policy transcodes because aic is not in the accepted video codecs).
  4. The job fails with ffmpeg exited with code 234; the asset plays audio only with a frozen thumbnail.

A repro file can be download and used freely at https://github.com/user-attachments/assets/c6016926-50d4-4251-9ea2-1763ef686b2d

Relevant log output

LOG [Microservices:MediaService] Transcoding video <asset-id> without hardware acceleration
DEBUG [Microservices:MediaRepository] ffmpeg -n 10 /usr/bin/ffmpeg -i /mnt/media/clips/clip.mov -y -c:v h264 -c:a aac -movflags faststart -fps_mode passthrough -map 0:0 -map_metadata -1 -map 0:1 -v verbose -vf scale=-2:720 -preset ultrafast -crf 23 /data/encoded-video/<...>.mp4

  Duration: 00:00:08.98, start: 0.000000, bitrate: 109026 kb/s
  Stream #0:0[0x1](eng): Video: aic, 1 reference frame (icod / 0x646F6369), yuv420p(progressive), 1920x1080, 107410 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 2997 tbn (default)
      Metadata:
        encoder         : Apple Intermediate Codec
  Stream #0:1[0x2](eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels (FL), s16, 768 kb/s (default)
  Stream #0:2[0x3](eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels (FR), s16, 768 kb/s (default)
  Stream #0:3[0x4](eng): Data: none (tmcd / 0x64636D74), 0 kb/s

Stream mapping:
  Stream #0:0 -> #0:0 (aic (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))

[auto_aresample_0 @ ...] ch:1 chl:1 channels (FL) fmt:s16 r:48000Hz -> ch:1 chl:1 channels (FL) fmt:fltp r:48000Hz
[aac @ ...] Unsupported channel layout "1 channels (FL)"
[aac @ ...] Qavg: nan
[aost#0:1/aac @ ...] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[af#0:1 @ ...] Error sending frames to consumers: Invalid argument
[af#0:1 @ ...] Task finished with error code: -22 (Invalid argument)

# video side encodes fine before being discarded:
[libx264 @ ...] frame I:1     Avg QP:20.00  size:213614
[libx264 @ ...] frame P:70    Avg QP:25.94  size: 43819
[libx264 @ ...] kb/s:11079.52

[out#0/mp4 @ ...] Nothing was written into output file, because at least one of its streams received no packets.
Conversion failed!

ERROR [Microservices:MediaService] Error occurred during transcoding: ffmpeg exited with code 234: Conversion failed!

Additional information

Root cause

The source audio stream is mapped straight into the AAC encoder with no channel-layout normalization.

Patch that worked for me

Normalizing the channel layout and merging the dual-mono pair into real stereo lets the transcode complete into a browser-playable H.264/AAC MP4:

ffmpeg -i input.mov \
  -filter_complex "[0:a:0][0:a:1]amerge=inputs=2,aformat=channel_layouts=stereo[a]" \
  -map 0:v:0 -map "[a]" \
  -c:v libx264 -crf 20 -preset slow -pix_fmt yuv420p \
  -c:a aac -b:a 192k -movflags faststart output.mp4

The minimal trigger is the missing layout normalization on the AAC path: forcing a standard layout (e.g. -ac 2) is enough to prevent the crash, while amerge additionally preserves true stereo from the two separate mono tracks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status
    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions