Jump to content

Recording post-processing


crusher11
Go to solution Solved by Q-Droid,

Recommended Posts

crusher11

I'm trying to get comskip to run on my recordings. If I SSH into the comskip folder and run:

comskip --ini=../var/comskip.ini "/volume1/Emby Libraries/Recordings/[Show]/[Episode].ts"

it works, and I get an EDL sitting alongside my episode.

But I can't figure out how to achieve that with the post-processing within Emby. I've tried getting it to run a comskip.sh file, I've tried getting it to just run /bin/sh and putting the entire above statement in the "arguments" field...nothing happens.

Link to comment
Share on other sites

crusher11
23 minutes ago, Luke said:

Hi, what exactly did you configure in emby server?

1266178134_Screenshot2022-05-1823_56_56.png.a25720c4b0022345130e3504c14e035b.png

 

Contents of comskip.sh:

 #!/bin/sh
CSDIR=$(dirname $0)

${CSDIR}/comskip --ini=${CSDIR}/../var/comskip.ini "${1}" 

 

But it's throwing this error:

2022-05-18 23:51:24.518 Info LiveTV: Running recording post processor /volume1/@appstore/comskip/bin/comskip.sh /volume1/Emby Libraries/Recordings/The Mafia's Greatest Hits/Season 1/The Mafia's Greatest Hits S01E05 Mob Cops.ts
2022-05-18 23:51:24.540 Error LiveTV: Error running recording post processor
	*** Error Report ***
	Version: 4.7.0.35
	Command line: /volume1/@appstore/EmbyServer/system/EmbyServer.dll -programdata /volume1/Emby -ffdetect /var/packages/EmbyServer/target/bin/ffdetect -ffmpeg /var/packages/EmbyServer/target/bin/ffmpeg -ffprobe /var/packages/EmbyServer/target/bin/ffprobe -nolocalportconfig -ignore_vaapi_enabled_flag -pidfile /volume1/Emby/EmbyServer.pid -defaultdirectory /volume1/Public -updatepackage emby-server-synology_{version}_x86_64.spk
	Operating system: Linux version 4.4.59+ (root@build2) (gcc version 4.9.3 20150311 (prerelease) (crosstool-NG 1.20.0) ) #25556 SMP PREEMPT Sat Aug 28 02:16:43 CST 2021
	Framework: .NET 6.0.2
	OS/Process: x64/x64
	Runtime: volume1/@appstore/EmbyServer/system/System.Private.CoreLib.dll
	Processor count: 4
	Data path: /volume1/Emby
	Application path: /volume1/@appstore/EmbyServer/system
	System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/volume1/@appstore/comskip/bin/comskip.sh' with working directory '/'. Exec format error
	   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
	   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
	   at Emby.Server.Implementations.Diagnostics.CommonProcess.Start()
	   at Emby.LiveTV.EmbyTV.PostProcessRecording(ActiveRecordingInfo recordingInfo)
	Source: System.Diagnostics.Process
	TargetSite: Boolean ForkAndExecProcess(System.Diagnostics.ProcessStartInfo, System.String, System.String[], System.String[], System.String, Boolean, UInt32, UInt32, UInt32[], Int32 ByRef, Int32 ByRef, Int32 ByRef, Boolean, Boolean)

 

Link to comment
Share on other sites

Have you tested the sh? Maybe try just pointing it to comskip directly rather than the sh.

Link to comment
Share on other sites

crusher11
6 minutes ago, Luke said:

Have you tested the sh? Maybe try just pointing it to comskip directly rather than the sh.

I'm not sure how to test it.

I need to be able to specify the ini file, thus the sh.

Link to comment
Share on other sites

I would try testing it by executing it on a command line, since that is essentially how the server will try to run it as well.

Link to comment
Share on other sites

crusher11
1 minute ago, Luke said:

I would try testing it by executing it on a command line, since that is essentially how the server will try to run it as well.

I'm not sure what exactly to run, though. Is it just

comskip.sh "/volume1/Emby Libraries/Recordings/The Mafia's Greatest Hits/Season 1/The Mafia's Greatest Hits S01E05 Mob Cops.ts"

from the directory with comskip.sh? Because that throws the error "-sh: comskip.sh: command not found".

Link to comment
Share on other sites

That looks right to me, but it's your script and your environment, so obviously I can't say if it will actually work or not.

Quote

Because that throws the error "-sh: comskip.sh: command not found".

If you can't run it from a terminal, then Emby Server won't be able to run it either. So I would use the terminal to figure out what your command is going to be, get it working there, then you can configure the same thing in Emby Server.

Link to comment
Share on other sites

crusher11
Just now, Luke said:

That looks right to me, but it's your script and your environment, so obviously I can't say if it will actually work or not.

But in Emby, I just call the sh and Emby itself handles how the path is thrown into the mix, so I wasn't sure how to phrase that.

I have no idea what command it's not finding?

Link to comment
Share on other sites

CBers
5 minutes ago, crusher11 said:

But in Emby, I just call the sh and Emby itself handles how the path is thrown into the mix, so I wasn't sure how to phrase that.

I have no idea what command it's not finding?

Looks like the executable isn't in $PATH, so use the full path name to any executables you are calling in the script. 

 

Edited by CBers
Link to comment
Share on other sites

crusher11

What executable? comskip and comskip.sh are in the same folder as each other, and I ran the terminal command from that folder.

Link to comment
Share on other sites

Q-Droid

 

@Luke, but running this from a shell would not be running it as the Emby runtime process owner, right? So @crusher11 needs to make sure the emby server can access and execute the script.

The server is trying to execute the script using the full path so do the same from the shell command line. The script is very simple and is written expecting path info to find the ini file.

If you run it from the shell then use the same call Emby is making: /volume1/@appstore/comskip/bin/comskip.sh "/volume1/Emby Libraries/Recordings/The Mafia's Greatest Hits/Season 1/The Mafia's Greatest Hits S01E05 Mob Cops.ts". Otherwise it can't find things because no test is in the script to make sure the path is correct.

The alternative is to use full path within the script for both the comskip exe and the ini files. Probably the simplest but less portable option.

Link to comment
Share on other sites

1 minute ago, Q-Droid said:

 

@Luke, but running this from a shell would not be running it as the Emby runtime process owner, right? So @crusher11 needs to make sure the emby server can access and execute the script.

Yes that is also true as well.

Link to comment
Share on other sites

crusher11
Just now, Q-Droid said:

If you run it from the shell then use the same call Emby is making: /volume1/@appstore/comskip/bin/comskip.sh "/volume1/Emby Libraries/Recordings/The Mafia's Greatest Hits/Season 1/The Mafia's Greatest Hits S01E05 Mob Cops.ts". Otherwise it can't find things because no test is in the script to make sure the path is correct.

/volume1/@appstore/comskip/bin/comskip.sh: line 3: $'\r': command not found
/volume1/@appstore/comskip/bin/comskip.sh: line 4: /volume1/@appstore/comskip/bin/comskip: no such file or directory

Link to comment
Share on other sites

Q-Droid

Ok. I think the shell doesn't like the expressions used in the script. Remove the CSDIR entries, all of the dirname line, and use full paths to comskip exec and ini files. 

 

 

 

Link to comment
Share on other sites

crusher11

That works in the terminal but still fails within Emby.

Edited by crusher11
Link to comment
Share on other sites

crusher11

I have no idea? It's erroring in "working directory '/'", which doesn't even make sense.

Link to comment
Share on other sites

crusher11

It's the same error as last time, as far as I can tell.

2022-05-19 01:55:24.824 Info LiveTV: Running recording post processor /volume1/@appstore/comskip/bin/comskip.sh /volume1/Emby Libraries/Recordings/Late Show With Stephen Colbert (2015)/Season 7/Late Show With Stephen Colbert S07E181 GUESTS 2022 - Ricky Gervais, Trombone Shorty.ts
2022-05-19 01:55:24.825 Error LiveTV: Error running recording post processor
	*** Error Report ***
	Version: 4.7.0.35
	Command line: /volume1/@appstore/EmbyServer/system/EmbyServer.dll -programdata /volume1/Emby -ffdetect /var/packages/EmbyServer/target/bin/ffdetect -ffmpeg /var/packages/EmbyServer/target/bin/ffmpeg -ffprobe /var/packages/EmbyServer/target/bin/ffprobe -nolocalportconfig -ignore_vaapi_enabled_flag -pidfile /volume1/Emby/EmbyServer.pid -defaultdirectory /volume1/Public -updatepackage emby-server-synology_{version}_x86_64.spk
	Operating system: Linux version 4.4.59+ (root@build2) (gcc version 4.9.3 20150311 (prerelease) (crosstool-NG 1.20.0) ) #25556 SMP PREEMPT Sat Aug 28 02:16:43 CST 2021
	Framework: .NET 6.0.2
	OS/Process: x64/x64
	Runtime: volume1/@appstore/EmbyServer/system/System.Private.CoreLib.dll
	Processor count: 4
	Data path: /volume1/Emby
	Application path: /volume1/@appstore/EmbyServer/system
	System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/volume1/@appstore/comskip/bin/comskip.sh' with working directory '/'. Exec format error
	   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
	   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
	   at Emby.Server.Implementations.Diagnostics.CommonProcess.Start()
	   at Emby.LiveTV.EmbyTV.PostProcessRecording(ActiveRecordingInfo recordingInfo)
	Source: System.Diagnostics.Process
	TargetSite: Boolean ForkAndExecProcess(System.Diagnostics.ProcessStartInfo, System.String, System.String[], System.String[], System.String, Boolean, UInt32, UInt32, UInt32[], Int32 ByRef, Int32 ByRef, Int32 ByRef, Boolean, Boolean)

 

Link to comment
Share on other sites

crusher11
1 minute ago, Q-Droid said:

What does the script look like now? 

 

 #!/bin/sh
/volume1/@appstore/comskip/bin/comskip --ini=/volume1/@appstore/comskip/var/comskip.ini "${1}"

Link to comment
Share on other sites

Q-Droid

I might be nit picking but is there a space or tab in front of "#!"? If so then remove the space. 

Link to comment
Share on other sites

crusher11
5 minutes ago, Q-Droid said:

I might be nit picking but is there a space or tab in front of "#!"? If so then remove the space. 

There was, but removing it made no difference. Wouldn't really expect it to given we already know the .sh works. It's just Emby not running it properly.

Link to comment
Share on other sites

I don't think you're going to have much success with the script as is.
The working directory is / or root which Emby should not have access to.

What you need to do is forget about Emby for now and get the script working stand-alone. Until you have a working script there's no point in trying to set it up in Emby.

If need be create a user for testing you will run the script under.  You can then set permission on that user to whatever they need to be. Remember what you're changing because you may need to adjust permissions later when adding this to Emby but don't worry about that now until you have a stand-alone script that can do all the parts needed to cut commercials (assuming that's the objective) such as scan the file for commercials (comskip), create a control file used by your second program that will cut the video into junks around the commercial points, delete the commercial segments you have tracked, reassemble a new video with all chunks left after removing the commercials. Clean up the working directory. Move the complete file to the destination.

Of course you need to gracefully handle all errors that could popup with code to defer and come back to again later.  For example you try to overwrite the recording but someone's watching it and it's locked.  You would have to handle that by trying again later to overwrite it.

Calling and running Comskip is about 5% to 10% of the overall process if you want to cut commercials from the recordings.

Break out notepad or something and work on one piece at a time for the basics. No point it even scripting anything until you have each piece working by typing it at the command line.  When all pieces needed can be done from the command line you can start to script it putting in error handler and the rest of the code that will be needed.

Edited by cayars
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...