![]() |
Comskip and Media Segments - Printable Version +- Jellyfin Forum (https://forum.jellyfin.org) +-- Forum: Support (https://forum.jellyfin.org/f-support) +--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions) +--- Thread: Comskip and Media Segments (/t-comskip-and-media-segments) Pages:
1
2
|
Comskip and Media Segments - AustinL - 2025-03-19 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 RE: Comskip and Media Segments - TheDreadPirate - 2025-03-19 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. RE: Comskip and Media Segments - AustinL - 2025-03-20 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 RE: Comskip and Media Segments - TheDreadPirate - 2025-03-20 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? RE: Comskip and Media Segments - AustinL - 2025-03-21 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 RE: Comskip and Media Segments - TheDreadPirate - 2025-03-21 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. RE: Comskip and Media Segments - AustinL - 2025-03-21 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. RE: Comskip and Media Segments - TheDreadPirate - 2025-03-21 IIRC, Media Segments has an API. And that the intro skipper plugin makes use of that. RE: Comskip and Media Segments - AustinL - 2025-03-21 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 RE: Comskip and Media Segments - esvee - 2025-03-25 (2025-03-21, 10:56 PM)AustinL Wrote: Thanks! - I think that's what I need :-) @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" |