Ability to process recordedings or call a script after recording (1 Viewer)

mattmannz

Portal Member
December 18, 2009
27
0
Home Country
New Zealand New Zealand
I am running MP1.1.0.0 on XP SP3 here in New Zealand with a DVB-T PVR3000 and an analog PVR250 card.

The .TS files play fine on my Popcorn Hour in the bedroom if they come from the PVR250 but the DVB-T here in NZ uses HE-AAC audio which is about the only codec NOT supported on the PCH.

I have done some experimenting with VLC and got a quick and easy command line script to convert the audio in the .TS files to AC3 from AAC.

vlc -vvv -I dummy "c:\original.ts" --sout=#transcode{acodec=a52,ab=128,channels=2,samplerate=48000}:duplicate{dst=std{access=file,mux=ts,dst='c:\converted.ts'} vlc://quit

Does anyone here know how or have some pointers on how I might script this so that either on a scheduled basis it goes through and converts the recordings or after recording a program it calls the script to convert it?

The issues I see are that not all recordings need to be converted, and I want the recordings to stay in the My TV folder so if the conversion is scheduled it needs to not reconvert files that have been converted and also retain the existing filename.

Any thoughts? It would seem like the best bet would be to do the conversion immediately after recording but I still need to check the original audio format and only convert if it's AAC and retain the original file name etc.

Cheers
Matt.
 

usualsuspect

Portal Pro
May 12, 2009
631
98
Home Country
Germany Germany
AW: Ability to process recordedings or call a script after recording

you can call the postprocessing with the inbuilt comskip launcher: TV-Server/Configuration/Plugins/ComSkipLauncher - MediaPortal Manual Documentation

another way would be to use a for-command in a batch file to run the command line script for all files in your rec-folder. you can avoid double processing by using a marker file that will be created after conversion. then you can configure your batch commands to only call the vlc if the marker file does not exist. this: https://forum.team-mediaportal.com/plugins-erweiterungen-178/comskip-atomatisieren-per-batch-73753/ could help you, although it's german the code should be clear.

anyway I have no clue how to check which files have to be transcoded. but I guess this should be possible to check with vlc.
 

mattmannz

Portal Member
December 18, 2009
27
0
Home Country
New Zealand New Zealand
Thanks very much for your help.

I have a script that will convert the files correctly and tried using Comskip, setup the plugin etc and the test button works okay but it doesn't appear to work after a recording is completed. Do you know if there is any debugging that can be done on the plugin?

Cheers
Matt.
 

kiwijunglist

Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,743
    1,754
    New Zealand
    Home Country
    New Zealand New Zealand
    you might also want to check out for the record plugin, from memroy this plugin supports processing files post recording.
     

    mattmannz

    Portal Member
    December 18, 2009
    27
    0
    Home Country
    New Zealand New Zealand
    Okay it turns out that I hadn't stopped and started the recording service after enabling the comskip plugin.....

    Works perfectly now. Thanks for everyone's help.

    Cheers
    Matt.
     

    mattmannz

    Portal Member
    December 18, 2009
    27
    0
    Home Country
    New Zealand New Zealand
    Here is the final script I ended up using if anyone is interested. It's called via the Comskip plugin in the TV Server using the filename parameter at the end of the recording.

    I have two cards, an analogue for Sky and a DVB-T for Freeview HD so only the Freeview programs with HE-AAC needed to be converted, the others were recorded with MPG audio.

    There are probably better and smarter ways of writing this script but this works for me at the moment. Have tested all the various permutations of error situations and it seems to handle them all okay.

    I used the cli version of Mediainfo to check the file to see if it needed to be converted. I added some logging so that I could see what was going on.

    Hope someone else can get some use out of this.

    @echo off
    rem Change to TV drive
    e:
    cd "\recorded tv"

    rem Start logging
    echo Starting conversion at %date% %time% > conversionlog.txt
    echo You passed me %1 >> conversionlog.txt

    rem Check supplied file exists
    if not exist %1 goto NOFILE

    rem Check current audio codec in file
    setlocal
    e:\mediainfo\mediainfo.exe --Inform=Audio;%%Format%% %1>audiocodec.txt
    set /p TOOLOUTPUT= < audiocodec.txt
    del audiocodec.txt
    echo The codec in the file is %TOOLOUTPUT% >> conversionlog.txt
    if "%TOOLOUTPUT%" == "AAC" goto CONVERT
    echo No need to convert %1 >> conversionlog.txt
    goto END

    :CONVERT
    rem Rename original file and delete temp file if necessary
    if exist tobeconverted.ts del tobeconverted.ts
    rename %1 tobeconverted.ts
    echo renamed %1 to tobeconverted.ts >> conversionlog.txt

    rem Call VLC to convert renamed file and output as original filename
    "g:\Program Files\VideoLAN\VLC\vlc.exe" -vvv -I dummy tobeconverted.ts --sout=#transcode{acodec=a52,ab=256,channels=2,samplerate=48000}:duplicate{dst=std{access=file,mux=ts,dst=%1} vlc://quit
    echo Just converted %1 >> conversionlog.txt

    rem Check for file and check file length of converted file and if zero back out
    if not exist %1 goto DELANDRENAME
    if exist %1 for %%i in (%1) do if %%~zi==0 goto DELANDRENAME

    rem All okay so delete renamed file
    del tobeconverted.ts
    echo Converted %1 okay >> conversionlog.txt
    goto END

    :NOFILE
    rem No file exists
    echo Error file %1 doesn't exist >> conversionlog.txt
    goto END

    :DELANDRENAME
    rem Delete zerobyte file and backout
    echo Problem so rolling back >> conversionlog.txt
    if exist %1 del %1
    rem Rename file to original
    rename tobeconverted.ts %1
    goto END

    :END
    rem Nothing left to do
    echo The end at %date% %time% >> conversionlog.txt
     

    andy_p

    Portal Member
    July 10, 2008
    18
    5
    London
    Home Country
    United Kingdom United Kingdom
    That script looks really useful.
    I've got one suggestion though - use a different temp filename each time instead of just "tobeconverted.ts", because if two recordings finish at the same time one will overwrite the other. You can set an environment variable to "tobeconverted_%random%.ts" and then use that, which I've never had a collision with.
     

    Users who are viewing this thread

    Top Bottom