[mythtv-users] Displayed recording duration not updated after applying cutlist
Richard
peper03 at yahoo.com
Tue Sep 4 21:40:16 UTC 2012
On 04/09/12 10:42, John Veness wrote:
> On 04/09/2012 00:30, Richard wrote:
>> I ended up writing a script
>> that would trim the start and end according to the cutlist, update the
>> start and end times of the recording accordingly and also filter out any
>> data stream from the recording, leaving all audio, video and subtitle
>> stream untouched (as I understand it, this should directly using
>> 'Recording profiles' but that never seemed to have any effect).
>> Depending on the channel and the amount of data streamed, the final file
>> is sometimes almost half the original size!
>>
>> Richard.
>
> Hi,
>
> I'm very interested in your script. I recording UK DVB-T and manually
> create a cutlist to cut out ads and trim the start and end. I would like
> to do a lossless transcode on this but this removes the DVB subtitles
> stream, which I sometimes use. Your script sounds like it will do the
> trick for me, will it?
Hi John,
Yes, it sounds like you want to do what I do.
The scripts are here:
http://dl.dropbox.com/u/19450259/trimRecording.pl
http://dl.dropbox.com/u/19450259/stripPIDs.pl
The first (trimRecording.pl) determines what needs to be trimmed from
which file and handles all the database updates. The second
(stripPIDs.pl) is called by the first to perform the trimming/filtering.
Only the start and end are trimmed (based on a saved cutlist).
'Internal' cuts are left alone (but still work after trimming).
stripPIDs.pl is mostly taken from the code here:
http://search.cpan.org/dist/Image-ExifTool/lib/Image/ExifTool/M2TS.pm
I pared it down a bit to get just what I needed so it's quite possible
that some errors may not be caught but it works fine for me.
Only MPEG2 TS files will work with these scripts. I use it with MPEG2
and H.264 files without problem but very little checking is done that
the files are in the correct format. Most likely the script will abort
with a 'Synchronization error' message but you've been warned!
The packet size is hard coded to 188 bytes. Other sizes are apparently
204 and 208. It should be pretty straightforward to adapt it to these
sizes if necessary, but I've not tried it as all my recordings use 188
byte packets.
You can set trimRecording.pl up as a user job.
-c <n> Channel ID
-s <s> Start-time
[-M <path>] MythTV settings folder [HOME/.mythtv]
[-l <path>] Path to a directory or file to log to (default is stdout)
You will probably need to set the path for stripPIDs.pl in line 46 in
trimRecording.pl.
trimRecording.pl moves the original recording into a subdirectory under
the directory where the recording was found called 'orig'.
As a final warning: The Perl bindings are used to connect to the
database. Ideally all the database changes would be committed together
and a rollback performed if something goes wrong, but unfortunately it
doesn't seem possible to turn off auto-commits. The database should not
be completely screwed if something goes wrong but it's possible that it
gets confused about the recording you were trying to trim - to the point
of not being able to find it.
I use these scripts more or less daily and have at most an occasional
database deadlock (which sounds worse than it appears to be - the script
just aborts, everything else continues to work fine). I've altered the
script to leave the original recording where it is until the last
moment, so even this error should be relatively harmless.
What I'm basically trying to say is 'caveat emptor'!
Richard.
More information about the mythtv-users
mailing list