|
SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI. |
|
Thread Tools | Search this Thread | Display Modes |
#21
|
|||
|
|||
I just keep the Sage server in the basement, turn on smb, and run comskip over the network from a windows machine..... Works fairly well. I run showanalyzer that way as well.
|
#22
|
|||
|
|||
pyinotify
I have a WinXP Server that only runs comskip overnight to keep the load down while we're watching tv. I have two linux laptops that are on most of the day with some cpu to spare, so I looked into using these computers to run comskip while they're on.
I modified the script I found here to run comskip if a new .mpg file is created in the recording directory. It uses inotify in the linux kernel, so there's no polling of the directory involved. It does nothing until a new file appears, then it runs comskip. Code:
#!/usr/bin/python import os import pyinotify import time wm = pyinotify.WatchManager() mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE class PTmp(pyinotify.ProcessEvent): def process_IN_CREATE(self, event): #test for .mpg extension if os.path.join(event.name)[-4:] == '.mpg': # wait 3 mins before processing new file time.sleep(180) # run comskip on the new file os.system("/usr/bin/wine 'C:\Program Files\comskip\comskip.exe' 'C:\\tv\%s'" % os.path.join(event.name)) notifier = pyinotify.Notifier(wm, PTmp()) wdd = wm.add_watch('/media/tv', mask, rec=True) while True: try: notifier.process_events() if notifier.check_events(): notifier.read_events() except KeyboardInterrupt: notifier.stop() break Code:
os.system("/usr/bin/wine 'C:\Program Files\comskip\comskip.exe' 'C:\\tv\%s'" % os.path.join(event.name)) |
#23
|
|||
|
|||
#24
|
|||
|
|||
Thanks, lewispm!
Like several other scripts that I've seen, this will run comskip on all new recordings, even those on channels with no commercials (HBO, PBS, ...). Is there any way to know, other than from inside sage, what channel a recording came from? I guess there's no problem just running comskip anyway, other than a few wasted watts, but it would be nice to be able to be more selective. Has anybody had issues with comskip finding "false positive" commercials on shows where no commercials exist? |
#25
|
|||
|
|||
Quote:
But if you want to be more selective about which recordings get comskip run on them, then SJQ can definitely help with that. The task client will also run on Linux so you can use a Linux client to run comskip tasks.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#26
|
|||
|
|||
you can also query the filename against a webservice as well.
B
__________________
Running SageTV on unRAID via Docker Tuning handled by HDHR3-6CC-3X2 using OpenDCT |
#27
|
|||
|
|||
Quote:
Aside from the suggested SJQ, the only way I can think of selectively running comskip would be recording in different directories (I don't think this is possible), or creating symlinks to a separate, monitored directory, from only those files you want to run comskip on. If you are parsing the name of the file to make the decision, that could be accomplished in this script, but it would probably be more work than its worth. |
#28
|
|||
|
|||
Quote:
Drew Code:
#!/usr/bin/perl sub commercial_free { $file=$_[0]; $url="http://127.0.0.1:8080/sage/DetailedInfo?FileName=" . $file; use LWP::UserAgent $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => $url); $req->authorization_basic('sage', 'frey'); $r = $ua->request($req)->as_string; # Look for a string which identifies a show as commercial free. For # me, I just look for shows recorded on WUNC, my local PBS affiliate $i = index($r, "WUNC"); if ($i > 0) { # print "$file is a PBS show\n"; return 1; } # print "$file is not a PBS show\n"; return 0; } ### CHANGE THESE VALUES FOR YOUR SYSTEM # You have to use 4 \'s per one /, since perl changes \\\\ to \\ # and shells change \\ to \ #$inifile = "Z:\\\\usr\\\\local\\\\etc\\\\comskip.ini"; @directories = qw (/var/media/tv); #@directories = qw (/tmp/tv); foreach(@directories) { $dir=$_; opendir(DIR, "$_"); @files = readdir(DIR); closedir(DIR); foreach $file (@files) { if ($file =~ /mpg/) { $comskip_file = $file; $comskip_file =~ s/\.mpg/\.txt/; $exists = 0; foreach $name (@files) { if ($name eq $comskip_file) { $exists = 1; break; } } if (! $exists) { $pathname_mpg = $dir . "/" . $file; if (!commercial_free($pathname_mpg)) { print "Will comskib $file ($comskip_file missing)\n"; system "(cd $dir ; wine comskip $file )\n"; } else { print "Will create .txt file $comskip_file\n"; system ("cd $dir; touch $comskip_file\n"); } } } else { if ($file =~ /\.edl$|\.txt$/) { # look for comskip .txt or .edl files left over after .mpg file has # been deleted. These seem to mainly come from live tv. $mpg_file = $file; $mpg_file =~ s/\.[et][xd][tl]/\.mpg/; $mp4_file = $file; $mp4_file =~ s/\.[et][xd][tl]/\.mp4/; $avi_file = $file; $avi_file =~ s/\.[et][xd][tl]/\.avi/; $exists = 0; foreach $name (@files) { if ($name eq $mpg_file || $name eq $mp4_file || $name eq $avi_file) { $exists = 1; break; } } if (! $exists) { $pathname = $dir . "/" . $file; print "mp4 = $mp4_file"; print "mpg = $mpg_file"; print "rm $pathname\n"; unlink $pathname; } } } } } |
#29
|
|||
|
|||
The new script (link above) now has the ability to load the CPU based on file type. TS files require more CPU that MPEG-2 files for instance.
B I'll have to add in the web lookup feature though.
__________________
Running SageTV on unRAID via Docker Tuning handled by HDHR3-6CC-3X2 using OpenDCT |
#30
|
|||
|
|||
I installed jetty and sagex.api from jreichen and stuckless. I chose curl to parse because it is standard on OS X (my script can run on that platform too)
Using that I can determine the channel id fairly easily. Code:
curl --user user:pass --silent http://localhost:8080/sagex/api?c=GetMediaFileForFilePath\&1=$VIDEO | grep AiringChannelName | cut -d[ -f3 | cut -d] -f1 New variables will be:
I would be open to further enhancements as well such as being able to specify a comskip ini on a per show/channel basis which would help for tuning specific shows Thoughts? B
__________________
Running SageTV on unRAID via Docker Tuning handled by HDHR3-6CC-3X2 using OpenDCT |
#31
|
|||
|
|||
I don't mean to hijack and if you tell me to I'll shut up and move on, but is there something about SJQ that is preventing you from using it? If so, I'd really like to know if it's something I could address. It seems to me you're writing scripts to parse out show info to help make decisions on what gets processed. SJQ does it already and all the hard work of having to parse out details to make decisions is done for you. You want to comskip everything, but stuff from PBS and HBO? The ruleset for SJQ can be as simple as this:
Code:
if [IsTV == true && IsScheduledRecording == true && ChannelName !% "HBO.*|WPBS" && FileExists != "%d%/%p%.edl"] { COMSKIP } Then configure a task client to run comskip for the COMSKIP task: Code:
COMSKIP { :CPU "LOW" /usr/local/bin/comskip "%c%" }
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#32
|
|||
|
|||
Well honestly I never looked at it. Off the top after skimming the docs (still learning to read you see)
Given the last is only mildly useful to me, but I do post this on my blog as well. B
__________________
Running SageTV on unRAID via Docker Tuning handled by HDHR3-6CC-3X2 using OpenDCT |
#33
|
|||
|
|||
Quote:
Yes. SJQ supports multiple, distributed clients and clients can run multiple tasks simultaneously.[*]Support throttling of executions based on file type? Yes, sort of. You can assign CPU priority to defined tasks. If you defined an MPG comskip task and a TS comskip task then you could set the CPU priority to be lower for the TS task (if that's what you're getting at?).[*]Clean up when a media file has been deleted? Yes, there is a built in file cleaner thread. You can tell it to do things like "delete *.edl files when there is no corresponding *.ts or *.mpg file to go with it."[*]Run without SageTV? The SJQ server must run within SageTV (and it actually runs within the Jetty plugin), but the task client does not run within Sage/Jetty, it's a completely standalone self contained package. Run it on the Sage host or any other host - it doesn't need Sage at all - the task client only talks to the SJQ server looking for work to do. Once it gets work it does it and reports back to the server.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#34
|
|||
|
|||
Can SJQ determine if preexisting tasks were running and delay execution until tasks complete? I have 7 tuners; if all 7 start recording at once or within 30 minutes, how is that handled for an external application like comskip? Would it fire off 7 comskips regardless?
You say you can affect prioritization, you're executing threads at a lower priority via what mechanism? My script or most other scripts on this page are independent of SageTV. Granted there is little value on these forums regarding that aspect, but there is still value outside. B
__________________
Running SageTV on unRAID via Docker Tuning handled by HDHR3-6CC-3X2 using OpenDCT |
#35
|
|||
|
|||
Quote:
Quote:
Quote:
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#37
|
|||
|
|||
I tried running comskip with SJQ and it works, though I have a couple of questions / issues.
First, in order to help the next person, here's what I did. In SJQ, I entered the following rule: if [IsTV == true && IsScheduledRecording == true && ChannelName !% "KQED.*|KTEH.*|KRCB.*|WORLD|CSPAN.*|CALCHAN.*|EDAC.*|KVIE.*|STARZ.*|STZ.*|HBO.*|.*MAX.*|SHO.*"] {I also set the file cleaner to delete files with extensions "edl|log|txt|logo.txt", if there's no .mpg or .ts present. Then I started SJQC: cd /opt/sagetv/sjqcand entered the following into it: :MAXPROCS 2When I run the queue, the right stuff gets put on to the active queue, and it runs, and it works. As I specified, it runs two comskips at a time (using 2 cores of my quad-core CPU). The old .edl and other files all get nicely deleted. The ability to queue all this work is really great! The .mpg's go really fast - about 90 seconds for a one hour show. The .ts files take much longer - 20-90 minutes for an hour show. CPU is an AMD Phenom II 905e X4. Because of the time discrepancy, I don't care about the loading that bcjenkins' script uses. The .mpg's are in and out so fast it doesn't matter. Several issues / questions
|
#38
|
||||
|
||||
I'll briefly address this post in this thread, but after this all future questions/posts about SJQ should not be hijacking this thread, but rather should be posted in the SJQ thread. Maybe Opus4 will be kind enough to merge the last post and this reply into that thread?
Quote:
Quote:
Quote:
Quote:
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#39
|
|||
|
|||
Thanks, slugger!
|
#40
|
||||
|
||||
Please tell me Wine is not the only way to get commercial skip on Linux. There is no way I am installing wine on my sagetv server. (Nothing against Wine, and I'm running it on another computer...)
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|