NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Linux v
« Previous 1 … 21 22 23 24 25 … 34 Next »
bulk comskip processing script

 
  • 0 Vote(s) - 0 Average
bulk comskip processing script
baj1
Offline

Senior Member

Maple Grove, MN, USA
Posts: 553
Threads: 91
Joined: Jan 2006
#1
2020-11-10, 08:11 AM
I made some headway here and thought I'd share.  I have a pretty decent volume of saved recordings, many of which have old comskip files from many versions ago.  I don't know if I'm saying this right, but as I understand it they trip up Kodi/knewc due to the edl_skip_field setting.  It defaults to 0=cut and you will not be able to play portions of the video marked as commercials.  Setting it to a value = 3 will allow playback of the commercial marked portions. 

Anywho, my solution was to re-run comskip on all of these recordings so I started a bash script to handle it in bulk in Linux.  I'm far from a bash guru but was able to piece together some code with a lot of help from other forums and Martin's PostProcessing.sh example.  Here it is:



Code:
#! /bin/bash
# comskip_subfolders.sh
# This script will bulk-process TS files in sub-folders.  Execute in your root Video folder and it will run comskip on all TS files in all the "show" subfolders
# nice eases CPU use, range is -20 (fastest/highest CPU usage) to 19 (slowest/least CPU usage), negative values require sudo

for d in */; do
    echo "Processing Folder $d"
    cd "$d"
    for file in *.ts
    do
      echo "Processing file " $file
      nice -n 19 comskip --ini=/home/<username>/Comskip/comskip.ini "$file" > /dev/null
    done
    cd ..
done

Just paste the code into your favorite text editor and change <username> to your user, or modify the path completely if you installed Comskip elsewhere.  Save the contents to your ~/bin folder and don't forget to chmod +x to make it executable.  If you haven't already you might want to make sure you've set edl_skip_field = 3 in your comskip.ini, or add that line to the end of the ini file if needed.

Change the nice value if you like.  I have a new server with a 6-core 3.6GHz CPU and I was running two instances of the script (in two separate folders) with nice @ "2" and each instance was showing about 240% utilization in System Monitor.  It was processing 1 hour shows in around 100 seconds, although this did vary with the particular show it was processing.

Disclaimer!  As stated I am FAR from a bash guru, use at your own risk!  It worked on my single-depth subfolder structure of my Video (recordings) folder.

I hope someone finds this useful.  This is v1.0, so I'm open to feedback/improvements.

Cheers,
-Brad
Server: Ryzen 5 3600 3.6GHz: 16GB RAM: ASRock Phantom D/RX570: SDD: 512GB HDDs: 5TB, 8TB, 8TB
Linux Mint v20, NPVR v5.1.3.210711
Tuners: Hauppauge PVR-2250-MC Dual Tuner, HDHR Duo ATSC Tuner
Clients: Knewc on CE-ODroid N2 x2, N2+, LE-RPi4, PCs x2
ElihuRozen
Offline

Senior Member

Massachusetts, USA
Posts: 514
Threads: 51
Joined: Apr 2006
#2
2020-11-10, 04:36 PM
If you wanted to do this from a single command line, the find command might be useful for you (note that this will not display each file as it is processed, which your script does do):

Code:
find . -name "*.ts" -exec nice -n 19 comskip --ini=$HOME/Comskip/comskip.ini "{}" >/dev/null 2>&1 \;


where:
find - command that we are running to find all videos in any subdirectories
. - top level directory to start search.  In this case, the current directory
-name "*.ts" - what to search for.  In this case, any file with a .ts extension
-exec - what to do with each file we find.  In this case, execute the command that follows
nice -n 19 comskip --ini=$HOME/Comskip/comskip.ini - the actual command to execute
"{}" - this is substituted with the actual file name for each file we find
>/dev/null - get rid of all standard output
2>&1 - redirect standard error to standard out.  In this case, get rid of any error messages since standard out is going to /dev/null
\; - this is needed to mark the end of the command that -exec will execute
Tuners: SD HDHR Prime (HDHR3-CC). SD HDHR Connect Quatro Tuner (HDHR5-4US) - only QAM.  EXVIST H.265 Encoder - capturing cable box.
Client: Odroid-N2 running knewc on KODI - connected via MoCA.
EPG: SchedulesDirect
Provider: Verizon Fios
Server: Dell XPS 8700 with Windows 10
VCR58
Offline

Posting Freak

Marion Iowa, USA
Posts: 1,838
Threads: 177
Joined: Aug 2016
#3
2020-11-10, 04:40 PM
(2020-11-10, 08:11 AM)baj1 Wrote: I made some headway here and thought I'd share.  I have a pretty decent volume of saved recordings, many of which have old comskip files from many versions ago.  I don't know if I'm saying this right, but as I understand it they trip up Kodi/knewc due to the edl_skip_field setting.  It defaults to 0=cut and you will not be able to play portions of the video marked as commercials.  Setting it to a value = 3 will allow playback of the commercial marked portions. 

Anywho, my solution was to re-run comskip on all of these recordings so I started a bash script to handle it in bulk in Linux.  I'm far from a bash guru but was able to piece together some code with a lot of help from other forums and Martin's PostProcessing.sh example.  Here it is:



Code:
#! /bin/bash
# comskip_subfolders.sh
# This script will bulk-process TS files in sub-folders.  Execute in your root Video folder and it will run comskip on all TS files in all the "show" subfolders
# nice eases CPU use, range is -20 (fastest/highest CPU usage) to 19 (slowest/least CPU usage), negative values require sudo

for d in */; do
    echo "Processing Folder $d"
    cd "$d"
    for file in *.ts
    do
      echo "Processing file " $file
      nice -n 19 comskip --ini=/home/<username>/Comskip/comskip.ini "$file" > /dev/null
    done
    cd ..
done

Just paste the code into your favorite text editor and change <username> to your user, or modify the path completely if you installed Comskip elsewhere.  Save the contents to your ~/bin folder and don't forget to chmod +x to make it executable.  If you haven't already you might want to make sure you've set edl_skip_field = 3 in your comskip.ini, or add that line to the end of the ini file if needed.

Change the nice value if you like.  I have a new server with a 6-core 3.6GHz CPU and I was running two instances of the script (in two separate folders) with nice @ "2" and each instance was showing about 240% utilization in System Monitor.  It was processing 1 hour shows in around 100 seconds, although this did vary with the particular show it was processing.

Disclaimer!  As stated I am FAR from a bash guru, use at your own risk!  It worked on my single-depth subfolder structure of my Video (recordings) folder.

I hope someone finds this useful.  This is v1.0, so I'm open to feedback/improvements.

Cheers,
-Brad

Hi Brad,

Thanks for the bash script! I was searching around for something like this after getting comskip running on my Linux NextPVR server.

I have a question concerning the usage of the script. I have all my shows in a directory called 'Recorded TV',  the full path is /mnt/sda1/'Recorded TV'. So would I just run comskip_subfolders.sh or do I need to add the folder after the command?

Sorry, I'm a newbe to comskip, and bash, and linux.

Thanks, Rex
baj1
Offline

Senior Member

Maple Grove, MN, USA
Posts: 553
Threads: 91
Joined: Jan 2006
#4
2020-11-10, 06:16 PM
No worries, I'm still learning too. I made the script to run in what would be your "Recorded TV" folder. If the folder where the script is located is not in your path, you will need to include it when executing the command. I put my bash scripts in a subfolder of my home called "bin". If you did the same, you would execute like this in a terminal:

$ cd /mnt/sda1/Recorded\ TV
$ ~/bin/comskip_subfolder.sh

'~' is a shortcut for your home folder path.

You could always make a set of test folders if you are unsure, but there's really no harm in trying it because if it doesn't find any TS files it doesn't do anything.
Server: Ryzen 5 3600 3.6GHz: 16GB RAM: ASRock Phantom D/RX570: SDD: 512GB HDDs: 5TB, 8TB, 8TB
Linux Mint v20, NPVR v5.1.3.210711
Tuners: Hauppauge PVR-2250-MC Dual Tuner, HDHR Duo ATSC Tuner
Clients: Knewc on CE-ODroid N2 x2, N2+, LE-RPi4, PCs x2
baj1
Offline

Senior Member

Maple Grove, MN, USA
Posts: 553
Threads: 91
Joined: Jan 2006
#5
2020-11-10, 06:21 PM
(2020-11-10, 04:36 PM)ElihuRozen Wrote: If you wanted to do this from a single command line, the find command might be useful for you (note that this will not display each file as it is processed, which your script does do):

Code:
find . -name "*.ts" -exec nice -n 19 comskip --ini=$HOME/Comskip/comskip.ini "{}" >/dev/null 2>&1 \;


where:
find - command that we are running to find all videos in any subdirectories
. - top level directory to start search.  In this case, the current directory
-name "*.ts" - what to search for.  In this case, any file with a .ts extension
-exec - what to do with each file we find.  In this case, execute the command that follows
nice -n 19 comskip --ini=$HOME/Comskip/comskip.ini - the actual command to execute
"{}" - this is substituted with the actual file name for each file we find
>/dev/null - get rid of all standard output
2>&1 - redirect standard error to standard out.  In this case, get rid of any error messages since standard out is going to /dev/null
\; - this is needed to mark the end of the command that -exec will execute

Thanks!  I figured someone would know a more efficient way of doing this, and I do like to learn so thanks for the info.

My 2 instances have been crunching away since late last night and are only on the C's in one folder and the F's in another, so I'm glad I have the echo status lines to show progress.
Server: Ryzen 5 3600 3.6GHz: 16GB RAM: ASRock Phantom D/RX570: SDD: 512GB HDDs: 5TB, 8TB, 8TB
Linux Mint v20, NPVR v5.1.3.210711
Tuners: Hauppauge PVR-2250-MC Dual Tuner, HDHR Duo ATSC Tuner
Clients: Knewc on CE-ODroid N2 x2, N2+, LE-RPi4, PCs x2
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,766
Threads: 954
Joined: May 2006
#6
2020-11-10, 07:09 PM (This post was last modified: 2020-11-10, 07:47 PM by mvallevand.)
I would have just used sed to fix my comskip.ini files

sed -e 's/0$/3/'g

changes the trailing 0 to 3 on each line

Code:
find folder -name "*.edl" -exec  sed -i -e 's/0$/3/'g {} +

Martin
baj1
Offline

Senior Member

Maple Grove, MN, USA
Posts: 553
Threads: 91
Joined: Jan 2006
#7
2020-11-10, 08:31 PM
Thanks Martin. I had done that manually on a couple files and was thinking that would be harder to do, guess not. Should be super fast too since it doesn't have to re-process the TS files.
Server: Ryzen 5 3600 3.6GHz: 16GB RAM: ASRock Phantom D/RX570: SDD: 512GB HDDs: 5TB, 8TB, 8TB
Linux Mint v20, NPVR v5.1.3.210711
Tuners: Hauppauge PVR-2250-MC Dual Tuner, HDHR Duo ATSC Tuner
Clients: Knewc on CE-ODroid N2 x2, N2+, LE-RPi4, PCs x2
baj1
Offline

Senior Member

Maple Grove, MN, USA
Posts: 553
Threads: 91
Joined: Jan 2006
#8
2020-11-21, 08:44 PM (This post was last modified: 2020-11-22, 04:16 PM by baj1.)
So I guess I really wanted an edl setting of 2 not 3. With 3 it automatically skips the commercials. we prefer to do it manually because comskip isn't always perfect. Weird that on both LibreELEC and CoreELEC clients that they worked like "2" with a "3" in the .edl files. It was just the local Kodi-knewc client that was autoskipping with the "3".

Simple update to comskip.ini to fix future recordings.

Thanks again Martin, your script worked great for updating the edl settings for the bazillion recordings we already have. :-)
Server: Ryzen 5 3600 3.6GHz: 16GB RAM: ASRock Phantom D/RX570: SDD: 512GB HDDs: 5TB, 8TB, 8TB
Linux Mint v20, NPVR v5.1.3.210711
Tuners: Hauppauge PVR-2250-MC Dual Tuner, HDHR Duo ATSC Tuner
Clients: Knewc on CE-ODroid N2 x2, N2+, LE-RPi4, PCs x2
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  NextPVR 7 looses recordings after post processing ballfam 15 807 2024-12-20, 03:23 AM
Last Post: ballfam
  Remote NextPVR backup script for Linux snagglewest 2 585 2024-02-06, 05:44 PM
Last Post: snagglewest
  Post Processing and moving files ballfam 16 2,461 2022-12-30, 06:59 PM
Last Post: ballfam
  Think all the script files must've disappeared mlp78758 13 1,563 2022-11-25, 05:34 PM
Last Post: mvallevand
  Comskip fail Armsp0 6 1,364 2022-02-09, 11:19 PM
Last Post: Armsp0
  Linux upgrade shell script.. NextPVR-consumer 3 1,183 2021-12-05, 03:17 PM
Last Post: mvallevand
  comskip failing with segmentation fault CDinger 1 1,052 2021-05-10, 12:40 PM
Last Post: mvallevand
  Had comskip working, now it's not. baj1 11 2,712 2020-11-02, 12:02 AM
Last Post: baj1
  Script locations and parameters ? ceejayemm 2 1,242 2020-10-14, 12:02 PM
Last Post: ceejayemm
  Raspberry pi comskip DavidD 11 3,839 2020-06-29, 08:54 PM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode