script to extract audio (.ts to mpg)

rodp

Member
Hi All,

I understand there is a program via the custom firmware that will let me extract audio from a .ts file (sorry I can't remember what it's name is at the moment). What I would like to do is to set it up to run (at night or after the recording has finished) and look at a specific folder (my radio recordings), convert any .ts file and then delete the original .ts file leaving just the MPG file for me to pick up at a later date.

Many thanks in advance for any guidance in how to setup a script for this.

Thanks

Rodp
 
Updated in the light of subsequent posts

The WebIF provides the tools for this. The recording will need to be decrypted, therefore you will need the DLNA server turned on:

Menu >> Settings >> System >> Internet Setting >> Content Share = On

You will need the custom firmware package ffmpeg installed, check the WebIF Package Management "Installed" list to see if you already have it, and install it from the "Available" list if not.

In the WebIF Browse Media Files page click the "OPT+" button next to your target folder and select "Enable Auto-decrypt" and "Enable Auto-audio". The action of these two will be to automatically create a .MP3 file from any .TS that lands in that folder. These options will be greyed out (unavailable) if the conditions stated in the previous paragraphs are not met.

To automatically remove the original recording files, in the same OPT+ menu select Enable Auto-expire. This will ask for an age in days after which recordings should be deleted, and only applies to the original recording file set (not .MP3 or .MPG extractions). I suggest 2 days. If you also install the undelete package, deleted recordings will be preserved in a recycle bin for a period and can be rescued if you find that anything has gone wrong with the audio extraction.

Footnotes

1. Setting "Enable Auto-decrypt" is not necessary if you already have "Enable Recursive Auto-decrypt" set on a folder above the target folder, or if you are running the unencrypt package (not preferred - see Things Every... (click) section 5, and continue with the link in bullet point 4).

2. The resulting .MP3 file is actually MP2 audio and not all MP3 players are able to play it. An option in the WebIF settings page allows proper MP3 extraction to be selected instead, but note that this is an extremely slow process and should only be considered if maximum MP3 compatibility is required.

3. Radio recordings can be gathered automatically into one folder or one folder tree using the sweeper package (possibly in combination with flatten). Decryption can be made recursive (ie applies to sub-folders, sub-sub-folders etc), but (currently) not Auto-audio or Auto-expire. Do not install flatten or sweeper without familiarising yourself with their implications and appropriate usage first (they are capable of scrambling your folders).

4. Decrypting HiDef recordings also requires the auto-unprotect package installed.

5. The resulting .mp3 files will not be visible in the Humax media browser unless they are moved to the My Music folder and Media >> Media (yellow) >> Music is selected.
 
Note 2) above, the conversion to a more playable MP3 format could be carried out by the Humax, but it is very slow and I would not recommend doing it at the same time you are using the tuners for viewing / recording TV
 
It depends on your definition of practical. In my tests it takes about 4 times real time, so a 30 minute programme would take 2 hours to convert.
It runs at low priority so the comment about not doing it when using the machine for viewing/recording is irrelevant as it makes no difference to that.
The machine would only be spinning in the idle loop otherwise, so why not use it for something useful?
 
Sure, but as an easily accessed tool has not been added to the WebIF for this it is still impractical for the non-technical user (I have requested it before).

However, I am surprised you find it that speedy. I understood it is a lot worse than that (to the extent that any reasonable rate of radio recording would overwhelm the queue - it is no good recording an hour a day and then finding it takes more than a day to process an hour's worth).
 
The last tests I did to extract / convert MP3 from TS files (Link HERE) showed it took about 3 - 4 times the play time of the audio file. I used this command line :-
Code:
ffmpeg -i input.ts -vn -ar 44100 -ac 2 -ab 192000 -f mp3 out.mp3
 
I think we are all agreed it's best to use get iplayer if one requires a genuine MP3 file from BBC materiel on a regular basis other than that if the materiel comes from the Humax you can do the processing on a PC. Some BBC materiel is in MP3 as a podcast. Get iplayer you put a command in for it to convert AAC to MP3 (national programmes on the iPlayer are in AAC, regional MP3), but then some MP3 player play AAC ditto media servers. If you get them into MP3 via get iplayer you can then play them on the Humax - you convert at a high bit rate so as to retain those Radio 3 hi def programmes.

I was a bit critical about the documentation before but I see it's been tidied up :).
 
Hi All,

Thanks very much for the guidance - was alot easier than i imagined. All setup now.

Thanks again

Rodp
 
The last tests I did to extract / convert MP3 from TS files (Link HERE) showed it took about 3 - 4 times the play time of the audio file. I used this command line :-
Code:
ffmpeg -i input.ts -vn -ar 44100 -ac 2 -ab 192000 -f mp3 out.mp3
4 times slower than real-time is still about right, but note that the straightforward MP2 extraction is around 17 times faster than real-time. I also noticed that my fan sped up during the MP3 conversion even though I have the fan package installed and set at 40%.
I will add an option to the web interface to provide the choice.
 
That will be good af123 when you need it on the odd occasion where you have a must have requirement e.g. something recorded but no longer available on the main iPlayer which you need to get off onto mp3.
 
Hi All,

Just wanted to add an update to this. I chose to use the webif router of setting the auto-audio (to mp3) and auto-expire setting. One thing to note is it's not recursive so you need to change it for each directory.

Black Hole mentioned something above....

To automatically remove the original recording files, in the same OPT+ menu select Enable Auto-expire. This will ask for an age in days after which recordings should be deleted, and only applies to the original recording file set (not .MP3 or .MPG extractions)

This is true but i now realise that mp3 files are not visible from the normal video view of the humax and so you could be tricked into thinking the autoexpire has also removed these. But when I checked on the webif website the mp3 files were still there.

Rodp
 
I will add an option to the web interface to provide the choice.
I decided to have a go with the new facility, and found it as an option in the WebIF settings page so that all audio extraction is either MP2 (fast) or MP3 (slow).

What concerns me is that when I switched the option to MP3, some kind of "invalid argument" message flashed up. I don't know whether the option has taken or not, time will tell.
 
Definitely something wrong, the conversions were finished in minutes and when I went back to the Settings page it was showing MP2 again.

The pop-up says "Invalid value for audiomp3".
 
Strange - works for me. Which browser?
That error means that your browser sent a non-numeric value for that parameter, which shouldn't be possible.
 
Yep, the setting worked in Safari.

I have disabled auto-audio and deleted all the MP2s, set MP3 preference and re-enabled auto-audio - does the absence of the extracted file mean it will try again, or is there some other flag that needs clearing?
 
Removing the file should be enough. I'll try and test with IE when I get chance.
 
Back
Top