• 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): « Previous 1 2

     
    • 0 Vote(s) - 0 Average

    Comskip and Media Segments

    esvee
    Offline

    Junior Member

    Posts: 8
    Threads: 0
    Joined: 2025 Mar
    Reputation: 0
    #11
    2025-03-25, 07:19 AM (This post was last modified: 2025-03-25, 07:24 AM by esvee. Edited 2 times in total.)
    I’m finding media segments not entirely reliable. If I record the same show using Plex and jellyfin at the same time, and pass each through the same script, the output that imports automatically into jellyfin does not skip ads. But importing the one from Plex does. Both have the chapter markers.

    My suspicion is that there is something going on with the library refreshing during the recording and media segments not getting picked up (because they don’t exist yet).

    But @TheDreadPirate you say the metadata is tied to file? So shouldn’t the comskipped remux file get its own database and media segment entries?

    is there a way to manually purge chapter segment info from the database? - as deleting and reimporting the file doesn’t help, nor does triggering any metadata refresh or segment scan.. Smiling-face
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #12
    2025-03-25, 01:45 PM
    "Replace all metadata" should purge chapter segment info, right?

    Also, media segments scans do not run on library import. It is a separate job in Scheduled Tasks.
    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]
    esvee
    Offline

    Junior Member

    Posts: 8
    Threads: 0
    Joined: 2025 Mar
    Reputation: 0
    #13
    2025-03-25, 03:25 PM
    (2025-03-25, 01:45 PM)TheDreadPirate Wrote: "Replace all metadata" should purge chapter segment info, right?

    Also, media segments scans do not run on library import.  It is a separate job in Scheduled Tasks.

    I’ve tried replace all metadata and also have media segments scheduled for every 30 minutes. Chapter segments aren’t triggering any skipping if there was previously a ts version of the file in the library. 

    So as a workaround, ive found an ignore glob pattern plugin, to ignore ts files. That way the converted mp4 file is the first in the library, and com chapters skip as expected.
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #14
    2025-03-31, 11:00 PM (This post was last modified: 2025-03-31, 11:03 PM by AustinL. Edited 3 times in total.)
    I am making good progress with this project.  I can use the API to enumerate media segments for an item and I can delete media segments (if the Media Segments API plugin is installed on my server)... But I am having a real problem creating media segments.  The URL I am posting to is

    http://myserver/MediaSegmentsApi/{itemId}

    Where {itemId} is the ID of the parent item, and the request body is something like this:

    {
    "Id":"baaac615-a238-4cf2-8dcc-fb22afce9782",
    "ItemId":"5a7af56b-eec6-f219-6cd0-d445b5bc87ad",
    "Type":1,
    "StartTicks":123527,
    "EndTicks":345475
    }

    But... the API is expecting a URL parameter called providerId and I have absolutely no idea what this is - if I use a random string, I get the response:

    {
        "message": "Provider with id 'RandomString' not found."
    }

    Any ideas? - What is a "provider" in this context, and how do I get an ID for it?

    Thanks,
    Austin
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #15
    2025-04-01, 01:27 PM
    I have recently been informed that you should avoid using the Media Segments API. It is a legacy implmentation prior to official media segment support in the server and is problematic post 10.10.

    The proper media segments endpoints are documented here.

    https://api.jellyfin.org/#tag/MediaSegments
    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
    #16
    2025-04-01, 07:16 PM (This post was last modified: 2025-04-01, 07:18 PM by AustinL. Edited 3 times in total.)
    Ah, OK, thanks... the problem is that the native API only allows enumeration of media segments (which works perfectly for me), but it doesn't allow adding or removing segments, which is really what I'm trying to do with this project.

    I can remove segments with the Media Segments API, but I can't add new segments... and from what you're telling me, I'm going about it the wrong way anyway :-(

    Oh well... back to the drawing board - many thanks for all your guidance, it's really useful! I will post back here when (if) I make any further progress!

    Thanks,
    Austin
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #17
    2025-04-01, 07:29 PM
    Oh... I think I've just solved it!... if I use "Chapter Segments Provider" for the provider ID parameter, it seems to work - I can add new media segments to an item.

    (Although that's using the third party API which you have advised against... so maybe it's not the ideal solution)

    Complete code to follow in a few days when I've tidied it all up.
    AustinL
    Offline

    Junior Member

    Posts: 9
    Threads: 1
    Joined: 2025 Jan
    Reputation: 0
    Country:United Kingdom
    #18
    2025-04-02, 10:35 AM
    All in Visual Basic, I'm afraid... I'm such an amateur.

    First, a few constants:

    Code:
            Const MyServer = "http://localhost:8096"
            Const PathToComSkip = "C:\ComSegments\comskip\comskip.exe"
            Const PathToComSkipINI = "C:\ComSegments\comskip\comskip.ini"
            Const AuthToken = "MediaBrowser Token=""MyAPIToken"""
            Const ProviderID = "Chapter Segments Provider"
            Const ComskipEDLFile = "C:\ComSegments\working\tmp.edl"

    Next, Analyse the media file with Comskip and generate EDL file:

    Code:
            Dim psi As ProcessStartInfo
            Dim p As Process

            psi = New ProcessStartInfo(PathToComSkip)
            psi.ArgumentList.Add(FileToAnalyse)
            psi.ArgumentList.Add("--ini=" & PathToComSkipINI)
            p = Process.Start(psi)
            p.WaitForExit()


    And finally, mark the media segments:

    Code:
            Dim lines = File.ReadAllLines(ComskipEDLFile)
            Dim LineParts() As String

            For Each line In lines
                LineParts = line.Split(vbTab)
                ms = New MediaSegment
                ms.Id = Guid.NewGuid
                ms.ItemId = Guid.Parse(ItemId)
                ms.Type = MediaSegmentType.Commercial
                ms.StartTicks = LineParts(0) * 10000000
                ms.EndTicks = LineParts(1) * 10000000
                h = New StringContent(JsonConvert.SerializeObject(ms), Encoding.UTF8, "application/json")
                Await Client.PostAsync(MyServer & "/MediaSegmentsApi/" & Guid.Parse(ItemId).ToString & "?providerId=" & ProviderID, h)
            Next


    I'm still running this manually because I can't find a way of getting the ID of an item from the recording post processing command, but actually that's OK for me because only a few programmes that I record are on commercial TV.  I'm happy with it for my purposes, no need for any muxing, converting, creating chapters, or deleting - it doesn't even touch the source file.  If anyone is interested in taking the idea and making it into a plugin, that would be wonderful (not me, I don't have the skills or the patience), and it would be really cool if the Jellyfin geniuses could expand the native Media Segments API to allow creation and deletion and avoid the need to use the third party Media Segments API plugin.

    And my wife is happy because she now gets a "Skip Ads" button when she watches her favourite soaps :-)

    Many thanks to TheDreadPirate and esvee for pointing me in the right direction!

    Austin
    Pages (2): « Previous 1 2

    « 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