Jump to content

Automated Commercial Removal from TV Recordings


PhilWhite

Recommended Posts

PhilWhite

Hmm ... thank for the info.

 

So what extension should I use so that ffmpeg knows that files are MPEG-2?

I don't think you need to change anything since it seems to work, but the files are mpegts and most systems apply the .ts file extension.  .ts is an mpeg-2 format.  If there is a way to configure your service to supply that extension it might work a little better.  But when I looked on one of the forums for Channels DVR it appears that the system looks for .mpg files when you use it to delete files.  If you switch to another extension you won't be able to use that feature.   Also, if you use Handbrake it will create an MKV file (or, you could set the CLI to make an .mp4 if you wish), and it looks like Channels DVR won't recognize that if you want to use the deletion feature.

  • Like 2
Link to comment
Share on other sites

I'm looking to switch from ChannelsDVR to Plex anyways, since I already bought a Plex lifetime subscription.  

 

I just verified that Plex DVR uses .ts (for it's DVR recordings) so I should be good to go with my current post.sh

 

I'll simply rename old ChannelsDVR recording to .ts

 

Again, thanks for all your help.

Link to comment
Share on other sites

PhilWhite

I don't know if it will work to rename the files .ts, but it's worth a try.  Though, since the files are actually mpeg-ts files you shouldn't need to reformat them.  Most of the time you have to reformat to make a file extension change meaningful; but I would bet you can get away with it.  Actually, thinking about it, why not try that with the same file you have already cut commercials from (assuming you have the original, or with the next one you record), and change to a .ts extension and see what happens when you run it.

 

Excellent.  You should be good to go.  This was all worked out for the Freenas Plex plugin and originally posted on the FreeNas forum, so it works perfectly with Plex.

Edited by PhilWhite
Link to comment
Share on other sites

 

Here's my script, which is really WarrentC3's which he based on Phil's OP in this thread.

 

I cleaned some stuff up for example:

set filename = `printf "%s " $1:t:r:r`

Works better if you use 'basename', which does what WarrentC3 intended (extracts just the file name from the path string returned) but doesn't choke on unexpected characters in the file name. I had a problem with a couple shows that had . in their name (i.e. House Hunters St. Croix) using WarrentC3's script as is. This works better:

set filename = `basename "$1" .ts`

Cleaned up some other minor stuff as well. I was going to just re-do it in Bash because C Shell is ancient, but then, Bash is no spring chicken either and to do some of the more complicated stuff I am thinking of doing next will probably require a more robust scripting environment than a shell....that is a bigger project so in the meantime my full script posted below works fine.

 

  • It will cut commercials and create a _cut.ts file
  • Convert the video (adjust the settings to your liking if you don't want .mp4, etc.)
  • Extract the first embedded CC track if one is present (in the cut file obviously, so they sync correctly with that) and write it out to an .srt file - note I've only tested this with EIA-608/708 North America closed captioning, no idea if it works for other types. This is one function I plan to make a lot more robust...just not using csh :)
  • Checks to see if an mp4 file was created by HandbrakeCLI and if so deletes the _cut.ts and .ts files.

 

Pretty basic but works. In addition to extracting subtitles more elegantly I am also working on checking the mp4 file via ffprobe to insure codec is correct and the duration matches - Handbrake will usually just fail if it encounters a problem (and thus checking for the presence of the mp4 is "good enough" for the basics) but it would be better to actually do a quick diagnostic on the file itself before deleting.

 

Anyway I'll noodle on improving this process but it works well enough now - use at your own risk of course. Script is pretty self explanatory as are my changes:

#!/bin/csh
set path = ($path /usr/local/bin)
set w1 = `jot -r 1 2 15`
set filename = `basename "$1" .ts`
set grab = `printf "%s " $1:h`
set a = `echo "$filename".ts`
set b = `echo "$grab/$filename"_cut.ts`
set c = `echo "$grab/$filename".mp4`
set d = `echo "$grab/$filename".srt`
set e = `echo "$grab/$filename".ts`
sleep $w1

while (1)
if ( ! -e "$b" ) then
echo "Running Comcut"
comcut --ffmpeg=/usr/bin/ffmpeg --comskip=/usr/bin/comskip --lockfile=/tmp/comchap.lock --comskip-ini=/media/Comskip/comskip.ini "$1" "$b"
echo "Comcut complete"
else
echo "Comcut already done"
endif
break
end

while (1)
if ( -e "$b" ) then
echo "Extracting subtitles"
ffmpeg -f lavfi -i "movie=${b}[out0+subcc]" -map 0:1 "$d"
echo "Subtitle extraction complete"
else
echo "No input file found for sub extraction"
endif
break
end

while (1)
if (! `pgrep HandBrakeCLI` ) then
break
endif
echo "HandBrakeCLI is still running. Will try again in a minute."
sleep 60
end

HandBrakeCLI --input "$b" --output "$c" --preset-import-file /media/comchap/hb-dvr.json

while (1)
if (! -e "$c" ) then
echo "Conversion appears to have failed no file found"
break
endif
echo "Cleaning up source files"
sleep 5
rm "$b"
rm "$e"
end

 

Thinking trying out this script, but have some questions.

 

1) what's the purpose of generating the "w1" variable, I see it used only for sleep, but why?

2) what is the purpose of the "grab" variable, since it seems to generating same value as "filename"

3) what's the purpose of using the "$grab/$filename"

4) The handbrake line reference "/media/comchap/hb-dvr.json" what's that for

 

Sorry about all the question, just trying to improve my post.sh as much as possible.

Link to comment
Share on other sites

sluggo45

The sleep variable is a relic; you can use it instead of setting a fixed sleep time but I got rid of it. You can remove it.

 

Grab and Filename are done in order to parse the correct paths and join them together correctly. This is easier to do in Bash but this is a c shell script so it was slightly trickier. There's probably a better way to do this. 

 

The handbrake json file is the configuration file for Handbrake. You can use it instead of passing config options via command line. The original script has an example on github.

Link to comment
Share on other sites

PhilWhite

I've been trying to simplify this process, but there are a few things I simply do not know how to do -- like how to make 'git clone ...' work in a csh script.

 

Here is the slightly simplified version for setting up from scratch.  First open a shell session in Freenas and go to your jail -- iocage console <jailname>, then I usually hit cd / to get to root in the jail, but you can start at any point.  You will need to add a few packages to get started, but this might change depending on if I figure out the git clone issue.

 

pkg update

pkg install -y wget

pkg install -y git

pkg install -y bash

cd /usr/local

git clone https://github.com/erikkaashoek/Comskip

git clone https://github.com/BrettSheleski/comchap

cd /

wget https://raw.githubusercontent.com/pawhite/Comercialcut/master/package.sh

chmod +x /package.sh

./package.sh

 

That set of commands will put Comskip and comchap into their own directories in /usr/local -- the way that WarrentC3 set up his approach.  It will also download all the other needed packages, including Handbrake, set pathways correctly, pull in a copy of comskip.ini and place it in the Comskip directory, pull in an executable post.sh file based on WarrentC3's suggestions (I completely missed his posts from a year or so ago), and compile Comskip.  You only have to hit 'y' twice during the mostly automated process.

 

I'm still trying to figure out how to use git in csh, but I'm a rank beginner.  If someone knows how to do this I would greatly appreciate any guidance.  I'm also working on adding sluggo45's suggestions into other options that can be retrieved from github.

 

There are a couple of things to know about how this is set up.  It will create a new directory under media called TSFiles.  I set up my post.sh script to cut commercials, convert to .mkv and move the original source video (without commercial cuts) to that directory -- in case there were any problems with the commercial cutting process (another of WarrentC3's great ideas).  I also used the same command line options for Handbrake as in the first post, but the package.sh script will put a copy of WarrentC3's Handbrake json file in a new directory, also under media called comchap.  I did this in case anyone wanted to use that approach (you will need to change the post.sh script to use the json file as in WarrentC3 and sluggo45's posts), and simply used his convention for where to 'house' the json file.

 

ETA:  So, I am recording four programs tonight and will see how things worked in the morning.  Everything seems to be in the right place, so hopefully it will go well.

Edited by PhilWhite
  • Like 1
Link to comment
Share on other sites

unhooked

You don't really need wget, fetch comes with the base system and does the same thing. Also checking stuff out to /usr/local breaks heir and there's no need to do that either as make install will put things where they belong. Your issue with git is probably just that it didn't exist at the beginning of your script so you need to call it by it's full path. (or if it did exist /usr/local/bin isn't on your path).

 

<get 9:46pm> chmod +x foo
<get 9:46pm> ./foo
Cloning into 'Comskip'...
remote: Enumerating objects: 1880, done.
remote: Total 1880 (delta 0), reused 0 (delta 0), pack-reused 1880
Receiving objects: 100% (1880/1880), 9.99 MiB | 1.45 MiB/s, done.
Resolving deltas: 100% (1125/1125), done.
<get 9:46pm> ls
Comskip foo     screens
<get 9:46pm> cat foo
#!/bin/csh

git clone https://github.com/erikkaashoek/Comskip
 

  • Like 1
Link to comment
Share on other sites

PhilWhite

You don't really need wget, fetch comes with the base system and does the same thing. Also checking stuff out to /usr/local breaks heir and there's no need to do that either as make install will put things where they belong. Your issue with git is probably just that it didn't exist at the beginning of your script so you need to call it by it's full path. (or if it did exist /usr/local/bin isn't on your path).

 

<get 9:46pm> chmod +x foo

<get 9:46pm> ./foo

Cloning into 'Comskip'...

remote: Enumerating objects: 1880, done.

remote: Total 1880 (delta 0), reused 0 (delta 0), pack-reused 1880

Receiving objects: 100% (1880/1880), 9.99 MiB | 1.45 MiB/s, done.

Resolving deltas: 100% (1125/1125), done.

<get 9:46pm> ls

Comskip foo     screens

<get 9:46pm> cat foo

#!/bin/csh

 

git clone https://github.com/erikkaashoek/Comskip

 

Thank you.  I will try using fetch and see how that works.  I had a bit of an issue this morning because Handbrake needed a lame component that was not present, so I need to add portsnap fetch to the process.

 

I agree about moving stuff to usr/local -- just making things overly complicated if for no other reason.  And it might have been the problem with git.  Actually the script sets the path to /usr/local/bin, so that should not be a problem and I added git before downloading the script.  I wonder if the issue actually was in changing directories to /usr/local.  I will take that out and see how it works -- still not ready for prime time yet.

 

This may have been an issue with Handbrake not having access to lame, but one other very weird thing is that when I tried to run post.sh from the command line this morning I got a "command not found" error -- the same error I was getting when I had the 'git clone' commands in package.sh.  Once I removed those lines from the package.sh script everything worked fine.  But the weird thing is that if I SSH'd into the jail, opened package.sh in a text editor and say added an extra line, removed it, and then saved it -- it ran perfectly even with the git clone commands in place.  The same was true of the post.sh script this morning -- minor change, reverse the change, save it and suddenly it worked fine from the command line.

 

I'm going to make a few changes to simplify, add the portsnap extraction to get lame in place, and see how that works.

 

Thanks again.

 

ETA:  Could I use fetch to retrieve a directory clone from github or do I need to use git clone for that?  Or does fetch only work for single files instead of directories?

 

ETA: OK, so it looks like fetch works for files but not for directories.  I'm going to look more at its use and see if there are modifiers that might help.  Also, with the weird behavior that the .sh files work fine if I change anything in a text editor and then save them on my freenas box, is there something else I need to do to those files before uploading them to github?  I've reproduced this multiple times, and git works fine when I save package.sh that way.  Maybe an extra command that I don't know about?

 

If I make the same type of change and reverse it and save using nano instead of using the text editor in WinSCP (was using this since I made numerous changes to see if things would work and then changing again when they did not) then I still get the same "command not found" error when trying to run the .sh files.  Could it be that I simply need to remake these files using a text editor in Freenas?  That doesn't sound right, but I guess it is worth a shot.  I still wonder if there is something simple that I am missing.

 

Restarting the jail didn't help.  Is this just an issue with the way the .sh file is encoded?

 

Thank you for your help so far, fetch works great - replaced wget in all instances.

Edited by PhilWhite
Link to comment
Share on other sites

PhilWhite

Yeah, ok, please ignore all the above blathering.

 

Stupid issue -- created by my attempt to cut corners.  There was never an issue with the 'git clone' command using the script -- I was changing back and forth what was in the script trying to trouble shoot issues that arose, and I used the text editor in WinSCP.  That is not really a problem, but I was editing primarily on the Windows side and I uploaded those files to Github.  I just edited the same files and saved on the Freenas side, uploaded those files to Github, and everything works perfectly.  So, I learned something new. And thanks again unhooked for the suggestion to use fetch.

 

The process is a bit easier now.

 

Open a shell session in Freenas, go to your jail -- iocage console <jailname>, and if you wish get to root do so with cd /

Then use these commands:

 

pkg update

pkg install -y bash git

fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/package.sh

chmod +x /package.sh

./package.sh

 

So, this version also fetches portsnap extract and makes/installs lame to avoid issues with Handbrake.  I can easily create a version that does not include this if anyone wants to use it and objects to adding ports.  The script will put everything in the right place and produce a post.sh that cuts commercials, converts to .mkv file, and saves the original .ts file in the directory TSFiles.  Any and all of that can obviously be changed at your own discretion.  WarrentC3's Handbrake .json file is also still placed under /media/comchap.

 

Just place the post.sh file in the post-processing pathway in the Emby DVR section.

 

During installation there are two places to answer 'y' and during the portsnap/lame process there are two screens to hit "OK".  Other than that the process should be automated.

  • Like 1
Link to comment
Share on other sites

PhilWhite

OK, final change -- streamlining a tiny bit.  I removed the addition of ports and the Handbrake .json file.  Once you run package.sh it will load everything. 

 

First, open a shell, go to your jail and add git, then fetch the package.sh file, make it executable and then run it.  That is pretty much it.  No need to hit 'y' or 'OK' during the process.

 

iocage console <jailname>

cd /

pkg install -y git

fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/package.sh

chmod +x /package.sh

./package.sh

 

If you have any problem running Handbrake it probably needs a lame file.  To add this:

 

portsnap fetch extract

cd /usr/ports/audio/lame

make install clean

 

If you want to use Warrentc3's json file for Handbrake:

 

fetch https://raw.githubusercontent.com/warrentc3/postprocessing/master/hb-dvr.json

 

You can then put the .json file wherever you want and call it into Handbrake by adjusting your post.sh file.  I included nano in the packages downloaded to make this easier.  To get into the file:

 

nano /post.sh

 

Next step -- trying to make this into a plugin.

Edited by PhilWhite
Link to comment
Share on other sites

unhooked

FWIW you can just do sh `fetch $urltoyourpackage.sh`

 

and I've had no issues building with clang so you don't really have to install another compiler either. Just have to set CC to clang.

  • Like 1
Link to comment
Share on other sites

PhilWhite

FWIW you can just do sh `fetch $urltoyourpackage.sh`

 

and I've had no issues building with clang so you don't really have to install another compiler either. Just have to set CC to clang.

I clearly need to do more research.  Thank you again, you've been a great help.

Edited by PhilWhite
Link to comment
Share on other sites

unhooked

You're not really doing anything I can see that requires csh, sh should be sufficient.

I don't use git enough to have bothered finding out how to transfer umasks, but it's really not needed to keep spawning sub shells like that.

You can run the script directly by calling sh, (or whatever other shell) as I showed above for running fetch output.

 

For that git issue, I would try calling is as /usr/local/bin/git instead of just git. Alternatively you could execute rehash after new binaries are added to your path.

It's generally good practice to either define processes you want to repeatedly call, or call on them by their full path so something else doesn't slip in there.  

Much safer on multi user systems anyway, as you could have multiple versions of git and the first one the shell finds on your path is going to get called.

  • Like 1
Link to comment
Share on other sites

unhooked

Ideally, building a comskip pkg would be best. I've been meaning to do that for years, but I'm too lazy to

pick it up and then maintain it.

  • Like 1
Link to comment
Share on other sites

PhilWhite

You're not really doing anything I can see that requires csh, sh should be sufficient.

I don't use git enough to have bothered finding out how to transfer umasks, but it's really not needed to keep spawning sub shells like that.

You can run the script directly by calling sh, (or whatever other shell) as I showed above for running fetch output.

 

For that git issue, I would try calling is as /usr/local/bin/git instead of just git. Alternatively you could execute rehash after new binaries are added to your path.

It's generally good practice to either define processes you want to repeatedly call, or call on them by their full path so something else doesn't slip in there.  

Much safer on multi user systems anyway, as you could have multiple versions of git and the first one the shell finds on your path is going to get called.

Again, thank you.

 

The reason this is in csh is because the person who originally posted this solution (for Plex) on the Freenas forum did it that way (and I didn't know any better).  All of the issues I have run into arise from my ignorance of how to make this work best.  Originally I was just the messenger, moving this over from the Freenas forum to here.  Now I'm trying to learn something new.  And I'm perfectly happy using whatever works.

 

So, my original 'problem' with git was that I thought the 'command not found' message I received when I tried to run the script was because of git -- when I removed the git commands and saved the script and then ran it, it worked.  Of course, the problem wasn't git but the way I was saving the script.

 

The other problem I ran into was that when I installed git early in the script and then tried to use it later I would get an error saying that git was not found.  I tried to set up a while-if-then loop using 'command -v git' (which I found for bash, don't know if it even works in csh) and then have the script sleep if it didn't find git; but that didn't work (probably because I didn't structure it correctly).  I also tried just having the script sleep for a brief period while git installed, but that didn't work either.  I'm sure there is an easy solution, but I'm still mucking around trying to find it.  The one thing I tried that did work was creating a separate script for using git and compiling comskip and calling that in -- not elegant but functional.  So, maybe just using rehash will work.  I'll give it a try.

 

I didn't fully understand what sh fetch ... did but now do from your post above, so again thank you.  I was going to spend time today figuring that out but now I will simply just use it, especially since it should solve the last problem I was trying to solve.  And I can remove adding gcc to the equation hopefully too.  The originator implied that whatever he was using to compile comskip didn't work which is why he added gcc.  I will use clang and see how that works.

 

Thanks for teaching me new tricks.  I think you've solved all my problems with this.

Edited by PhilWhite
  • Like 1
Link to comment
Share on other sites

PhilWhite

@@unhooked,

 

Many, many thanks.  hash git solved my git problem and running the script without having to download and store it is a terrific solution.  Clang worked beautifully. So, it's now down to a single command to install the commercial cutting script.

 

fetch -o - https:raw.githubusercontent.com/pawhite/Commercialcut/master/package.sh | csh

 

Then add post.sh to the dvr post-processing section.  I also renamed the directory where the original .ts files are thrown "ts_archive" instead of TSFIles if anyone ever decides to use this.

 

But folks might have to add and make lame from ports for Handbrake.  

Edited by PhilWhite
Link to comment
Share on other sites

unhooked

My plexpass is about to expire so I decided to convert what I was using there a bit.

So afterplex is now afteremby, but I decided to go one step farther and make emby do all the work. ;-)

 

http://unhooked.net/tv/afteremby

 

Thinking about pulling metadata into the mix, but I'm a lazy minimalist so maybe not.

  • Like 1
Link to comment
Share on other sites

PhilWhite

My plexpass is about to expire so I decided to convert what I was using there a bit.

So afterplex is now afteremby, but I decided to go one step farther and make emby do all the work. ;-)

 

http://unhooked.net/tv/afteremby

 

Thinking about pulling metadata into the mix, but I'm a lazy minimalist so maybe not.

Nice, thanks.  So you just use ffmpeg.  I like it.

Link to comment
Share on other sites

PhilWhite

To begin, many thanks to bollar (Freenas forum) for the original plan, @@Baenwort for multiple corrections, @@warrentc3 and @@sluggo45 for great improvements, and @@unhooked for significant help.

 

OK, here is the state of things as I have it.  I tried to eliminate as much fluff as possible without sacrificing the ability to place the converted file back in the original folder/directory (where the Emby metadata is placed). Here is my current post.sh:

#!/bin/csh

set path = ($path /usr/local/bin)

set show = `basename "$1" .ts` 
set grab = `dirname "$1"`
set a = `echo "$grab/$show".mkv`

/usr/local/bin/comcut --ffmpeg=/usr/local/bin/ffmpeg --comskip=/usr/local/bin/comskip --lockfile=/tmp/comchap.lock --comskip-ini=/Comskip/comskip.ini "$1"

/usr/local/bin/ffmpeg -i "$1" -vf yadif -c:v libx264 -preset slow -crf 18 -max_muxing_queue_size 1024 -c:a copy "$a"

mv "$1" "/media/ts_archive/$show.ts"

I ran into a few issues with ffmpeg in a couple of files (same issues with Handbrake, since Handbrake is really just ffmpeg with a GUI), so I added the max_muxing_queue_size solution for failed conversions and went back to using straight copy/passthrough for audio since it seems to work better.  For any wondering, the "show" variable provides just the name of the recorded show and the "head" variable provides the 'head' or rest of the pathway so that the conversion will be dumped back into the original folder/directory.  So, for instance, if you record The Late Show, Emby places the recording into your recording folder as The Late Show With Stephen Colbert (2015)/Season 4/The Late Show....ts -- 'head' maintains the path back to that folder.  You may leave it off, but the conversion will then be placed wherever your post.sh script is instead of where your recordings are originally placed (unless you put post.sh in that folder).

 

This version cuts commercials and then proceeds to convert the file to mkv.  You can, of course, change it to convert to mp4, or whatever.  After the conversion, the file with commercials removed is sent to a folder named ts_archive in case anything goes wrong in the process.  You could also add another variable, as sluggo and Warrentc3 did to 'receive' the cut.ts file and then run that file through ffmpeg.  That way you could keep the original uncut file, if you prefer.  I'm on the verge of simply deleting the 'cut file' altogether, but I want to watch how reliable this is.  So far, once I worked out a few kinks, all seems well.

 

An alternate version of post.sh that maintains the original recorded file without commercial cuts is this:

#!/bin/csh

set path = ($path /usr/local/bin)

set show = `basename "$1" .ts` 
set head = `dirname "$1"`
set a = `echo "$head/$show"_cut.ts`
set b = `echo "$head/$show".mkv`

/usr/local/bin/comcut --ffmpeg=/usr/local/bin/ffmpeg --comskip=/usr/local/bin/comskip --lockfile=/tmp/comchap.lock --comskip-ini=/Comskip/comskip.ini "$1" "$a"

/usr/local/bin/ffmpeg -i "$a" -vf yadif -c:v libx264 -preset slow -crf 18 -max_muxing_queue_size 1024 -c:a copy "$b"

rm "$a"
mv "$1" "/media/ts_archive/$show.ts"

This will save the original recorded file without changes in ts_archive and leave you with an mkv file with cut commercials in the recording directory.  It works best, however, if you make some changes to the comcut script (which requires a text editor in the jail or ssh'ing into the jail and making a few simple changes to the comcut script) so that conversion failures do not occur.  There is a way to include closed captions that I will include soon.

 

And here is the package.sh script for installing everything.  I left out Handbrake and a few other things that are not completely necessary.

#!/bin/csh

set path = ($path /usr/local/bin)

cd /
pkg install -y git
pkg install -y bash
pkg install -y argtable
pkg install -y autoconf
pkg install -y automake
pkg install -y libtool
pkg install -y ffmpeg

echo y | pkg set -o devel/pkg-config:devel/pkgconf
echo y | pkg install -f devel/pkgconf

setenv CC clang

/usr/local/bin/git clone https://github.com/erikkaashoek/Comskip
/usr/local/bin/git clone https://github.com/BrettSheleski/comchap

cd /Comskip
./autogen.sh
./configure
make install
fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/comskip.ini

ln -sf /comchap/comcut /usr/local/bin
ln -sf /comchap/comchap /usr/local/bin

cd /
mkdir /media/ts_archive
fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/post.sh
chmod +x /post.sh


Both the package.sh and my post.sh scripts are on github if anyone wants to use them.

 

To install the commercial cutting script you can just open a shell and go to your jail:

iocage console <jailname>

cd /

and then use:

fetch -o - https://raw.githubusercontent.com/pawhite/Commercialcut/master/package.sh | csh

And that should place a working copy of all the needed components in your jail with the above version of post.sh.  Then put post.sh in the DVR section of Emby, and you're good to go.

 

I did not include a text editor in the packages added, but you can get one (like nano) with

pkg install -y nano

if you want to alter the post.sh file in any way.  Most any text editor should work.

 

You can add Handbrake with

pkg install -y handbrake

if you prefer to use it instead of ffmpeg.  Depending on which audio settings you use with Handbrake you might have to add lame components (if you get an error message about a missing shared component).  You can do that with:

portsnap fetch extract
cd /usr/ports/audio/lame
make install clean

@@unhooked suggested creating a package for Comskip, and I think that is a great idea.  I've been researching and think I might give it a try once I learn a bit more.  That would (I assume, which is probably dangerous) eliminate the need to install autoconf, automake and libtool and to compile Comskip, streamlining the process even further.  

 

Another option to streamline things that I have been contemplating is to alter comcut to do all the work and make that my post-processing script.  That shouldn't require many changes and could eliminate the need to create a post.sh script.

Edited by PhilWhite
  • Like 1
Link to comment
Share on other sites

unhooked

Getting nice, only two things I would add.

make install instead of just make for your git pulls will put them in /usr/local/bin where they belong.

 

and that sleep really isn't needed as the first comskip spawned is going to create a lock file and any others spawned are going to wait until it's done to run.

 

A mono version of comcut would be pretty cool as it would work wherever emby is.

Link to comment
Share on other sites

PhilWhite

Getting nice, only two things I would add.

make install instead of just make for your git pulls will put them in /usr/local/bin where they belong.

 

and that sleep really isn't needed as the first comskip spawned is going to create a lock file and any others spawned are going to wait until it's done to run.

 

A mono version of comcut would be pretty cool as it would work wherever emby is.

Thanks again.

 

Couple of questions since this is new to me.

For the make install commands, it would be:

./autogen.sh

./configure

make

make install

 

Correct?

 

Is there any reason why I should not simply use fetch to retrieve the comcut script instead of using git to retrieve the folder with comcut, comchap and Makefile?

 

And, for creating a mono version of comcut, do you mean re-writing the script using C# or through some other means?

Link to comment
Share on other sites

unhooked

Auto tools defines where things should go so when you gen and config  it builds the Makefile so make install generally just works. Until it doesn't, but then the error messages will let you know.

 

using git for the pull would just insure you're getting any changes or files included if it's ever updated again. But I haven't seen it altered in forever so you could just as easily pull your own copy I'm sure.

 

Yea, non bash version of comcut. I only mentioned that cuz you said you were going to modify comcut.

Link to comment
Share on other sites

PhilWhite

@@unhooked,

 

I made a few changes to post #70.  I could not get a useful version of comcut invoking Brett Sheleski's makefile and using make install (since, I assume that is not appropriate) and all the makefile does is create new directories, copy files and then create a simlink to /usr/local/bin -- so I decided to cut out the middle man and just git comchap and create the simlink to /usr/local/bin in the package.sh script.  I used the full  path from within the jail to comcut in the post.sh script even though invoking comcut (without the full path) works fine.  Thinking about it, maybe I should add a comchap command line and comment it out to make it easy for anyone wanting to just tag commercials.

 

So, sorry, a few more questions.  I am going to start working on a non-bash version of comcut soon -- do you have any opinion on which language to use?  Or would two versions -- one in C that could be made into a pkg (for general portability) and one in C# for portability within Emby (or is there a freeBSD compiler for C#?) -- be a good idea (keeping in mind that this is largely a learning project for me, so the amount of work is inconsequential)? 

 

And, for creating a comskip pkg, I assume that I would use pkg create and include only the compiled comskip in /usr/local/bin, or should more be included?  Obviously, credit to Erik Kaashoek in the documentation if I could ever get it to work.

 

I guess a comskip package would be most useful with a working comskip.ini file, so maybe a post_install script to create a directory and fetch comskip.ini as part of the pkg?

 

Just thinking out loud, but is pkgconf only used in the compiling process?  So would it be the case that a comskip pkg would need to include argtable as a dependency, but that it would eliminate the need to install virtually all of the packages?  Comcut only needs comskip (with comskip.ini) and ffmpeg.  Could I create a comcut pkg (say, written in C) that includes a pre-install script adding the comskip pkg (with argtable) and the ffmpeg pkg along with a post-install script that includes post.sh (which I also assume would be much better written in the Bourne shell instead of c shell for portability) -- which would mean only having to install a comcut pkg?

 

Could a mono version of comcut just use the Windows version of comskip and ffmpeg?  Could that potentially work in a freenas jail after it is compiled?  Or would that be the easiest way to create an Emby plugin -- as another project -- since the plugin needs to be created using C#?

Edited by PhilWhite
Link to comment
Share on other sites

unhooked

@@unhooked,

 

I made a few changes to post #70.  I could not get a useful version of comcut invoking Brett Sheleski's makefile and using make install (since, I assume that is not appropriate) and all the makefile does is create new directories, copy files and then create a simlink to /usr/local/bin -- so I decided to cut out the middle man and just git comchap and create the simlink to /usr/local/bin in the package.sh script.  I used the full  path from within the jail to comcut in the post.sh script even though invoking comcut (without the full path) works fine.  Thinking about it, maybe I should add a comchap command line and comment it out to make it easy for anyone wanting to just tag commercials.

 

So, sorry, a few more questions.  I am going to start working on a non-bash version of comcut soon -- do you have any opinion on which language to use?  Or would two versions -- one in C that could be made into a pkg (for general portability) and one in C# for portability within Emby (or is there a freeBSD compiler for C#?) -- be a good idea (keeping in mind that this is largely a learning project for me, so the amount of work is inconsequential)? 

 

And, for creating a comskip pkg, I assume that I would use pkg create and include only the compiled comskip in /usr/local/bin, or should more be included?  Obviously, credit to Erik Kaashoek in the documentation if I could ever get it to work.

 

I guess a comskip package would be most useful with a working comskip.ini file, so maybe a post_install script to create a directory and fetch comskip.ini as part of the pkg?

 

Just thinking out loud, but is pkgconf only used in the compiling process?  So would it be the case that a comskip pkg would need to include argtable as a dependency, but that it would eliminate the need to install virtually all of the packages?  Comcut only needs comskip (with comskip.ini) and ffmpeg.  Could I create a comcut pkg (say, written in C) that includes a pre-install script adding the comskip pkg (with argtable) and the ffmpeg pkg along with a post-install script that includes post.sh (which I also assume would be much better written in the Bourne shell instead of c shell for portability) -- which would mean only having to install a comcut pkg?

 

Could a mono version of comcut just use the Windows version of comskip and ffmpeg?  Could that potentially work in a freenas jail after it is compiled?  Or would that be the easiest way to create an Emby plugin -- as another project -- since the plugin needs to be created using C#?

I haven't done any c#/mono dev so I'm not really sure what environment is best suited for this. A script/object is going to work anywhere as long as the variables all point to os dependencies. ffmpeg works the same on any platform, it's just up to how you evoke it. That's why python is becoming popular with cross platform apps. And mono/.net for it's compile once run anywhere an interpreter is available. The init routines for emby define all of those types of things, but referring to their plugin documentation is going to be more helpful than my poking at it for incite into my own tweaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...