comskip ordeal: player with playback speed adjustment?

Here you can ask your questions on how to use Comskip for the detection of commercials. Also questions on how to remove commercials are welcome
Post Reply
dsfwe33
Posts: 3
Joined: Mon Feb 10, 2014 12:54 am

comskip ordeal: player with playback speed adjustment?

Post by dsfwe33 »

I record a lot of news programming and my requirements seem basic:

1) Skip/remove commercials automatically
2) Watch with a player that is capable of 2x playback of .ts files (recorded by mediaplayer)

Here's what I've tried:

_COMCLEAN_
I have comskip generating the edl files automatically with mediaplayer. But can't find a good solution to actually watch the videos. My first attempt was to say 'hey, let's just cut them out with comclean.' After trying to get comclean 1, and 3 (didn't try 2 or 4) working, none of them can deal with mediaplayer's .ts files. comskip1 complains that it's not a valid 'mpeg', comskip3 just outputs the audio. I found a batchfile where soemone tried something similar to fix the batch file:

http://forum.team-mediaportal.com/threa ... ipt.67531/

_COMCLEAN + MPEG2REPAIR (+ MPEG2REPAIRHELPER)_
But like mediaportal, this program (mpeg2repair), seems like it was coded by a 4 year old. You MUST use a gui to make it work, and although there are other scripts that try and work around this showstopper bug (by trying to hide the window when it pops up), it always splashes something on the screen. This is not a viable option for someone that does as much recording as I do. And I'm not even sure why the ts stream needs to be 'fixed', but it wouldn't surprise me with all the design limitations of mediaportal.

_TRANSCODE THE TS FILES FROM MEDIAPORTAL_
I REALLY don't want to do this for something as easy as snipping out/skipping commercials

_SEARCH FOR OTHER PLAYERS_
So then I said, 'Ok, no need to actually delete the commercials, if I can find a player that supports both edl and 2x playback speed (with pitch correction). The entire reason I tried to go the comclean route is because VLC doesn't support edl (and I use vlc for the 2x playback). So I surveyed

mediaplayer - no plans to implment such a feature: http://forum.team-mediaportal.com/threa ... tch.38809/
xbmc - not only are the devs not planing to implment a feature, but they have hard-headed resistance to it. Oh well, you know what they say, "Devs are the holiest of gods and can never make a mistake even when everyone wants something they dont want". I think they say that ;).
vlc - doesn't support edl, no one willing to work on it
bsplayer - no pitch correction on the 2x playback
smplayer - (mplayer frontend) doesn't handle mediaportals ts files well--can't get it to even show the whole file and the seek bar doesn't work well
mpui - (mplayer frontend) starts up in a different lanugage I've never seen and have no idea what to do next

Well, I'm giving up for now. If anyone has any suggestions, at all, I'd be happy to entertain them.

thanks!

jack
dsfwe33
Posts: 3
Joined: Mon Feb 10, 2014 12:54 am

Re: comskip ordeal: player with playback speed adjustment?

Post by dsfwe33 »

So although there might have been some way to salvage comclean with mediaportal ts files, I couldn't find it. My solution was to run a script remotely on my linux server (where the files are stored) to parse the edl file and run a few ffmpeg commands to cut and concatenate the non-commercial pieces. So for people in a similar situation you could do something similar and you can probably install python and ffmpeg for windows to get something similar working. But here are the scripts if someone else is interested:

PostProcessing.bat (to get it to work with mediaportal see here: http://forum.team-mediaportal.com/threa ... ost-682185 )

Code: Select all

@echo off

echo Postprocessing.bat invoked on %1 recorded from channel %2 >>postprocessing.log

Rem The part below can be used to not run Comskip on certain channels, please modify for your conveniance.

Rem list of channels to not run comskip on
Rem if "%2" == "27" goto eof
if "%2" == "13" goto eof

Rem this trick also makes it possible to have dedicated comskip.ini file for certain channels.
Rem if "%2" == "79" goto channel79
Rem if "%2" == "72" goto channel72
Rem if "%2" == "65" goto channel65
Rem use the default comskip.ini for all other channels
goto generic

REM for custom ini per channel
Rem :channel79
Rem comskip --ini=channel79.ini %1
Rem goto continue
Rem :channel72
Rem comskip --ini=channel72.ini %1
Rem goto continue
Rem :channel65
Rem rem This is an example of how to reuse a previously learned logo to prevent Comskip from learning the wrong logo
Rem comskip --ini=channel65.ini --logo=channel65.logo.txt %1
Rem goto continue

REM fix mpeg stream as per: http://forum.team-mediaportal.com/threads/my-ts-fix-clean-and-advert-comskip-removal-script.67531/
REM e:\somefiles\comskipclean\mpeg2repairHelper.exe %1 %1-fixed.ts

REM -t for ts stream
:generic
e:\somefiles\comskipclean\comskip -t %1
:continue

Rem Once the commercials have been identified you can run comclean to delete the commercials from the recording.
Rem Do this only when you are not using the Skip function in the GBPVR viewer.
Rem To enable comclean remove the word "Rem" from the following line.
REM e:\somefiles\comskipclean\comclean %1

REM cant get comclean to work, so run ffmpeg remotely on server to cut out commericals and concatinate segments
echo ssh user@server "python /media/storage1/software/workspace/transcodeBot/removeCommercials.py %1"
c:\cygwin\bin\ssh user@server 'python /media/storage1/software/workspace/transcodeBot/removeCommercials.py ""%1""'

:eof

removeCommercials.py -- python script to parse edl, clip ts, and recombine. (To run remotely with passwordless login set up private key authentication with ssh (using cygwin ssh))

Code: Select all

#!/usr/bin/python

# http://hackmemory.wordpress.com/2013/04/08/lightning-fast-video-splitting-script/

import sys
import os
import subprocess
import ntpath
import glob


storagedir = '/tv/'
filepath = sys.argv[1]
filename = ntpath.basename(filepath)
filebasename = os.path.splitext(filename)[0]
edlfile = filebasename + ".edl"
previousend = 0
count = 0

# clean up old files if they exist
for file in glob.glob(storagedir + 'part*.ts'):
    os.remove(file)

for line in open(storagedir + edlfile):
    print line

    times = line.split("\t")

    begin_second = times[0]
    end_second = times[1]
    action = times[2]

    duration = float(begin_second) - float(previousend)

    #skip the first line
    if count != 0:
        # clip from last commercial ending to this commercial beginning
        cmd = ['ffmpeg', '-i', storagedir + filename, '-vcodec', 'copy',
               '-acodec', 'copy', '-ss', str(previousend), '-t', str(duration),
               storagedir + 'part' + str(count) + '.ts']
        print cmd
        subprocess.call(cmd)

    previousend = end_second
    count += 1

# concatinate files
joinList = 'concat:'
for x in range(1, count):
    partFile = storagedir + 'part' + str(x) + '.ts'
    joinList += partFile

    if x < count - 1:
        print x
        print count
        joinList += '|'

concatcmd = ['ffmpeg', '-i', joinList, '-acodec', 'copy', '-vcodec',
             'copy', storagedir + filename + '_nocom' + '.ts']
subprocess.call(concatcmd)

# cleanup files
for file in glob.glob(storagedir + 'part*.ts'):
    os.remove(file)
# to remove the original file (the one with commericals)
#os.remove(storagedir + filename)
erik
Site Admin
Posts: 3369
Joined: Sun Aug 21, 2005 3:49 pm

Re: comskip ordeal: player with playback speed adjustment?

Post by erik »

Did you try ffplay?
Zoomplayer also can skip while playing.
dsfwe33
Posts: 3
Joined: Mon Feb 10, 2014 12:54 am

Re: comskip ordeal: player with playback speed adjustment?

Post by dsfwe33 »

ffplay doesn't have a gui, does it?

Zoomplayer was one of my next choices from wiki links, but from what I could tell it doesn't have 2x playback with pitch correction. I would check it out, but I like my solution better. I really love VLC, and I didn't like the prospect of having to use something bulkier, more bloated, worse designed, or have to pay for something. Now I can still use VLC and can skip all those annoying commercials.
Post Reply