Manually run the Commerical removal

How can I manually run the commerical removal program?

I want to be able to test that it is correctly working and not removing parts of the programs. Its auto execution is turned off and I want to keep it that way until I can test it and confirm it is working correctly.

Server Version#: 1.19.3.2764 (running in a docker on Ubuntu 18)
Tuner Make/Model: HDHomeRun Duo

The program that Plex uses is called comskip and is typically found in /usr/local/bin on an Ubuntu box. You can find out by typing which comskip at CLI. Comskip uses an INI file to get its settings from at run time. The one for Plex is in the /usr/lib/plexmediaserver/Resources/ directory. There are ways to customize the INI file and there is a sister application called comchap that will add chapter markers to files if they are converted to MKV. MPEG TS files don’t support chapters. To manually run, you will want to write a small script to call the program against the out of box INI file and test how it works.

Thanks. I can’t find the comskip executable file in the docker file system, I have tried using a WHICH and FIND command, but there is no file called comskip within the docker!

I am running what I think is the official docker image “plexinc/pms-docker:latest)”.

Does this sound like the issue?
Any idea how I can fix it?
Do I need to take the issue to the docker sub-forum?

Plex Media Server uses a customized version of comskip named “Plex Commercial Skipper.” It’s located in:

/usr/lib/plexmediaserver/

To run successfully, it requires a couple of environment variables to be set correctly: EAE_ROOT and FFMPEG_EXTERNAL_LIBS. The values to which these are set vary by version. But, if you set up commercial skipping for a test show, you can check the logs to see what should be used (search for “Plex Commercial Skipper”). You may just be able to play a video and force a transcode as well, as Plex Transcoder uses the same environment variables. In that case, search for “Plex Transcoder” in the logs.

I have made some progress and can get the program to run. But it now reports an error with the codecs.

How should I go about set the two enviroment variables? And these the things I set when the container is created in docker?

How do I know what to set them to?

I have search for quite a while before getting stuck. Thanks.

[mpegts @ 0x3c97340] Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels): unspecified sample rate
Consider increasing the value for the ‘analyzeduration’ and ‘probesize’ options
Input #0, mpegts, from ‘/data/kids_films/Madagascar (2005)/Madagascar (2005).ts’:
Duration: 01:39:56.66, start: 1.400000, bitrate: 5062 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), none(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50 tbr, 90k tbn, 90k tbc
Stream #0:10x101: Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels
Stream #0:20x102: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Unsupported codec!
Could not open video codec
/data/kids_films/Madagascar (2005)/Madagascar (2005).ts: could not open video codec

On my Linux test server, FFMPEG_EXTERNAL_LIBS is set here:
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Codecs/99c90e0-3095-linux-x86_64

You should have a similar path on your system. I don’t use Docker, but I’d assume it would be close.

EAE_ROOT is set here on the same system (it could be different on yours):

/tmp/pms-b8168c54-cabb-4f54-93c1-2aa2652cdbfa/EasyAudioEncoder

As I mentioned above, the best way way to determine the correct values to use for your system would be to do a test recording with commercial skipping enabled, or force a transcode during playback of a video. You can then search for the those variables in your PMS logs.

1 Like

Brilliant. Making some progress here! It now runs, produces the log files and is detecting the commercials. But
 it is not updating the .ts file!

Why is it not updating the file? Is the file it updating going somewhere else?

The command I am running is:

/usr/lib/plexmediaserver/Plex\ Commercial\ Skipper /config/ScoobyDoo.ts

The files in the directory are:

drwxrwxrwx 3 plex plex 4096 Apr 8 19:10 Library
-rwxrwxrwx 1 plex plex 695888204 May 11 08:56 ScoobyDoo.ts
drwxrwxrwx 2 plex plex 4096 May 11 18:38 _data
-rwxrwxrwx 1 plex plex 7161 May 11 18:56 comskip.ini
-rwxrwxrwx 1 root root 695888204 May 11 20:44 Scooby.ts.bup
-rwxrwxrwx 1 root root 4999 May 11 20:44 Scooby.logo.txt
-rwxrwxrwx 1 root root 102 May 11 21:17 Scooby.txt
-rwxrwxrwx 1 root root 32 May 11 21:17 Scooby.edl
-rwxrwxrwx 1 root root 284135 May 11 21:17 Scooby.log
-rw-r–r-- 1 root root 4999 May 11 21:26 ScoobyDoo.logo.txt
-rwxrwxrwx 1 plex plex 72 May 11 22:01 testscript.sh
-rw-r–r-- 1 root root 102 May 11 22:03 ScoobyDoo.txt
-rw-r–r-- 1 root root 32 May 11 22:03 ScoobyDoo.edl
-rw-r–r-- 1 root root 113883 May 11 22:03 ScoobyDoo.log

Removing commercials is a multi-step process. The above is just the first part. It creates the EDL file, which contains the list of commercial segments. Plex, through some process about which I have no clue, turns that into a segment list file. That then gets fed to the transcoder along with the original recording to remove the commercial segments. The final result is then assimilated into the the library.

There are a couple of steps which aren’t explicitly logged as far as I can tell. The above-mentioned creation of the segment list being chief among them. Perhaps they are logged with verbose logging enabled; I haven’t tested that.

At any rate, the best I can suggest is for you to record a test show with commercial skipping enabled and then have a look at your Plex Media Server log to see exactly what Plex does.

comskip needs a script called comcut to actually alter the .ts file. All comskip does is produce the edl file to get the commercial markers by frame. I don’t do docker, but comcut is in same place as comskip on my system. There is also another tool called comchap that creates chapter markers in mkv files. TS files don’t support chapters.

Thank you. I have made one change to the docker, to add an enviroment variable. (I use portainer).

FFMPEG_EXTERNAL_LIBS /config/Library/Application Support/Plex Media Server/Codecs/99c90e0-3095-linux-x86_64/

The automatic comskip process on new recordings seems to be working. I cannot get it to work on existing recordings, but new ones work correctly.

The command to run it is a test mode from within docker is below.

When you see plex running the process in htop it has passed the --ini parameter, so you also need to do it when testing.

Do be aware that this will not remove the adverts, just generate a .txt file that tells the frames to be removed. For this you need to use the related ‘comclean’ process. I am not sure yet how this is implemented in plex.

/usr/lib/plexmediaserver/Plex\ Commercial\ Skipper Cheers\ (1982)\ -\ S05E26\ -\ I\ Do\ Adieu.ts --ini=/config/Library/Application\ Support/Plex\ Media\Server/DVR/comskip.ini

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.