NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.19k stars 14.2k forks source link

Jellyfin fails to transcode due to dependency error in libpng16 #96321

Closed Noir- closed 1 year ago

Noir- commented 4 years ago

Describe the bug If Jellyfin tries to transcode certain media using ffmpeg it fails because of a faulty dependency regarding libm and glibc. This prevents any playback.

To Reproduce I'm not sure which kind of media triggers this bug. This is the ffmpeg log of a failed transcode:

http://192.168.1.42:8096/videos/5f1a6520-1220-d964-aecd-1d340730121e/live.m3u8?DeviceId=TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvODQuMC40MTQ3LjEzNSBTYWZhcmkvNTM3LjM2fDE1OTgyMDM0NDE3MDY1&MediaSourceId=5f1a65201220d964aecd1d340730121e&VideoCodec=h264&AudioCodec=mp3,aac&VideoBitrate=139808000&AudioBitrate=192000&PlaySessionId=386e61bb77c447d28907bd4cfa5cf0fc&api_key=38aaaa3932da4be9b947649733354a03&TranscodingMaxAudioChannels=2&RequireAvc=false&Tag=da2262828ba2fca89243bce1d4dc57d5&SegmentContainer=ts&MinSegments=1&BreakOnNonKeyFrames=True&h264-profile=high,main,baseline,constrainedbaseline,high10&h264-level=51&TranscodeReasons=ContainerNotSupported

{"Protocol":"File","Id":"5f1a65201220d964aecd1d340730121e","Path":"/media/something.avi","Type":"Default","Container":"avi","Name":"something","IsRemote":false,"ETag":"da2262828ba2fca89243bce1d4dc57d5","ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"RequiresLooping":false,"SupportsProbing":true,"VideoType":"VideoFile","MediaStreams":[],"Formats":[],"RequiredHttpHeaders":{}}

/nix/store/nc7ic78k0zl3b9ar9kcin9pw93lfhwaw-ffmpeg-3.4.7-bin/bin/ffmpeg -f avi -i file:"/media/something.avi" -map_metadata -1 -map_chapters -1 -threads 0 -sn -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 19 -maxrate 139808000 -bufsize 279616000 -profile:v high -level 4.1 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:gte(t,n_forced*3)" -flags -global_header -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 192000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_entry_prefix "hls/c1c5b3e91a211859fccad37ae134c7d2/" -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/lib/jellyfin/transcoding-temp/c1c5b3e91a211859fccad37ae134c7d2.m3u8" -y "/var/lib/jellyfin/transcoding-temp/c1c5b3e91a211859fccad37ae134c7d2%d.ts"

/nix/store/nc7ic78k0zl3b9ar9kcin9pw93lfhwaw-ffmpeg-3.4.7-bin/bin/ffmpeg: /nix/store/wx1vk75bpdr65g6xwxbj4rw0pk04v5j3-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /nix/store/i3h1q2qpawskwiq4slr6fcs682qilnx6-libpng-apng-1.6.37/lib/libpng16.so.16)

Additional context Since Jellyfin 10.6.3 is not in the nixos-unstable channel yet, I manually patched the derivation to make it build.

Notify maintainers @nyanloutre @minijackson

Metadata

nyanloutre commented 4 years ago

Do you have the mediainfo of the file you are trying to transcode ? I've never seen this bug with standard mkv container with h264 video.

Noir- commented 4 years ago

Some files where the error occurs:

  1. Container avi, codec: Xvid MPEG-4, audio: mp3
  2. Container mkv, codec: H264 MPEG-4-AVC (avc1), audio: ac3

But I think I also depends on the client whether it is transcoded or not. Maybe it helps with testing if you force transcoding. I'm using DLNA on a WebOS TV but it doesn't work with the web interface in Chromium as well. There was no such Issue with these files before I upgraded from 10.5.3 (I recently upgraded my NixOS from 19.09 to 20.03).

minijackson commented 4 years ago

Hello, I tested a bit on my end, and can't reproduce your failure on Jellyfin 10.6.3:

Here's how I tested:

mkdir /tmp/medias
cd /tmp/medias
ffmpeg -f lavfi -i testsrc=duration=10 -f lavfi -i anoisesrc=duration=10 -c:v h264 -c:a ac3 test.mkv

Then went through the jellyfin configuration wizard and tried playing on both Firefox and Chromium (both worked).

I tried creating the xvid case, but ffmpeg segfaults with libxvid (I should investigate that).

Output of `ffprobe test.mkv` ``` ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers built with gcc 9.3.0 (GCC) configuration: --disable-static --prefix=/nix/store/vkk8yv64302jf8y8a9vdp4l7q7bbq59w-ffmpeg-full-4.3.1 --target_os=linux --arch=x86_64 --enable-gpl --enable-version3 --disable-nonfree --enable-shared --enable-pic --disable-small --enable-runtime-cpudetect --disable-lto --enable-gray --enable-swscale-alpha --enable-hardcoded-tables --enable-safe-bitstream-reader --enable-pthreads --disable-w32threads --disable-os2threads --enable-network --enable-pixelutils --enable-ffmpeg --enable-ffplay --enable-ffprobe --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-avutil --enable-postproc --enable-swresample --enable-swscale --enable-doc --disable-htmlpages --enable-manpages --disable-podpages --disable-txtpages --enable-bzlib --enable-libcelt --enable-libdav1d --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --enable-libfribidi --enable-libgme --enable-gnutls --enable-libgsm --enable-ladspa --enable-libmp3lame --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdc1394 --enable-iconv --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmysofa --enable-libopus --enable-librsvg --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvmaf --enable-libvpx --enable-libwebp --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-lzma --enable-nvenc --enable-openal --enable-libopencore-amrnb --disable-opengl --enable-libopenjpeg --disable-openssl --enable-libpulse --enable-librtmp --enable-sdl2 --enable-libsoxr --enable-libspeex --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-zlib --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, matroska,webm, from 'test.mkv': Metadata: ENCODER : Lavf58.45.100 Duration: 00:00:10.02, start: 0.000000, bitrate: 134 kb/s Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p(progressive), 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default) Metadata: ENCODER : Lavc58.91.100 libx264 DURATION : 00:00:10.005000000 Stream #0:1: Audio: ac3, 48000 Hz, mono, fltp, 96 kb/s (default) Metadata: ENCODER : Lavc58.91.100 ac3 DURATION : 00:00:10.016000000 ```

Also the screenshot of jellyfin's media info for good measure.

@Noir- can you confirm this is the same format as the one that fails on your end? Could you try adding the same test.mkv to your instance and see if it works?

minijackson commented 4 years ago

Also, do you have any particular transcoding options?

Here are the options that I have on a fresh Jellyfin 10.6.3 install.

Noir- commented 4 years ago

What I can see is that there's a way older ffmpeg version configured in my installation because I'm on the stable channel: /nix/store/nc7ic78k0zl3b9ar9kcin9pw93lfhwaw-ffmpeg-3.4.7-bin/bin/ffmpeg

Could this be the crucial difference in our installations. I installed Jellyfin from unstable because I needed the fixes in upstream. I included it like this:

let
  unstable = import <nixos-unstable> {};
in
{
  disabledModules = [ "services/misc/jellyfin.nix" ];
  imports =
  [
    ./hardware-configuration.nix
    <nixos-unstable/nixos/modules/services/misc/jellyfin.nix>
  ];
  services.jellyfin = {
    enable = true;
    package = unstable.jellyfin;
  };
}

The other transcoding options are identical. Do you know what would be the preferred way to include ffmpeg from the other channel? I'd like to try that before I continue with the other steps you suggested.

Noir- commented 4 years ago

I just tried the quick and dirty way: I installed ffmpeg-full from the unstable channel and configured Jellyfin to use it. This fixed all the problems for me. I somehow assumed that the dependencies of unstable packages will be installed from the unstable channel as well. But obviously I was wrong?

minijackson commented 4 years ago

From the top of my head, I think you're right actually, ffmpeg is a dependency of jellyfin and the path to the binary is passed through a wrapper, so you should have ffmpeg from unstable.

If you do systemctl cat jellyfin and then cat <path-of-jellyfin-in-the-systemd-service>, can you tell me the version of ffmpeg you see in the wrapper?

The way I installed jellyfin on my system is this:

{
  nixpkgs.overlays = let
    unstable = import <nixpkgs-unstable> {};
  in [
    (self: super: {
      inherit (unstable) jellyfin;
    })
  ];

  services.jellyfin = {
    enable = true;
  };
}

and I do have ffmpeg-4.3.1 set in the wrapper.

Noir- commented 4 years ago

I can confirm that this is the same on my system:

#! /nix/store/6737cq9nvp4k5r70qcgf61004r0l2g3v-bash-4.4-p23/bin/bash -e
export LD_LIBRARY_PATH='/nix/store/f7lws879jarjs40qznw95pwz4ngc7ib0-sqlite-3.32.3/lib:/nix/store/n9n570xdj4gnza8yp1vkgqlidadcwkbj-fontconfig-2.13.92-lib/lib:/nix/store/6nlkl2jqywpyxwk7c8il8kr5d3fkplpz-freetype-2.10.2/lib:/nix/store/v589pqjhvxrj73g3r0xb41yr84z5pwb7-gcc-9.3.0-lib/lib:/nix/store/q2wwkkllkcn8pzai29z10m4m18gklmyn-jellyfin-10.6.3/opt/jellyfin/runtimes/linux-x64/native/'${LD_LIBRARY_PATH:+':'}$LD_LIBRARY_PATH
exec "/nix/store/3d12d60dixhlx29vqqb38y29abb77ii6-aspnetcore-runtime-3.1.5/bin/dotnet"  /nix/store/q2wwkkllkcn8pzai29z10m4m18gklmyn-jellyfin-10.6.3/opt/jellyfin/jellyfin.dll --ffmpeg /nix/store/1xhddl3lgy36hycz7ch2xs2jkkrw06zz-ffmpeg-4.3.1-bin/bin/ffmpeg "$@"

Weird stuff. My guess is that the application config overwrites the command line flag. I never touched this value until now. Feels a bit counter intuitive because it should be the other way around. On the other hand I also can't imagine that this behavior worked well with NixOS in the past, unless it was introduced in a recent change. I'll have a look at the source.

kevincox commented 4 years ago

Ah, I was having the same problem. Clearing the ffmpeg field fixed it. However it appeared to get repopulated the next time I started jellyfin. I wonder if we will need some way to fix that field. Maybe needs a patch.

AkechiShiro commented 3 years ago

I'm encountering the same issue, how could I solve this, do I need to install ffmpeg-full from the unstable NixOS repo ?

minijackson commented 3 years ago

@AkechiShiro according to the previous messages, going into the settings on the web interface, under Playback, FFmpeg path, clearing the field and restarting the server solved the issue for them. Does it work for you?

AkechiShiro commented 3 years ago

Hi @minijackson I'm using Jellyfin version 10.7.1 and there is no FFmpeg path in the web interface however, I did found a way to fix it, I followed instruction given in issue #103218 and I found out that the hash path used by jellyfin was different from the path set inside /var/lib/jellyfin/config/encoding.xml in the tag <EncoderAppPath>/nix/store/path-to-old-derivation-of-ffmpeg/ffmpeg<EncoderAppPath> And also <EncoderAppPathDisplay>/nix/store/path-to-old-derivation-of-ffmpeg/ffmpeg<EncoderAppPathDisplay>, after changing these values I did a systemctl restart jellyfin and that fixed the problem.

Thesola10 commented 2 years ago

@AkechiShiro a more future-proof fix would be to use /run/current-system/sw/bin/ffmpeg as the FFmpeg path

kevincox commented 2 years ago

Assuming that ffmpeg is globally installed that is.

Thesola10 commented 2 years ago

@kevincox I believe the services.jellyfin option installs ffmpeg globally -- I'm using a volatile, single-purpose container config and didn't specify ffmpeg explicitly.

AkechiShiro commented 2 years ago

Thanks for the recommendation @Thesola10, will definitely try this out !

AkechiShiro commented 2 years ago

@Thesola10 I checked actually and ffmpeg is not installed globally, @kevincox's comment is relevant to me, even with services.jellyfin being enabled. The path /run/current-system/sw/bin/ffmpeg returns no such file or directory.

> which ffmpeg
/home/user/.nix-profile/ffmpeg

Or am I missing something very dumb ?

bjornfor commented 1 year ago

I think this can be closed, see https://github.com/NixOS/nixpkgs/issues/178123#issuecomment-1159814884.