[mythtv-users] Help with pdatranscode.pl

Peter Watkins peterw at tux.org
Thu Aug 23 20:57:38 UTC 2007

Jon Larson wrote:
> Thanks so much to Jeff and Peter for their work on the transcoding scripts.
Glad you find it useful!
> I've created a modified version of pdatranscode.pl that adds the 
> podcasting functions from myth2ipod, but I've run into a small snag: I'm 
> not sure how to compute a "duration" for a given video (I'd like to 
> include this in the podcast XML).
> I figure that it must be possible given that the start and end times are 
> available, but I'm really new to Perl so I'm not sure how to manipulate 
> the dates correctly to compute the difference between the start and end 
> time stamps.
> I'd like to end up with a duration in HH:mm:ss that I can add to the 
> podcast XML--can anyone provide advice on how to do this?
Step 1: convert the start and stop times (is stop also local 
YYYYMMDDhhmmss ?)  to seconds since epoch with timelocal() from 
Time::Local ( http://perldoc.perl.org/Time/Local.html -- note year 
should be AD year - 1900, and month should be 0-11)

Step 2: get the duration in seconds with simple subtraction

Step 3: us logic like the code posted by Joe to convert to HH:MM:SS. I'd 
suggest you use printf() if you want zero-padded strings like "01:01:01" 
rather than "1:1:1" for 1h 1m 1s

I'd be interested in including your work in my pdatranscode.pl if you're 
interested in sharing the code. Of course since pdatranscode.pl is GPL, 
I don't need your permission -- you could make your own "fork" if you 
wanted, too.


More information about the mythtv-users mailing list