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

Nov 16, 2012 8:31 PM in response to essandess

Thank you!


X windows was working fine, but my wine was not. I installed winetricks and ran winetricks -v (verbose) and found an identical problem here: http://code.google.com/p/winetricks/issues/detail?id=163


I also found a similar fix - removing and recreating my .wine directory in my home directory and re-running winetricks. Wine automatically sets up your new .wine directory and everything - awesome!


I tried comskip from the command line, identical to the command I pasted before and it is now busy analyzing the show I selected! 🙂 Next, I'll try and get everything automated with MarkCommericals.py, etc. I don't see why it won't work now.


Thanks again,

S

Nov 17, 2012 8:03 PM in response to essandess

Yep, now WINE is installed properly, the automation works too. It's beautiful.


Since EyeTV's 10-foot user interface is pretty dreadful and I use the AppleTV as my main media hub I use EyeTV's export feature routinely. The lack of a decent commercial skip (even 30 seconds forward!) was frustrating and this makes my evenings a lot more pleasant!


Thank you.


All the best,
S

Nov 18, 2012 5:24 AM in response to Ste88

Glad that it's working so well. I haven't tested this against an Apple TV setup and I expected it to work across various configurations, so it's nice to hear that it does.


And I know what you mean about EyeTV's UI!


But I really like their iPad app, and use it turn iOS devices into satellite TVs. The last feature missing from this commercial skipping setup is to have the EyeTV app use the mp4 chapters in its streming, the way iTunes sharing works.


If you find this code useful, the only thing I ask in return is to contact Elgato and make this feature request for their EyeTV app. Here's my request:


http://tickets.kb.elgato.com/?language=en-us


Dear Elgato,


This is a feature request for your iOS EyeTV app.


Would you please allow navigation using the embedded chapter markings in h.264 files, similarily to the functionality in iTunes Sharing?

Nov 19, 2012 9:25 PM in response to essandess

I believe that I've been properly following your steps for Moutain Lion, but I can't get ETVComskip to install. I've installed Xcode, Xquartz, and Macports and I've run "sudo port selfupdate" After that I get these two issues:


1. When I run "sudo port install wine-devel" I get these error messages: "Warning: The Command Line Tools for Xcode don't appear to be installed; most ports will likely fail to build. Warning: See http://guide.macports.org/chunked/installing.xcode.html for more information.

---> Computing dependencies for wine-develError: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?


2. When I run "Install ETVComskip" from the "ETVComskip-2.0.2-10.6" dmg I get the following pop-up error: "The operation couldn't be completed. (OSStatus error 100030.)"


Thanks for your help!


Chris

Nov 21, 2012 7:17 AM in response to chriser

Apparently Apple in its wisdom has removed basic command line executables from the latest Xcode rev. To troubleshoot general issues like this, just google the problem. In this case, "Xcode command line tools" leads to: https://developer.apple.com/downloads/index.action. So install the latest and try again. I don't know about your ETVComskip error—just make sure that you're using an admin account to install and if the problems persist after some reasonable sanity checks and googling, submit a ticket at the ETVComskip google code web page.

Jan 16, 2013 5:13 AM in response to bebopbillybobeep

I shoud mention that all of these files exist. I'm wondering if there is a permissions error?

I have two hard drives. One, a SSD, has the OS on it and the other, a HDD, has the User folders. Comskipper is installed on the OS drive in /LibraryApplication Support/, but my EyeTV recordings are stored in my user folder on the other drive.


ls -l /Library/Application\ Support/ETVComskip/ComSkipper.app/Contents/Resources/lib/python2.5/lib-dynload/ objc/_objc.so
-rw-r--r--@ 1 Jim macports 659852 May 26 2010 /Library/Application Support/ETVComskip/ComSkipper.app/Contents/Resources/lib/python2.5/lib-dynload/ objc/_objc.so
ls -l /usr/lib/libobjc.A.dylib
-rwxr-xr-x 1 root wheel 2486784 Nov 4 01:05 /usr/lib/libobjc.A.dylib

Jan 20, 2013 3:30 AM in response to bebopbillybobeep

This has to do with some Python version error on your system. It's tricky to troubleshoot unless your sitting at your box, but I'll give some background and a few pointers. ETVComskip comes with its very own Python executable, so you shouldn't even be seeing this error. Emphasis on "should." The upside should be that ETVComskip is robust to changes in Apple and Macports Python versions. I don't know why or if ETVComskip's Python should be calling the system library in /usr/lib.


Googling the error ("symbol not found" objc_sync_notify), shows that others have similar issues in Lion <http://lilypond.1069038.n5.nabble.com/Mac-OS-X-Lion-killed-LilyPond-tp70450.html>, though ETVComskip ran fine for me when I used Lion.


I'd suggest these actions:


0. Software update, and consider installing the apparently more robust Mountain Lion (though Lion should work fine with ETVComskip).

1. Reinstall ETVComskip from scratch.

2. Try the command line call


/Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials


That runs ETVComskip's python. Does that work?


4. Spend a little time searching for a fix online, googling error messages.

5. If you just can't get ETVComskip to run, post an issue on its google code page.

Jan 20, 2013 3:37 AM in response to bebopbillybobeep

Wait, it looks like you've installed an obsolete version of ETVComskip -- you should have python2.6 down in the guts, not 2.5. Here's what I see on my system:


$ ls -l /Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/Resources/lib

total 0

drwxr-xr-x@ 6 essandess staff 204 Jun 1 2010 python2.6


Download and Reinstall the latest ETVComskip and try again.

Dec 5, 2015 2:06 PM in response to essandess

I've released version 1.0rc2 with improvements for both functionality and performance. The latest version handles commercial skipping for EyeTV exports to the directory ~/Movies as well as to iTunes, uses the multi-threading capabilities of the latest releases of comskip, and improves the reliability of commercial skipping on older boxes (like my own) during back-to-back recordings.


Here's the new help string and changes. Edit to suite your particular configuration.


readme-and-install.sh

Installation:



2. Install Xcode from the App Store, the latest Xcode Command Line Tools from

https://developer.apple.com/downloads, and Macports from http://www.macports.org/.

For Mountain Lion, install Xquartz.


3. Install ETVComskip from code.google.com/p/etv-comskip/downloads/list.


4. Install Kaashoek's comskip files within the directory

/Library/Application\ Support/ETVComskip/comskip

Make sure that the ownership/group/permissions are set exactly the same

as the original ./comskip directory and files.


5. Download this zip file and check that your iTunes TV Shows directory

matches this setting at the beginning of ./MarkCommercials.py:

iTunes_TV_Shows = '~/Music/iTunes Media/TV Shows'

Edit ./MarkCommercials.py to match this, then run these commands as a sudoer:


# Necessary Macports

sudo port selfupdate

sudo port install wine-devel mp4v2


# Move these five files into their correct locations

sudo install -B .orig -b -m 0644 ./comskip.ini /Library/Application\ Support/ETVComskip/comskip/comskip.ini

sudo install -B .orig -b -m 0644 ./MarkCommercials.py /Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/Resources/MarkCommercials.py

sudo install -B .orig -b -m 0644 ./RecordingStarted.scpt /Library/Application\ Support/EyeTV/Scripts/TriggeredScripts/RecordingStarted.scpt

sudo install -B .orig -b -m 0644 ./RecordingDone.scpt /Library/Application\ Support/EyeTV/Scripts/TriggeredScripts/RecordingDone.scpt

sudo install -B .orig -b -m 0644 ./ExportDone.scpt /Library/Application\ Support/EyeTV/Scripts/TriggeredScripts/ExportDone.scpt


comskip.ini (this is for my old dual-core -- change to how many cores you wish to use)

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

thread_count=2 ; multi-threaded processing


ExportDone.scpt


-- EyeTV ExportDone script to use ComSkip to mark commercials in exports to iTunes and ~/Movies, and save exported file inode numbers as the text file filename.exported_inodes.txt for synchronization with MarkCommercials.py


-- 2013-01-29 1.0rc2: Handle exports to ~/Movies; Fix issues with multiple exports: extend iTunes delay, modify IsFileOpen to ignore Spotlight indexing, and use creation date


<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.