ExternalActions
#1
I am hoping someone can help me here. I am attempting to make use of the ExternalAction trigger that was added to serverWMC to run a program called CCExtractor which creates an *.srt file by processing a North American ATSC broadcast recording. This allows me to watch the shows with subtitles after the recording is complete. I have tested the batch file I have written that I am attempting to trigger when a recording completes, and it works if I specify the exact file name of the recording. I am at a loss for how to pass the arguments from this post (http://forum.kodi.tv/showthread.php?tid=...pid1605365) on to CCExtractor. Is there a standard syntax for this type of thing or is it dependent on CCExtractor? I previously used CCExtractor as part of my setup when I was using NextPVR (which I am SO glad to be done with now that serverWMC exists!) and the batch file for that was:

ccextractorwin.exe -srt %1 -o "%~dpn1.srt"

I can't say I understand exactly what it all meant, but it worked to take a just-completed recording (somehow designated at "%1") and then create a *.srt file with the same file name in the same location with only the file extension changed. When I replace %1 with a file name in quotes and replace %~dpn1.srt with the filename.srt, it works fine. But as it is listed above, I get no *.srt file. The only thing that changes is the date attached to the file, which switches to a seemingly random date (or at least one that I can't decipher the pattern). Can anyone help?

@krustyreturns - it looks like you might have something like this working already based on your post about live closed captions. I don't need live, but I could REALLY use the automated post-recording system if you have it working!

Thanks for all the help!
Reply
#2
I have been experimenting with have swmc generate srt files internally, but that functionality is not released yet. Also I was trying to do it for live streams, but it could be extended to finished recordings too - but that hasn't been done either.

In the meantime for what you are trying to do, it seems like external actions with ccextractor should work. I would think you want to do the action like this.

Code:
<RecordingExternalActions>
  <ExternalAction>
    <RecordingState>HasOccurred</RecordingState>
    <Program>c:\your\path\to\ccextractor.exe</Program>
    <Arguments>-autoprogram  -out=srt %FileName%</Arguments>
  </ExternalAction>
</RecordingExternalActions>

note that you have to enter your local path to ccextractor.exe. Serverwmc will replace %FileName% with the name of the recording, but I don't know if its a full path or just the file name (scarecrow?). Hopefully this will at least get you started.
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#3
%FileName% is the full path of the WTV file of the recording.

Regarding your batch file poopyurinal, %1 %2 etc are the parameters passed to it. And there is special syntax %~ where d=drive p=path n=name and x=extension. So it looks like your batch file was passing %1 to the -srt argument, and then the full name (minux extnsion) with .srt on the end (eg replacing whatever the extension was, with .srt) to the -out option. This is all DOS batch magic eg see here: http://stackoverflow.com/questions/11205...batch-file

Anyway Im not sure how CC extractor works... if it can just automatically name the output ".srt" file when given the input .wtv file, then you can get awway with callin ccextractor natively from ServerWMC external action and passing %FileName% to it, as per krusty's example. If you need more control over how things are named then you could write a batch file (or use your existing one), have ServerWMC call the batch file passing in %FileName% parameter and then in the batch file use that magic %~ DOS commands to pull apart the drive/path/name/extension however you need to. Could also write a script in powershell or something a bit easier to work with Smile

Anyway once you've setup an ExternalAction and enabled ExternalActions as per the post you linked, your ServerWMC.log file should log exactly when it calls the action and what the fully expanded parameters were etc, allowing you to see what it is doing and debug/correct any syntax issues you may have
pvr.wmc TV addon and ServerWMC Backend Development Team
http://bit.ly/ServerWMC
Reply
#4
Those parameter should work for ccextractor. It will automatically name the output file the same as the wtv, only the extension will be changed to .srt. So kodi should will play it with subtitles.
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#5
(2014-11-15, 05:04)scarecrow420 Wrote: %FileName% is the full path of the WTV file of the recording.

Regarding your batch file poopyurinal, %1 %2 etc are the parameters passed to it. And there is special syntax %~ where d=drive p=path n=name and x=extension. So it looks like your batch file was passing %1 to the -srt argument, and then the full name (minux extnsion) with .srt on the end (eg replacing whatever the extension was, with .srt) to the -out option. This is all DOS batch magic eg see here: http://stackoverflow.com/questions/11205...batch-file

Anyway Im not sure how CC extractor works... if it can just automatically name the output ".srt" file when given the input .wtv file, then you can get awway with callin ccextractor natively from ServerWMC external action and passing %FileName% to it, as per krusty's example. If you need more control over how things are named then you could write a batch file (or use your existing one), have ServerWMC call the batch file passing in %FileName% parameter and then in the batch file use that magic %~ DOS commands to pull apart the drive/path/name/extension however you need to. Could also write a script in powershell or something a bit easier to work with Smile

Anyway once you've setup an ExternalAction and enabled ExternalActions as per the post you linked, your ServerWMC.log file should log exactly when it calls the action and what the fully expanded parameters were etc, allowing you to see what it is doing and debug/correct any syntax issues you may have

You guys are awesome! You've definitely sent me on the right track. I have a fairly busy weekend so I am not sure how quickly I can get this up and running, but I will definitely post back with my successes and/or failures. Powershell is beyond me at this point, but I've already tried what krusty suggested and gotten further than previously (a seemingly empty but properly formatted *.srt file). I've been keeping an eye on the log file and it looks like it is sending things to ccextractor properly. Now I just need to debug that end of things. Thanks again for your help and if/when I get this working I will document it as best I can for anyone else that wants this working similarly.

(2014-11-15, 05:47)krustyreturns Wrote: Those parameter should work for ccextractor. It will automatically name the output file the same as the wtv, only the extension will be changed to .srt. So kodi should will play it with subtitles.

Thanks krusty, looks like I was posting when you were. Which parameters are you referring to? Your original set? Or scarecrow420's suggestions regarding the "dpn" portion?
Reply
#6
I mean in my code for calling ccextractor directly, Scarecrows instructions are for using a batch file to call it, but I don't think you need to do that (at least not yet Smile). Try these parameters instead, when next you test:

<Arguments>-autoprogram -out=srt -latin1 %FileName%</Arguments>
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#7
(2014-11-15, 06:13)krustyreturns Wrote: I mean in my code for calling ccextractor directly, Scarecrows instructions are for using a batch file to call it, but I don't think you need to do that (at least not yet Smile). Try these parameters instead, when next you test:

<Arguments>-autoprogram -out=srt -latin1 %FileName%</Arguments>

I've had a chance to test this several times now without success. In the log file, it claims that the process was successful but no file is created (the one time I got an empty .srt file that I mentioned earlier was a fluke, I must've changed something and I don't know what it was that one time). The relevant section of my config.xml file is:

<RecordingExternalActionEnabled>true</RecordingExternalActionEnabled>
<RecordingExternalActionDateFormat>YYYY-MM-dd HH:mmConfuseds</RecordingExternalActionDateFormat>
<ClientRestrictionEnabled>false</ClientRestrictionEnabled>
<RecordingExternalActions>
<ExternalAction>
<RecordingState>HasOccurred</RecordingState>
<Program>e:\Recorded TV\ccextractorwin.exe</Program>
<Arguments>-autoprogram -out=srt %FileName%</Arguments>
</ExternalAction>
</RecordingExternalActions>

If I enter a command prompt and navigate to e:\recorded tv and then run the command:

ccextractorwin.exe -autoprogram -out=srt "Name of recorded program"

the process completes successfully. So it seems like it must be something with the %FileName% argument and its interaction with ccextractor. A serverWMC.log file using the above setup is available here: http://pastebin.com/ZASZhaBL

It looks to me like the "FileName" argument wasn't passed at all, so I tried putting it earlier in the arguments like this:

<Arguments>%FileName% -autoprogram -out=srt</Arguments>

This time it looks like it passed the %FileName% argument to ccextractor as evidenced by this log file: http://pastebin.com/jTC7aVmb

However, there is no srt file created by either of these setups. Any thoughts on what else I can do to troubleshoot this?

Thanks!

EDIT: Two quick things. One, my xml file is properly formatted, it just lost the formatting when pasting in here. Two, I just noticed an srt file at the root of the drive where ccextractor is located (aka e: in this example) titled Recorded.srt. It is empty but was created (based on the date attached to the file) at the end of the recording from my second link above. I don't know if this file was created on earlier attempts since it might have been the same file name and been overwritten. I am testing that now.

SECOND EDIT: It seems that the Recorded.srt file is created every time in the root of that drive and it is blank again. This also happens with or without the "-latin1" argument krustyreturns suggested.
Reply
#8
Hmm well Im not sure about the first one, it does seem like it didnt pass the filename for some reason on that one.

With the second one it is passing it OK as you say
Code:
Run external action: e:\Recorded TV\ccextractorwin.exe E:\Recorded TV\Thomas & Friends_WHADT_2014_11_18_12_29_00.wtv -autoprogram -out=srt

But your filernames have spaces in the path so that is why ccextractor is only seeing the "E:\Recorded" as the argument. Put quotes around %FileName% and I think you should be good

<Arguments>"%FileName%" -autoprogram -out=srt</Arguments>
pvr.wmc TV addon and ServerWMC Backend Development Team
http://bit.ly/ServerWMC
Reply
#9
(2014-11-19, 01:10)scarecrow420 Wrote: Hmm well Im not sure about the first one, it does seem like it didnt pass the filename for some reason on that one.

With the second one it is passing it OK as you say
Code:
Run external action: e:\Recorded TV\ccextractorwin.exe E:\Recorded TV\Thomas & Friends_WHADT_2014_11_18_12_29_00.wtv -autoprogram -out=srt

But your filernames have spaces in the path so that is why ccextractor is only seeing the "E:\Recorded" as the argument. Put quotes around %FileName% and I think you should be good

<Arguments>"%FileName%" -autoprogram -out=srt</Arguments>

Thanks scarecrow420, I tried it with the quotes (I tried it earlier, too, for the same reason) and it doesn't get passed correctly, it appears. Here is the relevant section, though if the whole log will help I can pastebin it:

2014/11/18 20:02:00.531 RecordingStatus> Recording Scheduled 3/NCIS: Status changed from IsOccurring to HasOccurred
2014/11/18 20:02:00.533 RecordingStatus> Recording Scheduled 3/NCIS: Run external action: e:\Recorded TV\ccextractorwin.exe "" -autoprogram -out=srt
2014/11/18 20:02:00.549 RecordingStatus> Recording Scheduled 3/NCIS: Run external action: Succesful (PID 6812

Is there a way to change the default naming convention for windows media center recordings? Or a way to control this better through a batch file? Would the argument %"FileName"% do anything? I feel like this is really close to working!
Reply
#10
No, the %TokenName% is replaced with the particular field so if you put quotes inbetween the % signs it wouldnt have a match to replace.

It should work. I think you must be striking cases where the filename of the completed recording isnt known for some reason, thus it's blank (and you end up with ""). Also your earlier Sesame Street example appeared to have the same thing (blank filename, no quotes were there that time but you can see where conceivably it replaced %Filename% with an empty string). But another example you posted (Thomas and Friends) DID have a filename, but at that point you didnt have quotes which caused ccextractor to only see up to the first space.

There's not alot more we can do on this right now, can you leave it running as you have it configured now, and get a few more completed recordings firing - then we can review all the external action executions to see if some of them do have filenames known and others dont, or whether all of them are blank etc.

I'll have a look on my side tonight as well
pvr.wmc TV addon and ServerWMC Backend Development Team
http://bit.ly/ServerWMC
Reply
#11
(2014-11-19, 04:42)scarecrow420 Wrote: No, the %TokenName% is replaced with the particular field so if you put quotes inbetween the % signs it wouldnt have a match to replace.

It should work. I think you must be striking cases where the filename of the completed recording isnt known for some reason, thus it's blank (and you end up with ""). Also your earlier Sesame Street example appeared to have the same thing (blank filename, no quotes were there that time but you can see where conceivably it replaced %Filename% with an empty string). But another example you posted (Thomas and Friends) DID have a filename, but at that point you didnt have quotes which caused ccextractor to only see up to the first space.

There's not alot more we can do on this right now, can you leave it running as you have it configured now, and get a few more completed recordings firing - then we can review all the external action executions to see if some of them do have filenames known and others dont, or whether all of them are blank etc.

I'll have a look on my side tonight as well

Thanks for all the assistance. Would you like me to keep it as <Arguments>"%FileName%" -autoprogram -out=srt</Arguments> for now? I'd be glad to set up several recordings on several channels to see what cooks up. Is there a way to build in a delay of a few seconds in case it is an issue with it starting too quickly after a recording completes (perhaps the file is being "named" while the process is starting)? I doubt that's the issue but it's another idea. Also, with my previous examples, the Thomas and Friends one that created the "Recorded.srt" file, it was an empty file, so though it got the %FileName% passed to it, it still didn't work properly. I know that might be a ccextractor problem and not a serverWMC problem, but just wanted to point that out.
Reply
#12
Well if it wasnt given the actual WTV file (because due to the space it only was processing "E:\Recorded") then it wont have found anything to put into the srt file. But it had obviously already created the srt file before it actually tried to open the WTV file

and yes, have parameters as you specified, schedule a bunch of recordings on various channels, and let's review the logs after they all complete
pvr.wmc TV addon and ServerWMC Backend Development Team
http://bit.ly/ServerWMC
Reply
#13
(2014-11-19, 06:25)scarecrow420 Wrote: Well if it wasnt given the actual WTV file (because due to the space it only was processing "E:\Recorded") then it wont have found anything to put into the srt file. But it had obviously already created the srt file before it actually tried to open the WTV file

and yes, have parameters as you specified, schedule a bunch of recordings on various channels, and let's review the logs after they all complete

Partial success! I set up 7 recordings this morning spread across all the OTA channels I receive. All 7 recordings worked fine, but for some reason only 5 out of the 7 produced a working srt file. One that didn't work sent the "%FileName%" argument as "" instead of the full file name (the first recording in the log). The other 6 sent the full name of the recording in quotes as it should, but one of them produced a non-functional srt file ("Girl Talk", don't ask, I picked random shows!), which I am guessing is the fault of CCExtractor, but maybe you can see something in the log that I didn't. You can see the log here: http://pastebin.com/fcm2cKbC

Any ideas why the first one didn't work (sending "")?
Reply
#14
No ideas on the one that sent the blank. Can you keep a bunch of recordings scheduled and we can keep reviewing the logs to see how many times you get blanks? Ive been playing on my dev setup tonight and so far every recording ive scheduled has the filename populated.

In terms of your "Girl Talk" one... if you run the command manually is the srt file still the same (ie not working)?

2014/11/19 09:02:00.658 RecordingStatus> Recording Scheduled 57/Girl Talk: Run external action: e:\Recorded TV\ccextractorwin.exe "E:\Recorded TV\Girl Talk_WBUWDT_2014_11_19_08_29_00.wtv" -autoprogram -out=srt

Does ccextractor have a log or something you can find out if it had any errors with that file

If you are able to, please keep scheduling recordings so we can see how many have blank filename property and if there is any commonality (eg channel, time of day, whatever).
pvr.wmc TV addon and ServerWMC Backend Development Team
http://bit.ly/ServerWMC
Reply
#15
I'll keep trying to record at least one show on each channel every day for a while. Running CCExtractor on the girl talk recording manually still results in an error, so ignore that issue. Do you want me to post a log daily or wait for a week or something and post them all at once? I had another idea as to what the variable could be for passing a blank filename, though I don't have a good reason for it. Would it matter if the show was being watched while the recording ends? If it is is remuxing the file to a .ts to watch it while it is recording, could that alter its ability to be worked on when the recording ends? It seems like it would just throw an error or not work rather than not calling the filename properly, but I'm not sure how this is handled. This happened to a recording my wife was watching last night while it was actively recording, and I *think* that may have been true of the blank one from the log posted yesterday. I'll try and test that later on tonight.
Reply

Logout Mark Read Team Forum Stats Members Help
ExternalActions0