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

Oct 7, 2014 8:17 PM in response to essandess

Thanks for the quick response.


I thought this *had* to be the cause, but I installed them HD mods from the link as you suggested and used the bash script to copy the files to the right location, restarted everything and still my 32 minute TV shows are coming out at edited 19 minute shows on iTunes! Do you happen to know precisely where in the HD mods this behavior is modified so I can dig into the code and check?


Thanks,

S

Oct 8, 2014 7:05 AM in response to Ste88

Question for you Ste88: Are the files your'e talking about ones you are manually exporting after they've been recorded or the ones that EyeTV is exporting on it's own after it records the show? I've found that because of the way ETV does this, shows that it automatically exports work just fine, but ones I manually export have the commercials cut out.

Oct 8, 2014 8:05 AM in response to Brandonshire

shows that it automatically exports work just fine, but ones I manually export have the commercials cut out.


This is true for shows that must be transcoded, but if the transcoded show already exists, then all the Export command does is import the transcoded show into the iTunes library. At the time of transcoding, any .edl file present in the specific .eyetv directory will be honored by EyeTV and Turbo.264 and will delete content specified by the edit decision list.


To maintain all content with ETVComskip, you have to tell EyeTV to export programs to iTunes when they're recorded. There are a few ways to do this -- see the EyeTV Software Manual. EyeTV's and ETVComskip's automated scripting then records the show, transcodes the show (there is no .edl at this point so all content is kept), exports the show to iTunes, finds all the commercials in the show (which creates the .edl file), then updates the chapter markings of exported shows both in EyeTV and in iTunes. If you manually export a show that's already been transcoded, all content will be kept in the manual export because all the export does is a straight copy of an existing transcode into iTunes. Conversely, if you manually export a show for which no transcoded show exists, the show is first transcoded and the newly transcoded show and its iTunes export will delete the content specified by the .edl file created by ETVComskip.


A quick way to watch what's going on is to right-click the program in EyeTV, "Show in Finder", then right-click the EyeTV Show and "Show Package Contents". Another way is to open the show using Turbo.264, which will show any existing edit decision list. This is a good way to fine-tune edit decisions in general.

Dec 5, 2015 2:02 PM in response to Brandonshire

I haven't upgraded yet because of all the Server.app 4 bugs <OSX Yosemite Server 4.0 - webapps & SSL issues>. There is a release of Macports for Yosemite <www.macports.org/install.php>, so it will all come down to whether the essential ports (wine, mp4v) compile under the latest Xcode. Also note the Macports migration instructions <trac.macports.org/wiki/Migration>.


Please post if anyone sees any issues.


<Edited by Host>

Jan 29, 2015 6:42 AM in response to Brandonshire

I've upgraded to Yosemite 10.10.2 and actually see improved performance with the existing setup. The ComSkipper process used with the original configuration no longer hangs on launch is it does with Mavericks, and I haven't seen a single runaway wine process running comskip.exe.


To migrate the necessary Macports to Yosemite, follow the steps at the Macports migration wiki. Also, there's a relatively recent upgrade at the comskip donator's page.

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

Hoping someone can help me get up and running again. I've been running a mid-2010 Mac Mini HTPC with EyeTV and ETVComskip successfully since 2010. I only use ETVComskip to mark commercials. I then use EyeTV to trim/compact/convert to .mp4 before moving them to an external Unraid server for Plex playback. I haven't automated anything. I do not use a Elgato Turbo.


After upgrading to El Capitan I began having lots of issues. After a trip to the genius bar, I decided to install a SSD, upgrade the RAM to 8GB, and perform a clean install of El Capitan. It's been 5 years since I installed comskip successfully, and I'm having a hard time recalling how to get it done. I've been trying to get ETVComskip up and running the last three days with no success. The following is what I've done. I'd say I'm not much more than a novice at this stuff.



Downloaded the latest donator's version comskip81_088


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.


Installed ETVComskip-3.4-10.11


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.


Created new "comskip" folder in root/Library/Application\ Support/ETVComskip/comskip and copied the following files from donor's comskip81_088

  • comskip.dictionary
  • comskip.exe
  • comskip.ini
  • comskip.txt
  • comskipGUI.exe
  • ComskipINIEditor.exe
  • debugwindow.html
  • HideRun.exe
  • manual.html
  • PostProcessing.bat
  • readme.txt
  • tuning.html


The result is nada. EyeTv completes recording without any comskip commercial detection.


A couple things I've noticed:

  • Looking at the files on my old HD located in HD/Library/Application Support/ETVComskip, there was a copy of ComSkipper.app and MarkCommercials.app that I don't have on the new SSD after running the ETVComskip installer.
  • Additionally, on the old HD in HD/Library/Application Support/EyeTV/Scripts/TriggeredScripts there were copies of RecordingDone.Scpt and RecordingStarted.scpt. Both of these are on the new SSD after install as well as the ExportDone.scpt.
  • On the new SSD,
    • There is a copy of org.macosforge.xquartz.startx.plist in root/Library/LaunchAgents.
    • There is a copy of com.github.essandess.etv-comskip.comskipper.plist in User/Library/Application Support/LaunchAgents.
  • I have a copy of ETVComskip_h264_HD_mods-1.0rc2, but I'm not sure if I need to do anything with it. Do I need MarkCommercials.py?


Can anyone give me some ideas of what to check? Thanks in advance.


<Edited by Host>

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

I'm no longer able to pull up this thread: etv-comskip: Commercial Skipping for EyeTV on OS X, iOS, and tvOS

Clicking on the link gives me the following error:

Unauthorized

Access to this place or content is restricted. If you think this is a mistake, please contact your administrator or the person who directed you here.


I saw your previous response essandess, asking me to compare to github.***/essandess/etv-comskip/issues/62 and github.***/essandess/etv-comskip/issues/63. I will run through them and post the results here if the other thread is still unavailable.


<Links Edited By Host>

Dec 5, 2015 3:10 PM in response to the1greatgumbino

the1greatgumbino wrote:


I'm no longer able to pull up this thread: etv-comskip: Commercial Skipping for EyeTV on OS X, iOS, and tvOS

Clicking on the link gives me the following error:

Unauthorized

Access to this place or content is restricted. If you think this is a mistake, please contact your administrator or the person who directed you here.


I saw your previous response essandess, asking me to compare to github.***/essandess/etv-comskip/issues/62 and github.***/essandess/etv-comskip/issues/63. I will run through them and post the results here if the other thread is still unavailable.


Apple discussion mods are classifying this discussion, variously, as "nontechnical or off-topic" or, without a trace of irony, "advertising". You can decide which explanation to accept, and which thread to post to.


We removed your post etv-comskip: Commercial Skipping for EyeTV on OS X, iOS, and tvOS because it was nontechnical or off-topic. We understand wanting to share experiences, but these forums are meant for technical questions that can be answered by the community.

You can read our submission guidelines here:

Apple Support Communities - Terms of Use

https://discussions.apple.com/static/apple/tutorial/tou.html

We hope you’ll keep using our Support Communities forums. You can find more information about participating here:

Apple Support Communities - Tutorials

https://discussions.apple.com/static/apple/tutorial/index.html

If you have comments about any of our products, we welcome your feedback:

Apple - Feedback

http://www.apple.com/feedback



We’ve removed your post Re: EyeTV with Commercial Skipping HD DVR Server because it contained advertising. To read our terms and conditions for using the Communities site, see this page:

Apple Support Communities - Terms of Use

https://discussions.apple.com/static/apple/tutorial/tou.html

We hope you’ll keep using our Support Communities forums. You can find more information about participating here:

Apple Support Communities - Tutorials

https://discussions.apple.com/static/apple/tutorial/index.html


<Edited by Host>

Dec 5, 2015 6:19 PM in response to essandess

I have some of the information you've requested, but am coming up short at the MarkCommercials and Running ComSkipper by Hand steps if you can provide some guidance.


In response to github.***/essandess/etv-comskip/issues/62, here are my results:


I didn't have a .edl file, so I manually ran comskip:

total 4453680

-rw-r--r-- 1 user staff 3676 Dec 5 15:36 000000001c138b3d.eyetvp

-rw-r--r-- 1 user staff 106000 Dec 5 15:36 000000001c138b3e.eyetvi

-rw-r--r-- 1 user staff 2600 Dec 5 15:37 000000001c138b3e.eyetvr

-rw-r--r-- 1 user staff 2273944036 Dec 5 15:36 000000001c138b3e.mpg

-rw-r--r--@ 1 user staff 161146 Dec 5 15:37 000000001c138b3e.thumbnail.tiff

Comskip 0.81.089, made using ffmpeg

Donator build

39725 Frames Processed

Commercials were found.

total 4454912

-rw-r--r-- 1 user staff 3676 Dec 5 15:36 000000001c138b3d.eyetvp

-rw-r--r-- 1 user staff 66 Dec 5 15:56 000000001c138b3e.edl

-rw-r--r-- 1 user staff 106000 Dec 5 15:36 000000001c138b3e.eyetvi

-rw-r--r-- 1 user staff 2600 Dec 5 15:37 000000001c138b3e.eyetvr

-rw-r--r-- 1 user staff 501390 Dec 5 16:10 000000001c138b3e.log

-rw-r--r-- 1 user staff 117541 Dec 5 15:50 000000001c138b3e.logo.txt

-rw-r--r-- 1 user staff 2273944036 Dec 5 15:36 000000001c138b3e.mpg

-rw-r--r--@ 1 user staff 161146 Dec 5 15:37 000000001c138b3e.thumbnail.tiff

-rw-r--r--@ 1 user staff 6054389 Dec 5 15:37 000000001c138b3e.tiff

159.63 261.93 0

437.07 559.79 0

741.81 843.04 0

1101.70 1325.42 0


EyeTV Triggered Scripts:

total 224

-rw-r--r-- 1 root admin 62090 Dec 5 11:59 ExportDone.scpt

-rw-r--r-- 1 root admin 37272 Dec 5 11:59 RecordingDone.scpt

-rw-r--r-- 1 root admin 6320 Dec 5 11:59 RecordingStarted.scpt

I don't have the last line of output that yours does:

drwxr-xr-x+ 4 root wheel 136 Dec 7 2011 orig


MarkCommercials:


I can't figure out how to obtain the data that you're looking for here.

First, determine the EyeTV recording ID. Use

grep
to filter the output using the name of your show:

/Library/Application\ Support/ETVComskip/bin/MarkCommercials | grep Pocket

My filename is SEC Football Championship - Florida vs. Alabama.eyetv. I've tried inserting "SEC", "Football", "Alabama", etc. in place of "Pocket" below. The only data I get is:

Binary file (standard input) matches


Running ComSkipper by hand:

/Library/Application\ Support/ETVComskip/bin/ComSkipper

I get nothing when running this. Just a blank line. Let it run for 10 minutes before shutting the terminal window to cancel because "control+c" didn't do anything.


Status of the comskipper user launch daemon:

266 0 com.github.essandess.etv-comskip.comskipper

Dec 5, 2015 6:54 PM in response to the1greatgumbino

Looks like the compiled binaries run fine. What happens when you just run


/Library/Application\ Support/ETVComskip/bin/MarkCommercials


without filtering the output through grep?


Try recording a show, figure out its record id from the lhs of the MarkCommercials command, then run


/Library/Application\ Support/ETVComskip/bin/MarkCommercials --log 0123456789 <insert correct record id>


Does that work to mark commercials?

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.