• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support General Questions Generate backdrops from screenshots?

     
    • 0 Vote(s) - 0 Average

    Generate backdrops from screenshots?

    Similar to how missing poster art is generated
    stewed pork roti
    Offline

    Junior Member

    Posts: 10
    Threads: 3
    Joined: 2023 Oct
    Reputation: 0
    #1
    2024-07-14, 09:17 PM
    Can the screen grabber be used to also generate backdrops for certain media types? I have a library of concert recordings and I'd like to use a random screenshot as the backdrop, instead of the plain black bg.

    If there isn't a built in function or a plugin, does anyone know of an external tool that can do this?
    esjaysee
    Offline

    Junior Member

    Posts: 24
    Threads: 1
    Joined: 2024 Jan
    Reputation: 0
    Country:United States
    #2
    2024-07-14, 10:09 PM (This post was last modified: 2024-07-14, 10:10 PM by esjaysee. Edited 1 time in total.)
    I have a few concerts that all have images. In the Library settings, go to Chapter Images and check both boxes. That should make a generic screenshot of the video as the thumbnail. Then you can go to Edit Images and use it as the backdrop. I might be missing a step but I think that's how I did it.
    Efficient_Good_5784
    Offline

    Community Moderator

    Posts: 1,167
    Threads: 3
    Joined: 2023 Jun
    Reputation: 50
    #3
    2024-07-14, 11:21 PM
    (2024-07-14, 10:09 PM)esjaysee Wrote: I have a few concerts that all have images.  In the Library settings, go to Chapter Images and check both boxes.  That should make a generic screenshot of the video as the thumbnail.  Then you can go to Edit Images and use it as the backdrop.  I might be missing a step but I think that's how I did it.
    I just checked. You cannot reach the chapter images from the edit images option.
    The user would need to find the exact folder in the config/metadata/library directory to copy the chapter images.

    What would be more easier is to just open the concert video with an external player on the PC (VLC, MPV, etc.) and screenshot it. Then simply just upload the screenshot as the background for the concert in Jellyfin.
    stewed pork roti
    Offline

    Junior Member

    Posts: 10
    Threads: 3
    Joined: 2023 Oct
    Reputation: 0
    #4
    2024-07-18, 06:08 AM
    So no built-in way to do it with Jellyfin, then? I've got a pretty big folder of music videos and concerts, so the best I can think of is to write a bash script and take screenshots with ffmpeg at a random time.

    The Mediaelch app kind of does this, but you have to set your folder as "Movies" instead of "Concerts" and then you'd have to click it for each one. Not ideal, but better than nothing.

    Let me know if anybody finds something to do this efficiently, and I'll let you know if I ever write that script Smiling-face
    Efficient_Good_5784
    Offline

    Community Moderator

    Posts: 1,167
    Threads: 3
    Joined: 2023 Jun
    Reputation: 50
    #5
    2024-07-18, 06:49 AM
    (2024-07-18, 06:08 AM)stewed pork roti Wrote: ...so the best I can think of is to write a bash script and take screenshots with ffmpeg at a random time.

    As an FYI, the episode screen grabber in Jellyfin isn't actually random. It pulls an image from the same video duration percentage (I think) each time. It will not randomly pick a picture from any point in the video, so even if you recreate them, they come out the same.
    theguymadmax
    Offline

    Community Moderator

    Posts: 1,038
    Threads: 0
    Joined: 2024 Jun
    Reputation: 58
    #6
    2024-07-18, 05:22 PM
    (2024-07-18, 06:08 AM)stewed pork roti Wrote: Let me know if anybody finds something to do this efficiently, and I'll let you know if I ever write that script Smiling-face

    This python script should do the job, adjust to your needs. It's set to create three backdrops; one at 20 & 40 seconds and one random within the first 5 minutes. Just set the script to be executable and run it without passing any arguments. Requirements: Python3 & FFmpeg.

    Code:
    #!/usr/bin/env python3

    import os
    import random
    import subprocess
    from pathlib import Path

    def extract_frames(input_file, output_prefix, first_file):
        # Define times to extract frames (in seconds)
        times = [20, 40]
        random_time = random.randint(60, 300)  # Random time between 60 and 300 seconds
        times.append(random_time)

        for i, time in enumerate(times):
            if i == 0 and first_file:
                output_file = f"{output_prefix}-backdrop.jpg"  # First file without number sequence
            else:
                output_file = f"{output_prefix}-backdrop{i+1}.jpg"  # Subsequent files with number sequence

            output_path = os.path.join(os.path.dirname(input_file), output_file)
            subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error',
                            '-i', input_file, '-ss', str(time), '-vframes', '1', output_path])
            print(f"Processed: {output_file}")

    def process_media_file(media_file):
        filename = media_file.name
        print(f"Processing: {filename}")
        filename_no_ext = filename[:filename.rfind('.')]
        output_prefix = f"{filename_no_ext}"
        extract_frames(str(media_file), output_prefix, first_file=True)

    def scan_directory(directory):
        media_files = []
        for root, _, files in os.walk(directory):
            for file in files:
                if any(file.lower().endswith(ext) for ext in ['.mp4', '.avi', '.mkv', '.mov']):
                    media_files.append(Path(root) / file)

        total_files = len(media_files)
        print(f"Total media files found: {total_files}")
        for media_file in media_files:
            process_media_file(media_file)

    if __name__ == "__main__":
        directory = input("Enter the directory path where media files are located: ").strip()

        if not os.path.isdir(directory):
            print("Invalid directory path.")
            exit()

        scan_directory(directory)
        print("Frame extraction completed.")
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode