add developer tool for converting MPEG TS timestamps

This commit is contained in:
Moritz Bunkus 2020-06-21 16:13:24 +02:00
parent 836ce42b73
commit c51c1861c9
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85

View File

@ -0,0 +1,29 @@
#!/usr/bin/perl
use strict;
use warnings;
sub fmt {
my ($orig, $direction, $ts) = @_;
my $seconds = int($ts / 1_000_000_000);
printf "%d %s MPEG is %02d:%02d:%02d.%09d\n", $orig, $direction, int($seconds / 3_600), int($seconds / 60) % 60, $seconds % 60, $ts % 1_000_000_000;
}
my $direction = 'from';
foreach my $arg (@ARGV) {
if ($arg =~ m{^(f|from)$}) {
$direction = 'from';
} if ($arg =~ m{^(t|to)$}) {
$direction = 'to';
} elsif ($direction eq 'from') {
fmt($arg, $direction, int($arg * 100_000 / 9));
} else {
fmt($arg, $direction, int($arg * 9 / 100_000));
}
}