SnapStream Forums

Go Back   SnapStream Forums > SnapStream Discussion
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-11-2004, 12:59 AM
Registered User
 
Join Date: Sep 2003
Posts: 196
Automatically cut commercials! Cutads script posted here.

Hello, fellow SnapStream users.

EDIT: This has been superceded by Version 2, posted in this thread: http://discuss2.snapstream.com/vb/sh...threadid=12421

SnapStream Beyond TV 3.4 (formerly PVS) introduced SmartChapters, which detects the location of commercials. A natural extension of this would be to automatically cut the commercials from the recording, to save disk space make it even more convenient to watch recorded shows.

Introducing cutads.pl
If you store your videos in Windows Media (WMV) format, here is a solution for you. I have written a Perl script, cutads.pl, which parses the .chapters.xml file in which Beyond TV stores the chapter markers, then constructs the command line arguments necessary to make the freeware asfcut tool remove the commercials from the video!

Windows Media Only
The asfcut tool only supports WMV format, so this method does not currently work if you use MPEG-2 or DiVX for your Beyond TV shows. However, if you know of any command line tools similar to asfcut that works on those formats, the Perl script could be modified easily enough.

Requirements
Because this is a Perl script, you need a Perl 5.8 interpreter. It needs to be at least version 5.8 because the .chapters.xml files are UTF-16 encoded, and earlier versions of Perl did not handle unicode. I recommend the free Perl available from http://www.activestate.com (click Languages, ActivePerl, download). It should also work with the cygwin perl if your video file is in the current directory when you run it (to avoid Unix path character conflict). You also need to install the asfcut.exe command-line tool, available from http://www.radioactivepages.com/inde...tails.html</a>

Usage
You can also see the usage by running the script with no parameters: perl cutads.pl .

Examples:
perl cutads.pl -i MyMovie.wmv
Create a copy called MyMovie.wmv.tmp with the "chapters" removed.

perl cutads.pl -i MyMovie.wmv -o MyMovieCut.wmv
Same as above, but make the output filename be MyMovieCut.wmv.

perl cutads.pl -i MyMovie.wmv -start 130.5 -end 1734.0
The output file will cut 130.5 seconds from the beginning of the file and will end 1734 seconds (just under half an hour) into the file, plus trim the "chapters". This allows you to trim to show start & end. Unfortunately, you must enter these parameters yourself, because the real start and end of the show is not detected by Beyond TV.

License
A script this simple hardly needs a license . It is freeware, public domain. Do absolutely anything you want with it. Note that asfcut and Perl have their own license agreements.

Enjoy!
Please post comments and improvements.
Attached Files
File Type: txt cutads.pl.txt (4.6 KB, 189 views)

Last edited by Soundman; 01-27-2004 at 12:24 AM.
Reply With Quote
  #2 (permalink)  
Old 01-12-2004, 12:57 AM
Registered User
 
Join Date: Jan 2004
Posts: 251
this is great! would you mind posting a few more details? i've followed your instructions and maybe i need a reboot to get everything working but can you verify what i've done?

1 - i followed you instructions and dl'd activeperl and ran through the install.
2 - i dl'd the cutads.pl file. i placed in in the directory where my tv shows are stored and where the chapters XML file is located.
3 - i opened a DOS prompt in the dir where my tv shows are stored.
4 - ran the command:

D:\TV>perl cutads.pl -i Teen Titans-(How Long Is Forever)-2004-01-11-0.wmv
'perl' is not recognized as an internal or external command,
operable program or batch file.

i'm thinking perl isn't recognized b/c i didn't reboot after the install or maybe i have to define the perl path. i'm going to reboot and see if that resolves the issue.
Reply With Quote
  #3 (permalink)  
Old 01-12-2004, 01:13 AM
Registered User
 
Join Date: Jan 2004
Posts: 251
rebooted and perl is good to go. getting an error on line 90 of cutad.pl.

D:\TV>perl cutads.pl -i Teen Titans-(How Long Is Forever)-2004-01-11-0.wmv
Unknown open() mode '<:encoding(UTF-16)' at cutads.pl line 90.
Reply With Quote
  #4 (permalink)  
Old 01-13-2004, 09:04 PM
Registered User
 
Join Date: Sep 2003
Posts: 196
suprfli,

Quote:
D:\TV>perl cutads.pl -i Teen Titans-(How Long Is Forever)-2004-01-11-0.wmv
'perl' is not recognized as an internal or external command,
operable program or batch file.
2 things: First, put the full path to the perl.exe executable instead of just "perl". Secondly, since the video file name contains spaces, you have to put it in quotes.

Example:
Code:
C:\Program Files\Perl\bin\perl.exe cutads-pl -i "Teen Titans-(How Long Is Forever)-2004-01-11-0.wmv"
It looks like once you rebooted, the directory containing perl.exe got added to your search path, so you can just use "perl" by itself.

Quote:
D:\TV>perl cutads.pl -i Teen Titans-(How Long Is Forever)-2004-01-11-0.wmv
Unknown open() mode '<:encoding(UTF-16)' at cutads.pl line 90.
This sounds like you are not using the most recent version of perl. The ActiveState web site has both version 5.8.2 and 5.6.? available for download. You have to have 5.8.2.

To find out what you have, type:
Code:
C:\Program Files\Perl\bin\perl.exe -version
The first line of the output should be similar to:

Code:
This is perl, v5.8.2 built for MSWin32-x86-multi-thread
Also, make sure the filename is in quotes, as noted above.

I hope this helps!
Soundman

Last edited by Soundman; 01-13-2004 at 09:08 PM.
Reply With Quote
  #5 (permalink)  
Old 01-19-2004, 01:44 PM
Registered User
 
Join Date: Jan 2004
Location: Ottawa, Ontario
Posts: 11
Hi:

Can someone suggest a MPEG2 command line cutting tool? If such a thing exists, it would be fairly simple to modify the Perl script to drive it.
Reply With Quote
  #6 (permalink)  
Old 01-19-2004, 02:24 PM
Registered User
 
Join Date: Apr 2003
Location: St. Louis, MO
Posts: 97
Quote:
Originally posted by impeyr
Can someone suggest a MPEG2 command line cutting tool? If such a thing exists, it would be fairly simple to modify the Perl script to drive it.
I tried to find the same thing a few weeks ago, offering to write a program (in VB) to do the same thing, but nobody could really come up with anything. I got a link to a command-line based MPEG1 editor with some MPEG2 support, but it didn't work well enough.
Reply With Quote
  #7 (permalink)  
Old 01-19-2004, 10:51 PM
Registered User
 
Join Date: Sep 2003
Posts: 196
Lightbulb

Hi, All.

I have an update on my progress with the Cutads.pl script. I noticed that the trimmed file created by asfcut.exe loses the episode description and other meta data in Beyond TV's database. This is a major limitation, in my view.

So, I added code to copy the meta data by using Beyond TV's web server to GET the "Edit Show" page for the original recording, then POST that same data for the new, trimmed file.

I have all the guts of it working, but I need to clean it up and overcome one issue of timing. That is, you can't POST the meta data until Beyond TV has noticed the new file and added it to its database. This can take an unpredictable amount of time.

I plan to work this out and post a new version soon.

Still no word on an MPEG-2 or AVI tool, though.

Regards to all,
Soundman
Reply With Quote
  #8 (permalink)  
Old 01-20-2004, 01:26 AM
Guest
 
Join Date: Nov 2003
Posts: 498
was it mpgtx? http://sourceforge.net/project/showf...group_id=22678
Reply With Quote
  #9 (permalink)  
Old 01-20-2004, 08:52 AM
Registered User
 
Join Date: Apr 2003
Location: St. Louis, MO
Posts: 97
Quote:
Originally posted by _Shorty
was it mpgtx? http://sourceforge.net/project/showf...group_id=22678
Yeah, I tried that and the output wasn't very usable. If I recall correctly, BTV would play it, but you couldn't rewind/fastforward at all or it would lock up.
Reply With Quote
  #10 (permalink)  
Old 01-20-2004, 12:02 PM
Registered User
 
Join Date: Jan 2004
Location: Ottawa
Posts: 32
Send a message via ICQ to zealot
Quote:
Originally posted by impeyr
Can someone suggest a MPEG2 command line cutting tool? If such a thing exists, it would be fairly simple to modify the Perl script to drive it.
I do all of my avi/mpeg editing using mencoder (part of mplayer).

mencoder has a ton of options, but splitting is pretty straight forward. Searching on google should give you the options you need.

You might also want to check out ffmpeg and transcode (if you have a linux box availible).
Reply With Quote
  #11 (permalink)  
Old 01-20-2004, 04:08 PM
Guest
 
Join Date: Nov 2003
Posts: 498
does it do it via command line though, that's the question. There are plenty of user-controlled editors that will do the trick. The goal here is to find what that can simply be fed command line options to get the editing that you want done, done.
Reply With Quote
  #12 (permalink)  
Old 01-20-2004, 09:06 PM
Registered User
 
Join Date: Sep 2003
Posts: 196
Great! I just took a peek at mencoder, and it looks like it will work from the command line. I'm not sure if a Windows version is available, though.
Reply With Quote
  #13 (permalink)  
Old 01-21-2004, 07:09 AM
Registered User
 
Join Date: Jan 2004
Location: Ottawa
Posts: 32
Send a message via ICQ to zealot
yes, both of the apps i mentioned are command line based.

A couple of people have compiled mplayer for windows, and offer installers. Searching on google for "mplayer win32" should give you some hits.

Here's a link to one of the installers i found: http://www.christianroessler.com/mplayer.php

mencoder has a lot of options, but here are the flags you'll probably want to use to split the mpeg:

mencoder -ovc copy -oac copy -endpos hh:mm:ss

or

mencoder -ovc copy -oac copy -ss hh:mm:ss -endpos hh:mm:ss

-ss is the time you want to start the clip at
-endpos is how long you want the clip to be
Reply With Quote
  #14 (permalink)  
Old 01-21-2004, 09:15 AM
Registered User
 
Join Date: Jan 2004
Location: Ottawa, Ontario
Posts: 11
Good suggestion. I have used memcoder before under Linux (I run mythTV). Works well, pretty fast. If it does the trick under Windows this would be a good solution.

Now is there a way to run memcoder via BTV, via the delayed re-encoding feature (SmartChapters/SmartSqueeze)? Yes, we always want more.

I am very happy with BTV. I like mythTV too, but it takes more care and feeding, which is fine. The main problem with mythTV is the stored file format. The program produces a file format called Nuppelvideo (.nuv). Mplayer understands the format, and memcoder is able to transcode the format to other formats. Which is why I used memcoder.
Reply With Quote
  #15 (permalink)  
Old 01-21-2004, 10:31 AM
Registered User
 
Join Date: Jan 2004
Location: Ottawa, Ontario
Posts: 11
The mplayer package given above
(http://www.christianroessler.com/mplayer.php)
does not contain memcoder.

The following package does include memcoder,

http://mplayer.sunset-utopia.homeip.net/

I will check it out tonight, and report back.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically removing commercials from Mpeg files look30 Beyond TV and Beyond TV Link 4 02-28-2005 04:46 PM
Automatically cutting commercials in mpeg2? salama Beyond TV and Beyond TV Link User-to-User Troubleshooting & Support Forum 7 02-23-2005 08:13 AM
Remove commercials automatically Hipster421 Beyond TV and Beyond TV Link User-to-User Troubleshooting & Support Forum 11 01-11-2005 12:43 PM
Any way to automatically delete commercials? loudog3114 Beyond TV and Beyond TV Link User-to-User Troubleshooting & Support Forum 1 10-18-2004 12:42 PM
automatically cutting out commercials msgon2002 Beyond TV and Beyond TV Link User-to-User Troubleshooting & Support Forum 5 09-21-2004 06:56 PM


All times are GMT -6. The time now is 01:45 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0 RC1
©2004-2006 Snapstream Media