Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Users

Help with pdatranscode.pl

 

 

MythTV users RSS feed   Index | Next | Previous | View Threaded


jtlarson at u

Aug 22, 2007, 12:43 PM

Post #1 of 3 (450 views)
Permalink
Help with pdatranscode.pl

Thanks so much to Jeff and Peter for their work on the transcoding scripts.

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?

Thanks,

Jon


_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


vitaminjoe at gmail

Aug 23, 2007, 10:16 AM

Post #2 of 3 (425 views)
Permalink
Re: Help with pdatranscode.pl [In reply to]

On 8/22/07, Jon Larson <jtlarson [at] u> wrote:

> 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?

This script does a fairly good job:

#!/usr/bin/perl -w

use POSIX;

srand(time);

for (my $i=0; $i<10; $i++) {
my $interval = int(rand(10000));

my $hour = sprintf("%02d", POSIX::floor($interval / 3600));
my $min = sprintf("%02d", POSIX::floor($interval - ($hour * 3600)) / 60);
my $sec = sprintf("%02d", $interval - ($min * 60) - ($hour * 3600));

print "($interval seconds) = HH:MM:SS = $hour:$min:$sec\n";
}



--
Joe Ripley
vitaminjoe [at] gmail
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


peterw at tux

Aug 23, 2007, 1:57 PM

Post #3 of 3 (428 views)
Permalink
Re: Help with pdatranscode.pl [In reply to]

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.

-Peter

_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

MythTV users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.