Skip to main content

Jellyfin

Jellyfin เป็น Media Server ที่ถือว่าดีตัวหนึ่งที่สามารถใช้ Hardware acceleration ได้โดยไม่ต้องเสียเงินแบบ Plex แต่ปัญหาหนึ่งของ Jellyfin คือ ตั้งค่า Hardware acceleration ยากพอสมควร และเช็คยากด้วยว่าใช้อยู่หรือไม่ แต่ถ้าเปิดใช้ก็จะช่วยลดภาระในการแปลงไฟล์ลงไปเยอะ คือจากกิน CPU 60-70% เหลือ 18-30% บน DS918+

เท่าที่ลองหาวิธีเปิด Hardware acceleration ส่วนมากจะเป็นการให้สิทธ์ root กับ Jellyfin เพื่อให้เข้าถึงการ์ดจอใน NAS ได้ ซึ่งดูแล้วเหมือนจะให้สิทธ์เยอะเกินไปหน่อย ซึ่งวิธีที่ถูกต้องควรจะทำเหมือน Plex มากกว่าคือ ขอสิทธ์ใช้การ์ดจอเท่านั้นก็พอ ดังนั้นสิ่งที่ต้องทำก็จะย้อนรอย Plex นิดหน่อย (Plex ทำมาให้อัติโนมัติแล้ว) คือ

    สร้าง ID User ใหม่ใน DSM เป็นของ Jellyfin โดยเฉพาะ เพื่อใช้ใน Docker ให้สิทธ์ User Jellyfin ในการเข้าถึง folder ต่าง ๆ เพื่อดึง Media ของเรามาใช้ ให้สิทธ์ User Jellyfin เข้าถึงการ์ดจอเพื่อใช้ในการทำ Hardware acceleration

     

    วิธีสร้าง User ใหม่ให้รองรับ Hardware acceleration

    สร้าง ID User ใหม่ใน DSM เป็นของ Jellyfin โดยเฉพาะ เพื่อใช้ใน Docker

    คุณจะใช้ ID อื่นที่ใช้เชื่อมต่อ Docker อยู่แล้วก็ได้ ถ้าจะใช้ ID เดิม ข้ามไป ส่วน "ให้สิทธ์ User Jellyfin เข้าถึงการ์ดจอ" ได้เลย

    ไปที่ Control Panel > User & Group > User > Create สร้าง user Jellyfin ขึ้นมาให้ แล้วอย่าลืมให้สิทธ์ read write folder docker และ folder media อื่น ๆ ของคุณด้วย ไม่งั้นเวลาเปิด media folder ที่ไม่มีสิทธิ์มันจะไม่เห็นไฟล์อะไรเลย

    image.png

     

    ให้สิทธ์ User Jellyfin เข้าถึงการ์ดจอเพื่อใช้ในการทำ Hardware acceleration

    ส่วนนี้ต้องใช้ SSH ในการเข้าไปจัดการสิทธิ์ ถ้าไม่เป็น อ่านเพิ่มได้ที่ SSH พื้นฐานเพื่อเชื่อมต่อ NAS และการติดตั้งโปรแกรมผ่านวิธีต่าง ๆ

    เมื่อเข้ามาใน SSH แล้ว ก่อนอื่นเราต้องหา UID และ GID ของ Jellyfin ก่อนเพื่อใช้เป็น user ใน Jellyfin ทำได้โดยใช้คำสั่ง

    id Jellyfin

     

    จด UID และ GID ไว้ให้เรียบร้อย หลังจากนั้น ลองเช็คดูว่ามี user ไหนอยู่ในกลุ่มที่ใช้การ์ดจอได้บ้างโดยพิมพ์

    sudo synogroup -get videodriver

    image.png

    ถ้าขึ้นจอให้กรอกรหัสผ่านให้กรอกไปอีกรอบ ก็ตะเห็นว่า Plex อยู่ในกลุ่มอยู่แล้วทีนี้มาทำ Jellyfin บ้าง

    ถ้ามี user อื่นอยู่ในนั้น เช่น PlexMediaServer อย่าลืมพิมพ์ใส่กลับเข้าไปด้วย ไม่งั้นมันจะมีแค่ user เดียวที่เราพิมพ์เข้าไป

    sudo synogroup --member videodriver PlexMediaServer Jellyfin

    เสร็จเรียบร้อยในขั้นตอนสร้าง user ใหม่ให้รองรับ Hardware acceleration

     

     

    version: "3.5"
    services:
      jellyfin:
        image: jellyfin/jellyfin
        container_name: jellyfin
        user: 1035:100    # <- PUID:PGID
        ports:
          - 8096:8096
        volumes:
          - /volume1/docker/jellyfin/config:/config
          - /volume1/docker/jellyfin/cache:/cache
          - /volume1/docker/jellyfin/media:/media
        devices:
          # VAAPI Devices - Enable Transcode for QSV (less CPU) or VA API (Quality)
          - /dev/dri/renderD128:/dev/dri/renderD128
          - /dev/dri/card0:/dev/dri/card0
        restart: "unless-stopped"

    Jellyfin เป็น Media Server ที่ถือว่าดีตัวหนึ่งที่สามารถใช้ Hardware Transcode ได้โดยไม่ต้องเสียเงินแบบ Plex แต่ปัญหาหนึ่งของ Jellyfin คือ ตั้งค่า Hardware Transcode ยากพอสมควร และเช็คยากด้วยว่าใช้อยู่หรือไม่ แต่ถ้าเปิดใช้ก็จะช่วยลดภาระในการแปลงไฟล์ลงไปเยอะ คือจากกิน CPU 60-70% เหลือ 18-30% บน DS918+


    สำหรับ

    Jellyfin ถ้าอยากใช้ Hardware Transcode แนะนำให้สร้าง ID ใหม่บน DSM ครับ


    Plex Jellyfin Sctucture

    Movie - Inline
    Plex Jellyfin
    -trailer -trailer .trailer _trailer (space)trailer
    -featurette -featurette
    -behindthescenes -behindthescenes
    -deleted -deleted
    -interview -interview
    -scene -scene
    -short -short
    -other

    -clip

    -sample .sample _sample (space)sample
    Movies
     └─ Avatar (2009)
        ├─ Avatar (2009).mkv
        ├─ Arrival-scene.mp4
        ├─ Bar Fight-deleted.mp4
        ├─ Performance Capture-behindthescenes.mkv
        ├─ Sigourney Weaver-interview.mp4
        ├─ Stephen Lang-interview.mp4
        ├─ Teaser Trailer-trailer.mp4
        ├─ Theatrical Trailer #1-trailer.mp4
        └─ Theatrical Trailer #2-trailer.avi
    Movies
    └─ Best_Movie_Ever (2019)
       ├─ Best_Movie_Ever (2019) - 1080P.mp4
       ├─ That clip that I want everyone to see-clip.mp4
       ├─ Release Trailer-trailer.mp4
       ├─ Preview Trailer.trailer.avi
       ├─ Release Trailer 2_trailer.avi
       ├─ Teaser.sample.mp4
       ├─ Favorite Scene-scene.mp4
       ├─ The Best Ever-clip.mp4
       ├─ Making of The Best Movie Ever-behindthescenes.mp4
       ├─ Not the best scene-deleted.mp4
       ├─ Theme Song Music Video-featurette.mp4
       └─ Art of the Best Movie Ever-short.mp4
    Movie - Subdirectories
    Plex Jellyfin
    Trailers Trailers
    Featurettes Featurettes
    Behind The Scenes Behind The Scenes
    Deleted Scenes Deleted Scenes
    Interviews Interviews
    Scenes Scenes
    Shorts Shorts
    Other

    Extras

    Samples
    Movies
    └─ Avatar (2009)
       └─ Avatar (2009).mkv
          ├─ Behind The Scenes
          │  └─ Performance Capture.mkv
          │
          ├─ Deleted Scenes
          │  ├─ Bar Fight.mp4
          │  └─ Lost Sister.mkv
          │      
          ├─ Interviews
          │  ├─ Sigourney Weaver.mp4
          │  └─ Stephen Lang.mp4
          │      
          ├─ Scenes
          │  └─ Arrival.mp4
          │      
          └─ Trailers
             ├─ Teaser Trailer.mp4
             ├─ Theatrical Trailer #1.mp4
             └─ Theatrical Trailer #2.mp4
    Movies
    └─ Best_Movie_Ever (2019)
       ├─ Best_Movie_Ever (2019) - 1080P.mp4
       ├─ Best_Movie_Ever (2019) - 720P.mp4
       ├─ Best_Movie_Ever (2019) - Directors Cut.mp4
       │
       ├─ behind the scenes
       │  ├─ Making of the Best Movie Ever.mp4
       │  └─ Finding the right score.mp4
       │ 
       ├─ interviews
       │  └─ Interview with the Director.mp4
       │   
       └─ extras
          └─ Home recreation.mp4


    Movie - Images


    Subdirectories

    Type
    Plex Jellyfin
    Poster

    • folder.ext
    • poster.ext
    • cover.ext
    • default.ext
    • movie.ext
    Backdrop

    • backdrop.ext
    • fanart.ext
    • background.ext
    • art.ext
    • extrafanart/*.ext
    Logo

    • logo.ext
    • clearlogo.ext