Jump to content

Automated Commercial Removal from TV Recordings


PhilWhite

Recommended Posts

PhilWhite

I don’t know if anyone is interested, or if you might already be doing this, but if anyone wants to cut commercials from recorded shows automatically and not have to use another program, such as MCEBuddy, there is a way to do the entire process on a Freenas box. Personally, I think this makes EmbyTV a killer DVR app. You can adapt it in many ways, but what I have below is what I use. It cuts commercials from over the air shows and converts the show to .mkv format for easy viewing.  You can also add commands to move shows to other folders if you prefer.

 

Caveat: this will not work for copy-once or copy never content (from many cable companies), since, as far as I know, you cannot cut commercials from those recordings.

 

This guide is only very slightly adapted from the excellent work of bollar and a few others in the Freenas forum. The original thread outlining these steps for Plex users can be found here: http://forums.freenas.org/index.php?threads/plex-dvr-commercial-skipping-with-comskip.46081/

 

Start by installing dependencies. Go to the jail and open a shell session. You can do this in the Freenas GUI either by navigating to the jail and clicking on the shell/terminal icon on the bottom of the page, or by opening a shell session and using jexec 1 (if 1 is the number of your jail – find out with the jls command, which will give you the jail id of jid of your jails).

 

For anyone using an iocage jail, use ---- iocage console <jailname>,  then cd / (the latter to get to the primary root in the jail)

 

Then install the following (this is the updated version):

pkg update
pkg install git argtable autoconf automake libtool ffmpeg 

Say "y" to all if you wish to install them.  If interested, git is added to fetch comskip (later step and the heart of the process) and everything else is needed to either compile or help comskip work.

 

Change pkg-config references to pkgconf and install pkgconf

pkg set -o devel/pkg-config:devel/pkgconf
pkg install -f devel/pkgconf

Set the compiler to clang.  Probably a totally unnecessary step, but clang did not work well with the initial instructions and gcc was used.  Clang now seems to work fine; setting the environment to clang is just for safety in case you have changed to any other compiler.  I believe clang is still the native compiler in freenas.

setenv CC clang

Get comskip and a version of Brett Sheleski's comcut that I modified -- the latter can be used as your post.sh file in Emby.  And make post3.sh executable. 

 

You can also go to Brett Sheleski's github page to fetch his original comcut if you prefer.  The command would be -- fetch https://raw.githubusercontent.com/BrettSheleski/comchap/master/comcut. If you go that route you will need to install bash since his script is written in bash (post3.sh is a pared down version of the original comcut using sh, so employing fewer dependencies).  I'm not sure how well comcut will work as a post.sh file since it uses bash. if you want to use the original comcut you will likely need to create your own post.sh file (there are good examples in the thread and in the original thread from the Freenas forum), most which use handbrake for video conversion (you can add handbrake with pkg install handbrake).  The original comcut does not include a command to convert .ts files to .mkv or .mp4, but most of the post.sh examples you will see do.  These post.sh files are simply another step that calls comcut just as comcut calls comskip to do the work.

 

I use ffmpeg to do the video conversion since handbrake is mostly just a gui wrapper around ffmpeg -- that is what is in post3.sh (the script is in another post near the end of the thread).

/usr/local/bin/git clone https://github.com/erikkaashoek/Comskip
fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/post3.sh
chmod +x /post3.sh

Then, compile comskip, which is in the Comskip folder that you just downloaded.

cd /Comskip
./autogen.sh
./configure
make install

Last, fetch a copy of comskip.ini to help comskip do its job.

fetch https://raw.githubusercontent.com/pawhite/Commercialcut/master/comskip.ini

And that is all you need.  This sequence of steps will put all dependencies in their proper place to work with post3.sh.  You then simply add post3.sh to the dvr post-processing section in Emby, and you can then cut commercials, convert the file to .mkv, and remove the original .ts file (so that you do not end up with two copies of the same program).
 

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

  • 5 weeks later...
Baenwort

So I've tried to follow along but I fail when I reach:

sentev cc gcc5

after pasting in the above I get:

sentev: Command not found.

What did I mess up installing or do I need to reboot between some step and missed the need?

 

or should it have been:

setenv cc gcc5

instead?

Edited by Baenwort
Link to comment
Share on other sites

Baenwort

So I tried 

setenv cc gcc5

and it worked. It seems that you have a typo in the instructions above @@PhilWhite 

 

Now, I'm trialing the commercial removal and don't have anything to report yet on how well it works.

 

However, since performing all the steps above I am having transcoding errors when trying to play videos that worked yesterday on my 2015 Roku 2 and via the webapp.  Direct play of the file and Emby Theater work fine.  This makes me think that the ffmpeg install is conflicting with the FreeNAS plugin version .30 as I get the below information in the transcoding log:

Application version: 3.2.30.0

http://192.168.1.133:8096/emby/videos/293ca488cc618efe6ed6611535d76695/hls1/main/0.ts?DeviceId=xaRDeKU5lja8JeuR1Kf3B5kmyCb20nYVb99ddE&MediaSourceId=293ca488cc618efe6ed6611535d76695&VideoCodec=h264&AudioCodec=aac&AudioStreamIndex=1&VideoBitrate=40000000&AudioBitrate=192000&Level=51&Profile=high&PlaySessionId=442d9d3c032b46ac909bb9a6c1e55be0&api_key=5092111a7e84426bb03b409596ff0a81&CopyTimestamps=false&TranscodingMaxAudioChannels=2&EnableSubtitlesInManifest=false&Tag=2ebc54589d3170d3b927e0f8cec689e6&RequireAvc=false&RequireNonAnamorphic=false&DeInterlace=false&SegmentContainer=ts&MinSegments=1&BreakOnNonKeyFrames=False&TranscodeReasons=VideoProfileNotSupported

{"Protocol":"File","Id":"293ca488cc618efe6ed6611535d76695","Path":"/media/Visual/TV Shows/Shaun The Sheep/Season 0/Shaun the Sheep Championsheeps S00E01.mkv","Type":"Default","Container":"mkv","Name":"720P/H264/AAC","IsRemote":false,"ETag":"2ebc54589d3170d3b927e0f8cec689e6","RunTimeTicks":6341329920,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"SupportsProbing":true,"EnableMpDecimate":false,"RequiresLooping":false,"VideoType":"VideoFile","MediaStreams":[{"Codec":"h264","TimeBase":"1/1000","CodecTimeBase":"1/50","NalLengthSize":"4","IsInterlaced":false,"IsAVC":true,"BitRate":988588,"BitDepth":10,"RefFrames":3,"IsDefault":true,"IsForced":false,"Height":720,"Width":1280,"AverageFrameRate":25,"RealFrameRate":25,"Profile":"High 10","Type":"Video","AspectRatio":"16:9","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p10le","Level":31,"IsAnamorphic":false},{"Codec":"aac","Language":"eng","TimeBase":"1/1000","CodecTimeBase":"1/48000","DisplayTitle":"Eng AAC stereo Default","IsInterlaced":false,"ChannelLayout":"stereo","Channels":2,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Profile":"LC","Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0,"IsAnamorphic":false}],"Formats":[],"Bitrate":988588,"RequiredHttpHeaders":{}}

User policy for Charles: EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True

/usr/pbi/emby-amd64/bin/ffmpeg -f matroska -i file:"/media/Visual/TV Shows/Shaun The Sheep/Season 0/Shaun the Sheep Championsheeps S00E01.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 18 -maxrate 1977176 -bufsize 3954352 -profile:v high -level 4.1 -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 2 -ab 192000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/db/emby-server/transcoding-temp/03aa9951cd7499e146ef5a983e14a19a.m3u8" -y "/var/db/emby-server/transcoding-temp/03aa9951cd7499e146ef5a983e14a19a%d.ts"

Shared object "libiconv.so.3" not found, required by "libavcodec.so.56"
Shared object "libiconv.so.3" not found, required by "libavcodec.so.56"

Any ideas anyone?

Link to comment
Share on other sites

Baenwort

So I couldn't rebuild ffmpeg as my Emby jail dates from 9.3 and the package upgrade won't cooperate. I uploaded another pbi to the emby jail, deleted the emby plug in, and then uploaded the emby .pbi back into the jail and deleted the temp .pbi. This fixed my ffmpeg error.

 

Now to test the commercial removal...again...but this time without trying to update ffmpeg.

  • Like 1
Link to comment
Share on other sites

Baenwort

I didn't save a copy of the error as I was focused on fixing it before the 3 year old melted to the center of the earth since his Shaun the Sheep wasn't working.

 

I haven't gotten the commercial skipping to work yet. I'm going to try again this weekend as just patching in a rewrite of Emby was able to fix the transcoding error I attached above and the post.sh exits with a code of 1 per the server logs but there isn't a .mkv file in the directory after the recording completes.

 

I did have one show record after the first try and before I fixed the transcoding error. It did convert to .mkv but the commercial removal was not entirely successful. The recording I made after fixing ffmpeg did not convert the .ts to .mkv but still gave the exit from posh.sh as a code 1.

Link to comment
Share on other sites

Baenwort

59bd95da14bc5_convert.jpg

Update for any other Premier subscribers. It seems that to make this work you have to turn off the built in Emby "Automatically convert recordings to a streaming friendly format

Recordings will be converted on the fly to MP4 or MKV for easy playback on your devices." as it results in a .mkv file being fed into post.sh instead of the .ts file.
 
Now that I've found that problem I'm still testing to see if I can actually get the commercials removed.

 

  • Like 1
Link to comment
Share on other sites

Baenwort

So I've reached the end of my knowledge and searching ability. I hope someone reading this can advise or provide a fresh idea to chase down.

 

If I leave checked the automatic conversion setting I get the below:

2017-09-16 12:30:00.138 Info App: Streaming Channel hdhr_21.3
2017-09-16 12:30:00.138 Info App: GetChannelStream: channel id: hdhr_21.3. stream id: native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4 profile: native
2017-09-16 12:30:00.138 Info HttpClient: HttpClientManager GET: http://192.168.1.175/discover.json
2017-09-16 12:30:00.150 Info App: Opening HDHR Live stream from http://192.168.1.175:5004/auto/v21.3
2017-09-16 12:30:00.150 Info HttpClient: HttpClientManager GET: http://192.168.1.175:5004/auto/v21.3
2017-09-16 12:30:00.368 Info App: Opened HDHR stream from http://192.168.1.175:5004/auto/v21.3
2017-09-16 12:30:00.368 Info App: Beginning multicastStream.CopyUntilCancelled
2017-09-16 12:30:00.368 Info App: Returning mediasource streamId 4be135c927f24525a0a6254c03fb4397native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4, mediaSource.Id 12664cef688b406aaeb8437f4f1c0d0a_native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4, mediaSource.LiveStreamId null
2017-09-16 12:30:00.368 Info App: Beginning recording. Will record for 29.9938542333333 minutes.
2017-09-16 12:30:00.368 Info App: Writing file to path: /media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv
2017-09-16 12:30:00.368 Info App: Opening recording stream from tuner provider
2017-09-16 12:30:00.368 Info App: /usr/pbi/emby-amd64/bin/ffmpeg -async 1 -vsync -1 -fflags +igndts -analyzeduration 5000000 -i "http://127.0.0.1:8096/LiveTv/LiveStreamFiles/e18198996c3e4a8fbd7208282989dfeb/stream.ts" -t 00:29:59.631 -codec:v:0 libx264 -force_key_frames "expr:gte(t,n_forced*5)"  -vf "yadif=0:-1:0" -pix_fmt yuv420p -preset superfast -crf 23 -b:v 25000000 -maxrate 25000000 -bufsize (25000000*2) -vsync -1 -profile:v high -level 41 -fflags +genpts -map_metadata -1 -threads 0 -codec:a:0 copy -sn -y "/media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv"
2017-09-16 12:30:00.582 Info App: ffmpeg recording process started for /media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv
...
2017-09-16 13:00:00.421 Info App: FFMpeg recording exited with code 0 for /media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv
2017-09-16 13:00:00.421 Info App: Recording completed to file /media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv
2017-09-16 13:00:00.421 Info App: Recording completed: /media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv
2017-09-16 13:00:00.421 Info App: Live stream 12664cef688b406aaeb8437f4f1c0d0a_native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4 consumer count is now 0
2017-09-16 13:00:00.421 Info App: Closing live stream 12664cef688b406aaeb8437f4f1c0d0a_native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4
2017-09-16 13:00:00.421 Info App: Closing HDHR live stream
2017-09-16 13:00:00.424 Info App: Live stream 12664cef688b406aaeb8437f4f1c0d0a_native_3c003f43265410b49b1bd7868f462f69_baf8abb560d559502ecc9097129a4db4 closed successfully
2017-09-16 13:00:00.427 Info App: Running recording post processor /post.sh "/media/Visual/TV Shows/LiveTV/Series/Lidia's Kitchen/Season 4/Lidia's Kitchen S04E18 Cheese.mkv"
2017-09-16 13:00:00.729 Info App: Recording post-processing script completed with exit code 1

If I turn it off I get the following:

2017-09-16 17:00:00.328 Info App: Opened HDHR stream from http://192.168.1.175:5004/auto/v21.2
2017-09-16 17:00:00.328 Info App: Beginning multicastStream.CopyUntilCancelled
2017-09-16 17:00:00.328 Info App: Returning mediasource streamId 4be135c927f24525a0a6254c03fb4397native_a3d8030cbaae6e0fae8ada703e70d88a_baf8abb560d559502ecc9097129a4db4, mediaSource.Id bcfc7c75e87549aead243ba2e08710c3_native_a3d8030cbaae6e0fae8ada703e70d88a_baf8abb560d559502ecc9097129a4db4, mediaSource.LiveStreamId null
2017-09-16 17:00:00.328 Info App: Beginning recording. Will record for 59.9945214833333 minutes.
2017-09-16 17:00:00.328 Info App: Writing file to path: /media/Visual/TV Shows/LiveTV/Series/The World's Most Famous Train/The World's Most Famous Train 2015-11-30.ts
2017-09-16 17:00:00.328 Info App: Opening recording stream from tuner provider
2017-09-16 17:00:00.369 Info App: Copying recording stream to file /media/Visual/TV Shows/LiveTV/Series/The World's Most Famous Train/The World's Most Famous Train 2015-11-30.ts
...
2017-09-16 18:00:00.157 Info App: Recording stopped: /media/Visual/TV Shows/LiveTV/Series/The World's Most Famous Train/The World's Most Famous Train 2015-11-30.ts
2017-09-16 18:00:00.157 Info App: Live stream bcfc7c75e87549aead243ba2e08710c3_native_a3d8030cbaae6e0fae8ada703e70d88a_baf8abb560d559502ecc9097129a4db4 consumer count is now 0
2017-09-16 18:00:00.157 Info App: Closing live stream bcfc7c75e87549aead243ba2e08710c3_native_a3d8030cbaae6e0fae8ada703e70d88a_baf8abb560d559502ecc9097129a4db4
2017-09-16 18:00:00.157 Info App: Closing HDHR live stream
2017-09-16 18:00:00.157 Info App: Live stream bcfc7c75e87549aead243ba2e08710c3_native_a3d8030cbaae6e0fae8ada703e70d88a_baf8abb560d559502ecc9097129a4db4 closed successfully
2017-09-16 18:00:00.161 Info App: Running recording post processor /post.sh "/media/Visual/TV Shows/LiveTV/Series/The World's Most Famous Train/The World's Most Famous Train 2015-11-30.ts"
2017-09-16 18:00:00.512 Info App: Recording post-processing script completed with exit code 1

Given how long it took to run I think there is an error in my post.sh but I can't see it.

#!/bin/csh

# Add bash path to Emby path.
set path = ($path /usr/local/bin)

# Sleep for a pseudorandom period (up to 10 seconds) to limit the number of instances that start at once 
sleep `echo $%10 | bc`

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

HandBrakeCLI -i "$1" -o "$1".mkv --format mkv --encoder x264 --quality 18 --loose-anamorphic --decomb eedi2 --x264-preset medium --h264-profile high --h264-level 4.1 --aencoder copy --all-subtitles

find /media/Visual/"TV Shows"/LiveTV -type f iname “*.ts.mkv” -exec sh -c ‘mv “$0” “S{0%.ts.mkv}.mkv”’ {} \;[

The only idea I have is to wipe out all my jails and rebuild them all from scratch to update the Emby jail to FreeNAS 9.11 as so far as I know the only way to update the FreeBSD version running in each jail is to wipe and rebuild them all.  I'd rather not do this due to the amount of work involved in re-configuring the plug-ins that are not as good as Emby about having a backup method.

Link to comment
Share on other sites

Baenwort

So it was pointed out to me that the --all-subtitles in the post.sh will not work. Instead I should use -s "1,2,3,4,5,6" as there are unlikely to be more than 6 subtitles and extra sub tracks will be ignored.  This fixed the post.sh completing with a code 1 nearly instantaneously but the resulting x264 mkv file still has commercials in it but it as at least encoded correctly so the HandbrakeCLI line is functioning.

 

The troubleshooting continues. Has anyone besides the OP followed these instructions and had it work completely successfully? 

Edited by Baenwort
Link to comment
Share on other sites

PhilWhite

Sorry, only just saw this.  Yes, there was a typo and it it should have been CC.  I have fixed that, thanks.

 

Commercial cutting is never perfect, and it varies from station to station.  In the US, it works very well for the main networks (ABC, CBS, and NBC) but less well in my experience with the CW.  I have not played with the comskip.ini file, but that is where you can alter how the commercials are cut.

 

There are clear limitations, since it will not cut anything if there is a ticker on either the top or bottom screen unless you change the comskip.ini file to all this -- the most common issue I have found is a weather ticker in times of bad weather.  It keys on the channel logo, so commercials that show a logo in the left or right corner of the screen will also not be cut.

 

Altering the comskip.ini file is a balancing act since you don't want to cut out parts of the program.  I've planned to change that version of comskip.ini (I just copied the original version from the Freenas thread), but I haven't gotten around to it yet.

 

I think I will change the ticker parameter this weekend to see what happens; that might fix the problem with commercial cutting when a weather ticker is present.  But I have no idea what to do with commercials that include a station or other logo.

Edited by PhilWhite
Link to comment
Share on other sites

  • 4 weeks later...
Baenwort

So I got this working at last by following the ffmpeg build instructions from https://emby.media/community/index.php?/topic/50820-freebsd-emby-ffmpeg/&do=findComment&comment=497966  and the imagemagic directions from the same post instead of using the package build for ffmpeg.

 

There are also a pair of errors in your comskip.ini as you have the connect_blocks_with_logo=1 logo_filter=0 lines doubled up and the cuttermaran_options= line split.

 

The only remaining problem I'm having is the find command is returning that there is nothing found:

find /media/Visual/"TV Shows"/LiveTV -type f iname “*.ts.mkv” -exec sh -c ‘mv “$0” “S{0%.ts.mkv}.mkv”’ {} \;[

Any ideas? 

 

I've found that searching the log for the post.sh and grabbing the line (such as /post.sh "/media/Visual/TV Shows/LiveTV/Series/Mystery Science Theater 3000/Season 5/Mystery Science Theater 3000 S05E01 Hercules.ts") and pasting it into a CLI for the emby jail has been very helpful in troubleshooting as the server log is unclear as to exactly what failed and how.

 

However this has failed to help me figure out the find command problem.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
PhilWhite

So I got this working at last by following the ffmpeg build instructions from https://emby.media/community/index.php?/topic/50820-freebsd-emby-ffmpeg/&do=findComment&comment=497966  and the imagemagic directions from the same post instead of using the package build for ffmpeg.

 

There are also a pair of errors in your comskip.ini as you have the connect_blocks_with_logo=1 logo_filter=0 lines doubled up and the cuttermaran_options= line split.

 

The only remaining problem I'm having is the find command is returning that there is nothing found:

find /media/Visual/"TV Shows"/LiveTV -type f iname “*.ts.mkv” -exec sh -c ‘mv “$0” “S{0%.ts.mkv}.mkv”’ {} \;[

Any ideas? 

 

I've found that searching the log for the post.sh and grabbing the line (such as /post.sh "/media/Visual/TV Shows/LiveTV/Series/Mystery Science Theater 3000/Season 5/Mystery Science Theater 3000 S05E01 Hercules.ts") and pasting it into a CLI for the emby jail has been very helpful in troubleshooting as the server log is unclear as to exactly what failed and how.

 

However this has failed to help me figure out the find command problem.

 

 

Sorry, I haven't look back at this for quite a while.  I've been pretty busy with RL, so give me a few days and I will hopefully be able to help.

Link to comment
Share on other sites

warrentc3

Again, don't know if this is at all helpful, but if anyone finds it useful then it was worth posting. Any comments or suggestions would be greatly appreciated.

 

Thanks for this, Phil!  It was a big help to me in trying to automate away from MCE Buddy.  +1000 kudos

 

A few things I added/changed/did differently.  

 

I added a cron job that would execute on a daily schedule to relocate the *.ts files for archival and/or deletion.

## installed nano
pkg install nano
nano .cshrc -- Then change/add these lines to
setenv  EDITOR  nano
## pull Comskip/comchap from git
mkdir /usr/local/comchap
mkdir /usr/local/Comskip
cd /usr/local 
git clone --depth 1 git://github.com/erikkaashoek/Comskip
cd /usr/local/Comskip
./autogen.sh
./configure
make
cd /usr/local 
git clone --depth 1 https://github.com/BrettSheleski/comchap
## added symlinks for convenience
ln -s /usr/local/bin/nano /usr/bin/nano
ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg
ln -s /usr/local/Comskip/comskip /usr/bin/comskip
ln -s /usr/local/comchap/comcut /usr/bin/comcut
ln -s /usr/local/comchap/comchap /usr/bin/comchap

Did the post script a bit differently as I also brought over my own handbrake preset .json file and tidied up the extensions.

 

Link to my comskip.ini file and handbrake preset:    https://github.com/warrentc3/stuff_for_media

edited to fix the file path variables for more accurate cshell execution. see next post...
Edited by warrentc3
  • Like 2
Link to comment
Share on other sites

warrentc3

set filename = `printf "%s\" ${1}:h "/" $1:t:r:r`

set grab = `printf "%s\" ${1}:h`
 
set b = `echo $grab/$filename--cut.ts`
set c = `echo $grab/$filename.mp4`
 

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

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

 

I really could use some help on this from someone with more cshell experience.  

 

EDIT.... after fighting with this to get it just right for longer than I care to admit...

#!/bin/csh
set path = ($path /usr/local/bin)
set w1 = `jot -r 1 2 15`
set filename = `printf "%s " $1:t:r:r` 
set grab = `printf "%s " $1:h` 
set a = `echo "$filename".ts` 
set b = `echo "$grab/$filename"_cut.ts` 
set c = `echo "$grab/$filename".mp4` 
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 ( ! `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

rm $b
mv "$1" "/media/PlexDVR/.plexignore/$a"

Edited by warrentc3
  • Like 2
Link to comment
Share on other sites

PhilWhite

Baenwort,

 

Sorry it took me so long to get back to you.  When you run the /post.sh file do you end up with a file with the extension .ts.mkv or one with only .ts or .mkv?  It may not be finding anything because the extension is different the way you have it set up?

 

Also, the [ at the end of the line with the find command is just a typo, I'm afraid.  I didn't do a very good job of proof-reading any of this, sorry.

 

Maybe the extra bracket at the end is messing up the line?

Edited by PhilWhite
Link to comment
Share on other sites

Baenwort

a file with the extension .ts.mkv is created.

 

Also, in you OP directions you've got another mistype that is causing problems. you have: 

pkg set -o devel/pkg-config:devel/pgkconf

and it should be:

pkg set -o devel/pkg-config:devel/pkgconf
Link to comment
Share on other sites

  • 2 weeks later...
warrentc3

 

a file with the extension .ts.mkv is created.

 

 

A .ts file is on purpose.  That's the unencoded mpeg2 stream extension.  This way comcut works with the native mpeg2 file created from hdhr.  I actually am still using Plex for DVR right now, so the TS file makes the most sense.

  • Like 1
Link to comment
Share on other sites

FreeBSD_Lover

Yeah I'm still using Plex with HDHomeRun to do the recording, but that will likely change soon.  Either way, I intend on finding a nice FreeBSD program (port) to transcode and edit the TV shows.  I'll transcode to .mp4 or .avi, but I'll watch the video first, make a note of the commercial time stamps, and then edit them out.

 

Actually, now that I am using free OTA (Over The Air), I kinda appreciate the commercials. Didn't expect that; its like hey this is free because of these shampoo and shiny car commercials.  :P

Link to comment
Share on other sites

  • 2 weeks later...
Baenwort

A .ts file is on purpose.  That's the unencoded mpeg2 stream extension.  This way comcut works with the native mpeg2 file created from hdhr.  I actually am still using Plex for DVR right now, so the TS file makes the most sense.

 

Yes, but at the end of the conversion process, per the OP and how I have it setup, Handbrake is run and generates at .ts.mkv file that needs to be renamed by the final line of post.sh; however, it does not accomplish this with the current command and I was alerting the OP so that he could correct what ever error was in that line as he has had to do several times for other errors in the OP. 

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
elmerF

AND...  it worked! Newbie in the freenas world using 11.1, and this actually worked! Used the multiple corrections of Baenwort. Hope it can weather the upgrade to 11.2.  Also, hope PhilWhite keeps this updated. Thanks all! 

Link to comment
Share on other sites

  • 5 weeks later...
PhilWhite

Sorry about all the typos.  I think I corrected them all.  If anyone else ever uses this please let me know if there are any problems.  I've been away for a while but will check back more frequently to check just in case.

  • Like 1
Link to comment
Share on other sites

  • 5 weeks later...
Arkitct

Following the instructions, I just tried to compile Comskip and received the following error:

 

mv -f ccextratorwin/.deps/comskip-myth.Tpo ccextratorwin/.deps/comskip-myth.Po gcc5 -g -O2 -o comskip comskip-comskip.o comskip-mpeg2dec.o  comskip-platform.o comskip-video_out_dx.o  ccextratorwin/comskip-608.o  ccextratorwin/comskip-ccextractor.o  ccextratorwin/comskip-encoding.o  ccextratorwin/comskip-general_loop.o  ccextratorwin/comskip-myth.o -L/usr/local/lib -largtable2 -L/usr/local/lib -lavutil -lavformat -lavcodec  -lpthread -lm
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Final'
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Update'
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Init'
collect2: error: ld returned 1 exit status
*** Error code 1

Stop.

Searched for others encountering this to no avail.

 

Has anyone else run into this and found a fix?

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...
PhilWhite

Following the instructions, I just tried to compile Comskip and received the following error:

 

mv -f ccextratorwin/.deps/comskip-myth.Tpo ccextratorwin/.deps/comskip-myth.Po gcc5 -g -O2 -o comskip comskip-comskip.o comskip-mpeg2dec.o  comskip-platform.o comskip-video_out_dx.o  ccextratorwin/comskip-608.o  ccextratorwin/comskip-ccextractor.o  ccextratorwin/comskip-encoding.o  ccextratorwin/comskip-general_loop.o  ccextratorwin/comskip-myth.o -L/usr/local/lib -largtable2 -L/usr/local/lib -lavutil -lavformat -lavcodec  -lpthread -lm
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Final'
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Update'
//usr/local/lib/libx265.so.160: undefined reference to `_libmd_MD5Init'
collect2: error: ld returned 1 exit status
*** Error code 1

Stop.

Searched for others encountering this to no avail.

 

Has anyone else run into this and found a fix?

 

Thanks!

Hi, just saw this.

 

Not sure I can help, especially since I don't understand why it is trying to move those files.  It may be an issue of trying to compile comskip in a particular environment?  What type of jail are you using -- a warden jail or iocage?  And, if iocage, did you create the jail with Freenas 11.1 or 11.2 or an earlier version?

 

There is also a newer version of gcc, namely gcc6 that you might try to use (especially if you are on Freenas 11.2) and see if that works since there may have been some changes to the the most recent version of comskip that Eric makes available.

 

I'm afraid I haven't tried to run this in several months so I don't know what changes might have impacted it.  Please let us know if any of those possibilities work or if there might be a bigger issue at play.

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