Jump to content


Photo

Post Processing Script - Working Example - Powershell


  • Please log in to reply
44 replies to this topic

#21 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 25 September 2018 - 01:46 PM

whats you full powershell comand line look like



#22 CBers OFFLINE  

CBers

    Advanced Member

  • Moderators
  • 15014 posts
  • Local time: 01:38 AM
  • LocationKent, England.

Posted 25 September 2018 - 01:50 PM

@PenkethBoy - I am trying to test your script manually directly from Powershell to ensure I am implementing it correctly before adding it to Emby. I am sure there is something I am not putting into your script that is causing the error in my attached log but after reading over your instructions and looking over your example I can't for the life of me figure out what I am doing wrong.

 
This is what I have just used from withing a PS window:
 
.\EmbyPP.ps1 -oldVideo 'X:\Videos\Live TV\Two and a Half Men (2003)\Season 3\Two and a Half Men S03E08 That Voodoo That I Do Do.ts' -Preset superfast

  • jasonmcroy likes this

#23 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 25 September 2018 - 02:01 PM

@CBers sorry - thats for the script you have :) not the one Jason is using

 

Jason - what you need to do is take the above example BUT dont add the "-preset superfast" bit as that does not apply to the script above

 

also you need to be in the console window AND have changed the directory to the PS script location for .\EmbyPP etc to work


  • CBers likes this

#24 jasonmcroy OFFLINE  

jasonmcroy

    Advanced Member

  • Super Testers
  • 1675 posts
  • Local time: 08:38 PM
  • LocationTampa, FL

Posted 25 September 2018 - 02:57 PM

Ha. Now I feel even more confused! lol

 

Here is what I did - I went by your instructions and created the ps1 script in the same folder where I have ffmpeg and copied your script into the ps1 file and changed the ffmpeg path. 

 

I then copied a test video file into that same folder. Then I right clicked on the ps1 script which then opens up powershell. Powershell then asks me to input the file name for the video so did and hit enter. Then it asked for the in type so I put ts and then it asked for out type and I put mkv and hit enter. It does something, closes then puts out that log file I uploaded to you. 

 

I hope your not laughing at me because I barely know what I am doing but I can follow directions normally. But outside of what you tell me to do I don't have any additional knowledge. Totally willing and excited to learn though!

 

Here is a screen shot of the powershell window up to the last command it asks me for before it does it's thing:

 

Attached File  Capture.PNG   480.43KB   1 downloads



#25 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 25 September 2018 - 05:28 PM

ok - you are not following what we said

 

open a console window for powershell - its on your start menu - windows powershell > windows powershell

 

with the window open (blue as in you screen shot)

 

now change the directory to the directory that has the ps1 file in it - as you would in any command window as it will by default start in windows\system32

 

then you can do the following

 

.\embyPP.ps1 -oldvideo "<full path to the video file inside double quotes>" -intype ts -outtype mkv


  • jasonmcroy likes this

#26 jasonmcroy OFFLINE  

jasonmcroy

    Advanced Member

  • Super Testers
  • 1675 posts
  • Local time: 08:38 PM
  • LocationTampa, FL

Posted 25 September 2018 - 09:15 PM

Ha! Now I understand what you're trying to say and I see what I am not doing. I didn't realize that the command you listed above (your first post) is what you would manually put into powershell if you're just doing it manually and not via Emby's post processing function.

 

I did what you said this time and it's processing now. 

 

By the way, how long does it usually take in your experience to process a 1 hour recording? Mine is still processing and it's been almost an hour now.



#27 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 26 September 2018 - 07:11 AM

Time is relative :)

 

Depends on

 

1. HD vs SD content

2. CPU GHz and number of Threads the CPU has

3. The ffmpeg commands you apply

 

For example - see the txt output for encoding times

- HD content converted on my i7 6700k runs at ~1.85x - so an hour recording would take approx 35 mins

- SD content converted on my i7 6700k runs at ~10x - so an hour recording would take approx 6 mins

 

As the script is an example the ffmpeg commands are simple and should cover most input and cope with most errors inherent in LiveTv streams - its not bomb proof though

 

You could change the ffmpeg commands to do other things - that would shorten the PP encode time - but might affect the quality and file size produced.

 

Thats up to you to research and test.

 

Note - if you run this manuallyfor a second time on the same file - dont run it with an existing PP file in the directory as you will setup a deadlock - delete the existing file first or add "-y" to the ffmpeg commands so it will overwrite the existing file


Edited by PenkethBoy, 26 September 2018 - 07:15 AM.

  • jasonmcroy likes this

#28 jasonmcroy OFFLINE  

jasonmcroy

    Advanced Member

  • Super Testers
  • 1675 posts
  • Local time: 08:38 PM
  • LocationTampa, FL

Posted 26 September 2018 - 11:33 AM

Thanks! I will do some research and testing today. You're comment about not running it with an existing PP file in the directly may have been an issue last time. I ended up killing powershell and ffmpeg because it was taking so long. However, I was also testing on my less powerful PC. It is an i3 cpu and was maxed out at 95-98% the whole time.

 

I have a beefier PC I can test on today that is an 8 core AMD cpu with 16gb ram in it. 

 

I will also do some research on the different ffmpeg commands I can use because I also want to test just doing a simple remux. The HDHomerun Premium channels come in at H.264 so I really only need a simple command for those. It is my OTA channels that come in at mpeg2 that take longer. 

 

Thanks for walking me through this!



#29 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 26 September 2018 - 12:43 PM

even your H.264 streams from the hdhr - will need re-encoding as the streams are almost always with errors - a simple remux will fail

 

ffmpeg always runs as fast as it can so 99% - normal

 

i3 - will do the PP but not very quickly

 

for ffmpeg - look at the -preset option - veryfast and superfast work well if the file is for viewing once and deleting - medium is very similar to what you have now

 

read this https://trac.ffmpeg....ki/Encode/H.264


Edited by PenkethBoy, 26 September 2018 - 12:44 PM.

  • CBers and jasonmcroy like this

#30 jasonmcroy OFFLINE  

jasonmcroy

    Advanced Member

  • Super Testers
  • 1675 posts
  • Local time: 08:38 PM
  • LocationTampa, FL

Posted 26 September 2018 - 01:47 PM

Thanks!



#31 Fratopolis OFFLINE  

Fratopolis

    Advanced Member

  • Members
  • 244 posts
  • Local time: 07:38 PM

Posted 09 December 2018 - 10:22 PM

NOTE - 11/9/2018

 

To be clearer the script above does not do any error checking to see if the ffmpeg process failed to convert the ts file and if you have the -DelFile option enabled it will just delete the ts file.

 

Error checking could be added by the user although from reading a few threads on ffmpeg - getting a valid exit code of 0 (zero) does not always mean the conversion worked! - sigh

 

So use the -DelFile with caution as recorded LiveTV is prone to errors in the ts stream - some of which may cause ffmpeg to abort.

 

did mine in bat file which has a basic error check if ffmpeg remuxed properly. so far it has worked just fine with my HDHR prime and OTA tuners

 



#32 Kramerika OFFLINE  

Kramerika

    Advanced Member

  • Members
  • 178 posts
  • Local time: 08:38 PM
  • LocationPA, US of A

Posted 11 June 2019 - 09:16 AM

I found an issue with this.  If the title of the show has an apostrophe in it, it breaks the script. Both America's Got Talent and Marvel's Agents of Shield fail to execute.  Other shows without apostrophes work just fine.  Here is an example and the error generated.  Is there a work-around for this?

 

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "& 'D:\Recordings\convert.ps1' -oldVideo 'D:\Recordings\Emby\America's Got Talent (2006)\Season 14\America's Got Talent S14E01 Auditions 1.ts' -InType ts -OutType mkv -DelFile"

 

D:\Recordings\convert.ps1 : A positional parameter cannot be found that accepts argument 's'.
At line:1 char:1
+ & 'D:\Recordings\convert.ps1' -oldVideo 'D:\Recordings\Emby\America's ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: ( :) [convert.ps1], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,convert.ps1

Edited by Kramerika, 11 June 2019 - 09:17 AM.


#33 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 11 June 2019 - 06:58 PM

enclose the file path in double quotes rather than single quotes

 

i.e.  "D:\Recordings\Emby\America's Got Talent (2006)\Season 14\America's Got Talent S14E01 Auditions 1.ts"



#34 Kramerika OFFLINE  

Kramerika

    Advanced Member

  • Members
  • 178 posts
  • Local time: 08:38 PM
  • LocationPA, US of A

Posted 12 June 2019 - 09:35 AM

Thanks, but unfortunately that did not fix the problem.

 

 

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "& "D:\Recordings\convert.ps1" -oldVideo "D:\Recordings\Emby\America's Got Talent (2006)\Season 14\America's Got Talent S14E01 Auditions 1.ts" -InType ts -OutType mkv -DelFile"

 

 

D:\Recordings\convert.ps1 : A positional parameter cannot be found that accepts argument 'Got'.
At line:1 char:1
+ & D:\Recordings\convert.ps1 -oldVideo D:\Recordings\Emby\America's Go ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: ( : ) [convert.ps1], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,convert.ps1


#35 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 12 June 2019 - 03:00 PM

How are you using the script?

 

Are you running from the emby post processing option?

 

or trying to run it directly from a command window? 

 

and if the second are you using a powershell console window?



#36 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 12 June 2019 - 03:20 PM

If you run the script from within a powershell console window then it works fine

 

i.e.

D:\Recordings\convert.ps1 -oldVideo "D:\Recordings\Emby\America's Got Talent (2006)\Season 14\America's Got Talent S14E01 Auditions 1.ts" -InType ts -OutType mkv -DelFile



#37 speechles OFFLINE  

speechles

    Advanced Member

  • App Developer
  • 5459 posts
  • Local time: 05:38 PM

Posted 12 June 2019 - 04:19 PM

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "& 'D:\Recordings\convert.ps1' -oldVideo 'D:\Recordings\Emby\America''s Got Talent (2006)\Season 14\America''s Got Talent S14E01 Auditions 1.ts' -InType ts -OutType mkv -DelFile"

 

It is the ' in America's causing you headaches. The ''(press ' twice.. not a double quote " single char) is powershell's version of ' within ' '. You just add a ' on the ' in the filename already within ' '.


Edited by speechles, 12 June 2019 - 04:22 PM.


#38 Kramerika OFFLINE  

Kramerika

    Advanced Member

  • Members
  • 178 posts
  • Local time: 08:38 PM
  • LocationPA, US of A

Posted 12 June 2019 - 05:07 PM

I am running it from a command line to test it, but I want to use it in post processing.  That works fine for any other titles.  It's only when there is an apostrophe.

 

Is there a way to automate replacing an apostrophe with a double single quote within the script?  If not, I guess I'm out of luck on any show that includes one in the title.



#39 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3392 posts
  • Local time: 01:38 AM
  • LocationWarrington,UK

Posted 12 June 2019 - 05:51 PM

the PP option in emby uses the command prompt and is where the issue ls - i.e. you have to escape the single quote to two single quotes - as the command prompt (windows) has an issue with the single quote and does not pass Powershell the full path

 

To overcome this you could use a bat file with code to escape the single quote and then pass it to the PS script which would then work

@Echo off
set test=%1
REM adds '' to escape '
set result=%test:'=''%

powershell -command "& 'F:\EmbyPP\EmbyPP.ps1' -oldvideo "'%result%'" -intype mp4 -outtype mkv"

for example - save the above as say pp.bat with the path amended to your copy of the ps1 file

 

and change the emby dvr to look like this

 

5d0172d14e8cf_Annotation.png


  • CBers likes this

#40 Kramerika OFFLINE  

Kramerika

    Advanced Member

  • Members
  • 178 posts
  • Local time: 08:38 PM
  • LocationPA, US of A

Posted 13 June 2019 - 09:59 AM

I will try the above.  Marvel's Agents of Shield records tomorrow night, so I'll just wait for it to run to test it.  Thanks!


Edited by Kramerika, 13 June 2019 - 09:59 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users