• 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 Comskip and Media Segments

    Pages (2): 1 2 Next »

     
    • 0 Vote(s) - 0 Average

    Comskip and Media Segments

    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #1
    2025-03-19, 01:42 PM
    I use JellyFin mostly as a DVR for UK Freeview terrestrial TV, running on an old Windows PC.  I am quite interested in the Media Segments feature to generate "Skip Ads" buttons when watching recordings from commercial TV stations.

    I eventually got a script working (using a .net console app) to:

    1. Use Comskip to generate an EDL file from newly recorded .ts videos
    2. Parse the EDL file and generate a text Chapter file
    3. Run ffmpeg to generate an MKV file with chapter markings
    4. Clean up by deleting the original .ts file and the various additional files generated by Comskip and ffmpeg

    All of this works beautifully (except that I need to force a Library Scan and a Media Segment Scan after the conversion, I'm still working on that part), and I am very happy with the results - the "Skip Ads" button shows up and works very nicely on my LG TV native app... and (very unusually for this kind of project in our house) has a good "Wife Acceptance Factor" because we no longer spend longer fast forwarding, overshooting, and then rewinding again, than we would have spent watching the damned ads in the first place - Nice!

    But... I can't help thinking that this approach is much more complicated than it needs to be, and that there should be a way to achieve the same result non-destructively without needing to generate any new media files, analyse any chapters, delete the original media, or run any new library or segment scans.  Surely I should be able to just use Comskip to parse the original media and then simply use the output to write directly to the JellyFin Media Segments database.

    Is my understanding correct, and if so, does anyone have any hints about how I could start such a project? (I would be very happy to share this if I can ever get it to work).

    Thanks!
    Austin
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #2
    2025-03-19, 02:07 PM (This post was last modified: 2025-03-19, 02:08 PM by TheDreadPirate. Edited 1 time in total.)
    I am pretty sure what you are doing is probably the best/only solution. Unless your provider neatly provides chapter markers (probably not).

    Having said that, could you share your script? I know at least one person on the forum that had a similar use case.

    Is it run outside of Jellyfin? Or is it set as the post-processing script in the Jellyfin DVR settings?

    Regarding need to scan your library, is your storage a network share or locally attached disk? If it is a local disk, you can enable real time monitoring for the recordings library. This has worked well for my recordings. Though my post processing only involves remuxing from TS to MP4.
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #3
    2025-03-20, 10:35 AM
    Thanks!

    I will certainly post my code, but it's still embarrassingly sloppy... I will do so when I have tidied it up a little bit and fixed a couple of issues :-)

    But basically, apart from one or two niggles it works as expected, and as a post-processing script set up in the DVR settings. Storage is a local drive on the PC, and recordings are stored in the default Jellyfish location - C:\ProgramData\Jellyfin\Server\data\livetv\recordings

    The Niggles (both minor):

    1. As mentioned, I need to run a scan before Jellyfin will recognise the new .mkv file, even though I have "Enable real time monitoring" checked in the Recordings library settings (maybe because it has the same filename as the original .ts file?).
    2. For some reason my script can't delete the original .ts file, I think this is either a permissions issue (but there are no problems deleting the various other files generated by Comskip and ffmpeg), or because the file is still open by ffmpeg when the script runs - I have added a try/retry block in case this is the case, but without luck.

    But... the reason for my post isn't the niggles (I'll try to figure these out myself), but that I think there might be a way of using the Media Segments API to skip one of the stages... so right now, my script uses ffmpeg to remux the .ts to .mkv and mark chapters, and then JellyFin uses the chapters to mark the Media Segments based on the chapters - my understanding is that once this is done, the chapters themselves are of no further use. Wouldn't it be more efficient to skip the remuxing, and just call the Media Segments API directly after Comskip has identified the timestamps of the commercials?

    I'm not really sure how to do this though - my understanding is the the Media Segments API is still a plugin and maybe not supported yet?

    Thanks again,
    Austin
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #4
    2025-03-20, 02:22 PM
    Media Segments plugin you are referring to is fully supported. I get prompts for skipping on my configured chapter types.

    Regarding your question, I don't believe it is possible. Metadata is tightly tied to the file and not to the "episode" or "movie". So when you create chapter segment metadata it will be tied to the MKV file and not the TS file.

    Regarding "niggle" 1. Not sure why real time monitoring wouldn't work. My post processing script literally just remuxes to MP4 and removes the original TS file. And it picks up the MP4 at the end immediately.

    Regarding number 2, what are the permissions and ownership of the recording? Are you able to tell what user the post processing script runs as when Jellyfin runs it?
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #5
    2025-03-21, 12:47 PM
    Thanks again,

    I guess I was inspired by the "intro skipper" plugin, which I got working intermittently but didn't really use (skipping commercials is far more useful to me than skipping intros) and was hoping to create something similar, intro skipper seems to work with .ts files which I understand doesn't support chapters, so that's why I'm wondering if the information is also stored outside the file somehow... but maybe the plugin is remuxing the media to something else as part of the process and I've missed that; I will keep digging and share here if I make any progress - I have to admit to being rather an amateur coder, I have looked at some of the source code, but it's a bit complicated for my rather limited analysis skills :-)

    I'll have another play around with my setup over the weekend to take a look at my niggles, it's possible that I've missed a setting somewhere which is preventing Jellyfin from recognising the new MKV file immediately - I should probably start again with a clean install as I've been playing around with a few different plugins, etc. and messed about with a few settings that I probably shouldn't have touched!

    I guess the delete permissions issue might be related the account I am running Jellyfin under on my server - I have it running as a Windows service, so that might need a bit of tweaking (I am not at home right now, so can't answer your question, but will do so over the weekend).

    Once again, many thanks for your kind help and support, really appreciate it.

    Austin
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #6
    2025-03-21, 01:17 PM
    The metadata generated by the intro skipper plugin is stored in the Jellyfin database. I believe the same is true for "properly" named chapters in MKVs. Jellyfin parses those chapter names and will store them in the database for use by clients that support media segments and skipping.
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #7
    2025-03-21, 01:41 PM
    Ahh... that makes sense, thanks.

    So, perhaps I need to find a way to write these data directly to the jellyfin database, in the same way that intro skipper does.

    I'll continue digging into the intro skipper code.
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #8
    2025-03-21, 01:52 PM
    IIRC, Media Segments has an API. And that the intro skipper plugin makes use of that.
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #9
    2025-03-21, 10:56 PM
    Thanks! - I think that's what I need :-)

    I'll have a play around over the weekend, you have been really helpful, appreciate it!

    Austin
    esvee
    Offline

    Junior Member

    Posts: 8
    Threads: 0
    Joined: 2025 Mar
    Reputation: 0
    #10
    2025-03-25, 07:11 AM (This post was last modified: 2025-03-25, 07:22 AM by esvee. Edited 2 times in total.)
    (2025-03-21, 10:56 PM)AustinL Wrote: Thanks! - I think that's what I need :-)

    I'll have a play around over the weekend, you have been really helpful, appreciate it!

    Austin

    @AustinL
    For your first niggle you can initiate a scan directly from your script using refresh api call. 

    #!/bin/bash

    # Jellyfin server details
    JELLYFIN_URL="http://localhost:8096"
    API_KEY="your_api_key_here"

    # Trigger library scan
    curl -X POST "$JELLYFIN_URL/Library/Refresh?api_key=$API_KEY"
    Pages (2): 1 2 Next »

    « 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