You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

EyeTV with Commercial Skipping HD DVR Server

I use EyeTV HD and Turbo.264 HD to record and transcode h.264 shows for playback on a Mac, Apple TV, iPad, iPhone. I also use a self-modified version of etvcomskip to detect and mark commercials, which are then automatically skipped at playback. This makes tv viewing a lot more pleasurable and efficient, and is especially helpful controlling advertiser access to children. In case this is useful to others, I've outlined the steps here:


  1. Eric Kaashoek's website Comskip and download his HD-capable Comskip software. "Commercial" commercial-skippingcompanies (ReplayTV, TiVo, Dish, etc.) are quickly sued out of existence or into submission, even if they simply provide a basic "30-second skip" feature. Comskip is open source beerware that you can download, install, and use yourself, and you can't sue anyone for publishing source code. And rather than providing a simple 30-second skip feature, it detects, marks, and provides that capability for automatic commercial skipping.
  2. Comskip a Windows executable, so you'll need WINE (WINdows Emulator) on OS X to run it. First, download and install Xcode (free from the Apple App store), then download and install and install Macports, then in Terminal, run "sudo port selfupdate; sudo port install wine-devel". Finally, make sure that /Applications/Utilities/X11.app is added to your list of applications to run at login (WINE uses X11 to display Windows windows). Yes, this is windows emulation, but on a half-decent box you'll see that commercial skipping runs at around twice real-time for h.264 HD recordings.
  3. Download and install etvcomskip (and PyeTV if you want EyeTV to work with Front Row). The 2010 version of etvcomskip doesn't work with Comskip's latest HD capabilities, and the latest Comskip mpeg libraries do not allow live tv processing, so install these files to get everything working. Once you done this, you'll have a commercial-skipping HD DVR box on your Mac that can stream to Apple TV, iOS, or export to iTunes.

Comskip software

This lives in the directory /Library/Application Support/ETVcomskip.


Edit the file ./comskip/comskip.ini to use these HD-tuned settings, tailored for US cable:


detect_method=127;1=black frame, 2=logo, 4=scene change, 8=fuzzy logic, 16=closed captions, 32=aspect ration, 64=silence, 128=cutscenes, 255=all
max_avg_brightness=21;maximum average brightness for a dim frame to be considered black (scale 0 to 255) 0 means autosetting
non_uniformity=50; Set to 0 to disable cutpoints based on uniform frames
max_volume=20; any frame with sound volume larger than this will not be regarded as black frame
logo_at_bottom=1; Set to 1 to search only for logo at the lower half of the video, do not combine with subtitle setting
intelligent_brightness=1; Set to 1 to use a USA specific algorithm to tune some of the settings, not adviced outside the USA

volume_slip=150

output_dvrmstb=0; Set to 1 if you're running DVRMS-Toolbox
live_tv=0; set to 1 if you use parallelprocessing and need the output while recording
live_tv_retries=4; change to 16 when using live_tv in BTV, used for mpeg PS and TS


Edit the file ./MarkCommercials.app/Contents/Resources/MarkCommercials.py to use WINE to run comskip.exe nicely. Grep for these changes:


EyeTV.launch()


msg = 'Error: unable to communicate with %s\n' % options.app


#cmd = '"/Library/Application Support/ETVComskip/Wine.app/Contents/Resources/bin/wine" "/Library/Application Support/ETVComskip/comskip/comskip.exe" --ini="/Library/Application Support/ETVComskip/comskip/comskip.ini" "%s"' % MpgFile

# MacPorts 64-bit wine

#cmd = '"/Applications/Wine.app/Contents/Resources/bin/wine" "/Library/Application Support/ETVComskip/comskip/comskip.exe" --ini="/Library/Application Support/ETVComskip/comskip/comskip.ini" "%s"' % MpgFile

cmd = '"/opt/local/bin/wine" "/Library/Application Support/ETVComskip/comskip/comskip.exe" --ini="/Library/Application Support/ETVComskip/comskip/comskip.ini" "%s"' % MpgFile


# nice the wine command

cmd = "/usr/bin/nice -n 14 " + cmd


EyeTV software

EyeTV uses the triggered AppleScripts RecordingStarted and RecordingDone in the directory /Library/Application\ Support/EyeTV/Scripts/TriggeredScripts. Open these using the AppleScript Editor and use these scripts instead. You will probably have to Save As... on your desktop, then copy the updated script back into the correct directory to avoid permissions issues.


RecordingStarted.scpt


on RecordingStarted(recordingID)

delay 10

-- comskip81 uses ffmpeg and does not support live tv; put this in RecordingDone.scpt

-- set cmd to "export DISPLAY=:0.0; /usr/bin/nice -n 5 '/Library/Application Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials' --log " & recordingID & " &> /dev/null &"

-- display dialog cmd

-- set cmd to "env > /tmp/etv_test.log &"

-- do shell script cmd


--disable this if you do not want a logfile written

write_to_file((short date string of (current date) & " " & time string of (current date)) & "Recording Started run for ID: " & recordingID & (ASCII character 13), (path to "logs" as string) & "EyeTV scripts.log", true)

end RecordingStarted


on write_to_file(this_data, target_file, append_data)

--from http://www.apple.com/applescript/sbrt/sbrt-09.html

try

set the target_file to the target_file as string

set the open_target_file to open for access file target_file with write permission

if append_data is false then set eof of the open_target_file to 0

write this_data to the open_target_file starting at eof

close access the open_target_file

return true

on error

try

close access file target_file

end try

return false

end try

end write_to_file

RecordingDone.scpt


-- Run the python MarkCommercials script for the given recording

-- this must be run with the RecordingStarted script

-- it will check if there were multiple PIDs for the recording and runs MarkCommercials for each pid

-- requires updated MarkCommercials which allows specifying the pid

-- by Ben Blake, September 2009


-- modified for latest Comskip, which cannot be run until after recording is finished; waits for Turbo.264 HD to stop running as well

-- S.T.Smith


global LogMsg


on RecordingDone(recordingID)


set ProcessName to "Elgato H.264 Decoder"

set DelayTime to 60

set MaxDelays to 4 * 60 -- four hours


-- delay until the process slows down or stops running

repeat MaxDelays times

delay DelayTime -- delay at least once to give it a chance to start

set pcpu to CPUPercentage(ProcessName)

if pcpu is equal to "" or pcpu < 2.0 then exit repeat -- break out of delay loop if it's not running

end repeat


delay 10

-- comskip81 uses ffmpeg and does not support live tv; take this from RecordingStarted.scpt

set cmd to "export DISPLAY=:0.0; /usr/bin/nice -n 5 '/Library/Application Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials' --log " & recordingID & " &> /dev/null &"

-- display dialog cmd

-- set cmd to "env > /tmp/etv_test.log &"

do shell script cmd


set LogMsg to ""

CheckMultiplePIDs(recordingID)


--disable this if you do not want a logfile written

if (count of LogMsg) > 0 then

write_to_file((short date string of (current date) & " " & time string of (current date)) & LogMsg & (ASCII character 13), (path to "logs" as string) & "EyeTV scripts.log", true)

end if

end RecordingDone


-- testing code: this will not be called when triggered from EyeTV, but only when the script is run as a stand-alone script

on run

tell application "EyeTV.app"

set rec to «class Unqu» of item 1 of every «class cRec»


my RecordingDone(rec)

end tell

end run


-- compute the percentage CPU used by ProcessName

on CPUPercentage(ProcessName)

set ProcessPS to do shell script ("ps -axwwc | grep '" & ProcessName & "' | grep -v grep || true")

if ProcessPS is not equal to "" then

set ProcessID to word 1 of ProcessPS

set ProcessPS to do shell script ("ps -xwwco pid,ppid,%cpu -p " & ProcessID & " | tail -1")

set ProcessCPU to word 3 of ProcessPS

return ProcessCPU as number

else

return ""

end if

end CPUPercentage


on CheckMultiplePIDs(recordingID)

--check if there are multiple Video PIDs in the file


tell application "EyeTV.app"

set input_text to my read_from_file((path to "logs" as string) & "ETVComskip" & ":" & recordingID & "_comskip.log")

if (count of (input_text as string)) > 0 then

set logdata to every paragraph of input_text

set logdata_lastrow to (item ((count of logdata) - 1) of logdata) as string


if (items 1 thru 19 of logdata_lastrow) as string = "Video PID not found" then

--multiple Video PIDs, rerun MarkCommercials until successful


set recrdingIDInteger to recordingID as integer

set rec to «class cRec» id recrdingIDInteger

set LogMsg to "RecordingDone found multiple PIDs for recording ID: " & recordingID & ", Channel " & («class Chnm» of rec) & " - " & («class Titl» of rec)


set PIDs to (items 44 thru ((count of logdata_lastrow) - 2) of logdata_lastrow) as string

set delims to AppleScript's text item delimiters

set AppleScript's text item delimiters to ", "

set PID_List to {}

set PID_List to every word of PIDs

set AppleScript's text item delimiters to delims


repeat with pid in PID_List

my launchComSkip(recordingID, pid)

repeat while (my mcIsRunning())

delay 5

end repeat

end repeat


end if

end if

end tell

end CheckMultiplePIDs


on read_from_file(target_file)

--return the contents of the given file

set fileRef to (open for access (target_file))

set txt to (read fileRef for (get eof fileRef) as «class utf8»)

close access fileRef

return txt

end read_from_file


on write_to_file(this_data, target_file, append_data)

--from http://www.apple.com/applescript/sbrt/sbrt-09.html

try

set the target_file to the target_file as string

set the open_target_file to open for access file target_file with write permission

if append_data is false then set eof of the open_target_file to 0

write this_data to the open_target_file starting at eof

close access the open_target_file

return true

on error

try

close access file target_file

end try

return false

end try

end write_to_file


on launchComSkip(recID, pid)

if pid = "" then

set cmd to "export DISPLAY=:0.0; /usr/bin/nice -n 5 '/Library/Application Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials' --force --log " & recID & " &> /dev/null &"

else

set cmd to "export DISPLAY=:0.0; /usr/bin/nice -n 5 '/Library/Application Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials' --force --log " & recID & " --pid=" & pid & " &> /dev/null &"

end if


do shell script cmd

end launchComSkip


on mcIsRunning()

set processPaths to do shell script "ps -xww | awk -F/ 'NF >2' | awk -F/ '{print $NF}' | awk -F '-' '{print $1}' "

return (processPaths contains "MarkCommercials")

end mcIsRunning

<Links Edited By Host>

Mac mini Server (Mid 2010), Mac OS X (10.7.4), Lion Server, EyeTV HD, Turbo.264 HD

Posted on Jun 4, 2012 7:57 AM

Reply
144 replies

Dec 5, 2015 1:46 PM in response to essandess

Clean install on Mavericks...


I am still trying to get comskip working on a clean install of Mavericks. Following the link essandess provided for the mp4v2, it appears that this should now work under Mavericks 10.9 and Xcode 5.0, but I cannot seem to figure it out.


Would someone be so kind as to provide a new recipe starting from scratch how we can get comskip working on a clean install of Mavericks? I would really appreciate it. Manually marking the commercials has been a real PITA!


<Link Edited By Host>

Dec 5, 2015 1:47 PM in response to Niccum

I have the following versions installed:


XQuartz 2.7.5 (xorg-server 1.14.4)

Xcode 5.0.2 (5A3005)

wine 1.7.9

Macports 2.2.1

Python 2.7.5

mp4v2 2.0.0_0


comskip81_058_donators


I tried to run MarkCommercials in batch mode to mark existing recoprdings. Seemed to find one to mark, but ended up having a window stating "wine configuration is being updating" and it hung up there. Now it just says


bash-3.2$ /Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials all

MarkCommercials 0.4.0



1. Processing "Once Upon a Time" on [KVUE HDTV] channel [24-1]...

Channel: 24-1 , not skipped

Title: Once Upon a Time , not skipped

Station name: KVUE HDTV , not skipped

Error: accessing 0000000018306318.edl

(2, 'No such file or directory')


Real Time update...

I just removed the .wine directory

rm -rf .wine

ran sudo port install winetricks

ran winetricks (this gave me errors about a missing file and tried to install a fix, but seemingly failed)

re-ran MarkCommercials

and it worked! Now hopefully it works as I record in EyeTV and not just in batch mode.

<Links Edited By Host>

Jan 14, 2014 5:56 PM in response to essandess

Hello - I have tried for a couple of months to get this program installed and working. I finally have it installed (I think) but it is not marking commercials. I set EyeTV to record manually (not sure if this matters) and when go to edit the show, I don't see anything marked. There are no errors that I'm aware of. I have the HD version of comskip. Can someone help me troubleshoot this problem? Thanks

Jan 14, 2014 6:30 PM in response to tomar012

Do you know how to use the Console application (located in Utilities)?


Running Console, under "Files", there should be "EyeTV scripts.log" and a folder named "ETVComskip".


The "EyeTV scripts.log" should let you know if EyeTV is initiating a call to the "RecordingDone.scpt" script, and if so it should give you a numerical identifier of the file being processed.


Inside the "ETVComskip" folder there should be two logs associated with the numerical file identifier. You should see "nnnnnnnnn.log" and "nnnnnnnnn_comskip.log" (where "nnnnnnnnn" is the numerical file identifier).


The first log item is generated by ETVComskip (running under OSX as a Python script). It shows the progress of setting up and running the actual "comskip" program (which runs under Wine, since Comskip is a Windows app). If Comskip finds commercials, it will be indicated in this log file.


The second item is generated by "comskip" itself, running under Wine. It will show you a log of the actual comskipping process, and if commercials were found, it will indicate so.


So the first thing to do is see if you have these log files. If not, find out why. If so, examine their contents to see if you can get a clue as to why you aren't having success.


One thing I might mention is that I've had issues with some of the later Comskip builds under EyeTV. You might try an earlier one to see if it functions any better for you (I've had good luck with comskip81_052_donators. Later ones have not worked wellfor me. comskip81_058_donators seems to solve some EyeTV issues, but not all of them).


See if these steps help and report back.

Jan 15, 2014 5:28 PM in response to chicodaman

chicodaman wrote:


The "EyeTV scripts.log" should let you know if EyeTV is initiating a call to the "RecordingDone.scpt" script, and if so it should give you a numerical identifier of the file being processed.



The EyeTV scripts.log shows the following:


1/11/14 8:16:54 PMRecording Started run for ID: 411182203

1/11/14 8:51:50 PMRecording Started run for ID: 411184299

1/12/14 5:05:09 PMRecording Started run for ID: 411257099

1/14/14 7:33:56 PMRecording Started run for ID: 411438826

1/14/14 7:53:59 PMRecording Started run for ID: 411440029


There doesn't seem to be a call to RecordingDone.scpt. If this is true, I suspect this is my first problem.


I didn't see any obvious errors in the nnnnnnnnnn.log file. "The Error Code is: 0, 0x0". It also said "No commercials found by comskip"


The nnnnnnnnnn_comskip.log files had the following lines at the end:


Commercials were not found.

[h264 @ 00198460] Missing reference picture, default is 0

[h264 @ 00198460] decode_slice_header error


I am using comskip81_056_donators but maybe I'll try comskip81_058_donators.


BTW - did you make all of the updates to the various files as suggested by the OP?


Thanks for your help. I've already learned new things!

Jan 15, 2014 10:06 PM in response to tomar012

The EyeTV scripts.log shows the following:


1/11/14 8:16:54 PMRecording Started run for ID: 411182203

.....

There doesn't seem to be a call to RecordingDone.scpt. If this is true, I suspect this is my first problem.


Actually, the call to RecordingDone.scpt is working, or else you wouldn't be getting this log output. The output occurs as a result of the script. If you know, or are willing to learn a bit of, Applescript, you can open the RecordingDone.scpt script and see what it does. Anyway, that part of your setup is working.


I didn't see any obvious errors in the nnnnnnnnnn.log file. "The Error Code is: 0, 0x0". It also said "No commercials found by comskip"


The nnnnnnnnnn_comskip.log files had the following lines at the end:


Commercials were not found.

[h264 @ 00198460] Missing reference picture, default is 0

[h264 @ 00198460] decode_slice_header error


That looks ok. Comskip is running and outputting a log file. The only thing is that Comskip isn't finding any commercials.


Why no commercials? Dunno. You might try some different source videos to be sure there actually are findable commercials. Or you can go to the Comskip website and look at "Tuning Comskip", which tells how to play with the parameters in the file "comskip.ini" to help comskip properly identify commercials.


However, given a commercial-laden source video, Comskip usually finds at least some, if not all, of the commercials. If you've edited the "comskip.ini" file to output a verbose log file ("verbose=10", I think), that log file will appear inside the eyeTV package as "nnnnnnn.log" (control-click on the EyeTV video file --> "Show Package Contents").


Check that comskip log file and see if comskip has identified any "blocks". Comskip first identifies "blocks", which are potential commercials, then uses logic to decide if they are indeed commercials.


You'll see something like this:


(...previous stuff deleted...)

Logos detected on the following frames

--------------------------------------

Logo start - 4441 end - 20238 length - 0:08:47.09 before:21.6 s after:9.2 s

Logo start - 27699 end - 50485 length - 0:12:40.29 before:23.2 s after:9.4 s

Logo start - 55742 end - 56053 length - 0:00:10.37 before:8.9 s after:11.2 s

Joining blocks 25 and 26 at frame 42276 because they both have a logo.

Joining blocks 24 and 25 at frame 38996 because they both have a logo.

(... etc. ...)


If it's finding blocks, that's a good sign. If not, something's wrong.


In the meantime, a simple thing to try would be to install the ETVcomskip version _052 just to make sure that you're not experiencing the problems I've had with later versions and EyeTV files. It's worth a try at this point, since your install appears to be ok.


If that doesn't work, since Comskip is running ok and producing log files, you can go to the Comskip website and ask for detailed help. Search the forum before posting, maybe someone has already described and resolved an issue similar to yours. On the top of the Support forum here is a sticky post that describes what information the Comskip author, Erik Kaashoek, requires to give assistance. He'll want to see the comskip log file from inside the EyeTV file package. He's not a Mac guy so he won't help you with anything but comskip itself (remember, ETVComskip runs comskip on the Mac under Wine, a Windows emulator).


It seems like a lot of work, I know, but it's worth it when you get Comskip running well. Good luck, let us know how things go....

Jan 16, 2014 10:15 PM in response to tomar012

Cool! Have fun. You can tune the comskip.ini file for improved commercial detection, if necessary, and play with the "RecordingDone.scpt" file to have it do additional tasks, like use different comskip.ini files for different channels, or export the skipped files and markers for use in players such as XBMC, etc. Search around for examples. Glad you got it to work....

Jan 19, 2014 5:42 AM in response to chicodaman

FYI, I recently learned that the older mid-2010 Mac Minis are cable of using 16 GB with recent OS X upgrades. The original limit was 8 GB, which does limit performance. This makes a big difference for a box that's constantly recording/transcoding/marking commercials. A quadcore i7 is much more performant now, but then so will be the next model with DDR4 on the horizon.


Google is your friend—you're looking for the PC3-8500 DDR3 1066MHz SO-DIMM, and make sure you've correctly matched hardware. I personally recommend OWC.


And FWIW, here's my comskip.ini diffs for 81_058 and U.S. basic cable:


$ diff comskip.ini comskip.ini.orig

2c2

< detect_method=127 ;1=black frame, 2=logo, 4=scene

change, 8=fuzzy logic, 16=closed captions, 32=aspect ration, 64=silenc

e, 128=cutscenes, 255=all

---

> detect_method=43 ;1=black frame, 2=logo, 4=scene

change, 8=fuzzy logic, 16=closed captions, 32=aspect ration, 64=silenc

e, 128=cutscenes, 255=all

19c19

< logo_at_bottom=1 ; Set to 1 to search only for l

ogo at the lower half of the video, do not combine with subtitle setting

---

> logo_at_bottom=0 ; Set to 1 to search only for l

ogo at the lower half of the video, do not combine with subtitle setting

23c23

< intelligent_brightness=1 ; Set to 1 to use a USA specifi

c algorithm to tune some of the settings, not adviced outside the USA

---

> intelligent_brightness=0 ; Set to 1 to use a USA specifi

c algorithm to tune some of the settings, not adviced outside the USA

76,79c76

< windowtitle="Comskip - %s"

< ; http://www.kaashoek.com/comskip/viewtopic.php?f=1&t=1130

< thread_count=2 ; multi-threaded proces

sing

<

---

> windowtitle="Comskip - %s"

\ No newline at end of file

Dec 5, 2015 1:48 PM in response to essandess

Ok, I just donated to comskipper. I've used eyetvcomskip for a few years and should have donated earlier.


With that said, I'm a little confused about what I need to do now. I've been reluctant to rebuild by Mac Mini DVR setup with EyeTV because I was afraid I wouldn't be able to get it working again. Well, it wasn't working all that well at the end so I pulled the trigger. So I have a clean install of OSX 10.9, the newest build of EyeTV3 and that is about it (Handbrake, Subler, Flash are the only additions).


Do I need to install all the additional components that Niccum listed above?


XQuartz 2.7.5 (xorg-server 1.14.4)

Xcode 5.0.2 (5A3005)

wine 1.7.9

Macports 2.2.1

Python 2.7.5

mp4v2 2.0.0_0


comskip81_058_donators


I didn't have all of that running on my old system I don't think. Just XQuartz and Xcode. Yes, I'll go back through the 7 pages of this thread to find somebody that has given a step by step guide, but most people aren't starting from scratch and I'd like to do a very generic install and configuration of this, then I can tweak and tune it later.


<Links Edited By Host>

Dec 5, 2015 1:48 PM in response to essandess

When I upgraded to 10.9 compskip stopped working. I just got it working again. I first installed the new MacPorts - but that wasn't enough for me to get commercial-marking to work. I had to reinstall winetricks, too.


In terminal:


# go to your home directory

cd ~


# make a backup of your current .wine directory, just in case

cp -r .wine .wine_backup


# remove the .wine directory

rm -rf .wine


# reinstall wine

sudo port install winetricks



This last step took longer than I thought it would while the program went and found and downloaded all the necessary, latest files and all the latest dependencies.


I left EyeTV alone for a few days and the new recordings now have correctly-marked commercials. I haven't re-ran MarkCommercials.py (or whatever it's called) to apply this to old recordings, but there's no reason to think it wouldn't work like a fresh recording.


Cheers,

S


<Edited by Host>

EyeTV with Commercial Skipping HD DVR Server

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.