Subtitles(3pm)
π Subtitles(3pm) π
okay bestie, so this is the manual page for Subtitles, a Perl module that lives in the User Contributed Perl Documentation corner of your system. Buckle up, it's cute and it's useful.
β¨ NAME β¨
Subtitles β handle video subtitles in various text formats π¬
πΈ DESCRIPTION πΈ
so like. video files (avi mpeg etc) are sometimes accompanied by subtitles, which rn are super popular as text files. Subtitles gives you the tools for simple loading, re-timing, and storing these subtitle files. there's also a command-line tool, subs, that does the same thing and uses the Subtitles interface β it ships in the distribution. π
the module supports the srt, sub, smi, and mdvd subtitle formats. no cap.
time values are floats, in seconds, with millisecond precision. β±οΈ
π¦ SYNOPSIS π¦
use Subtitles;
my $sub = Subtitles->new();
open F, 'Ichi The Killer.sub' or die "Cannot read:$!";
die "Cannot load:$@\n" unless $sub-> load(\*F);
close F;
# back two minutes
$sub-> shift( $sub-> parse_time('-02:00'));
# re-frame from 25 fps
$sub-> scale( 23.976 / 25 );
# or both
$sub-> transform( -120, 0.96);
$sub-> transform( -120, 0.96, 0, $sub-> length - 60);
# split in 2
my ( $part1, $part2) = $sub-> split( $self-> length / 2);
# join back with 5-second gap
$part1-> join( $part2, 5);
# save
open F, "> out.sub" or die "Cannot write:$!\n";
$part1-> save( \*F);
close F;
# report
print "sub is ", time2str( $sub-> length);
π API π
π Package methods
codecsβ returns an array of the installed codecs. that's it, that's the vibe check. β¨hms2time HOURS, MINUTES, SECONDS, MILLISECONDSβ smushes all four params together into a float time in seconds. π«Άtime2hms TIMEβ splits time into four integers: hours, minutes, seconds, and milliseconds. and listen β if the time is less than zero, you just get zero times back. πtime2shmsβ splits time into five integers: the time sign, hours, minutes, seconds, and milliseconds. sign girlie πtime2str TIMEβ turns a time into a human-readable string. iconic for printing. π
π Object methods
clearβ removes all content. poof. πcodec [ STRING ]β ifSTRINGisn't defined, it hands you the currently associated codec. otherwise it sets the new codec in association. theSTRINGis the codec's package name, likeSubtitles::Codec::srt. πdup [ CLEAR ]β duplicates the object instance in deep-copy fashion. if theCLEARflag is set, the timeframes are not copied. β¨join GUEST, GAPβ adds the content of objectGUESTat the end of the list of subtitles, withGAPin seconds. besties reunited π«Άlengthβ returns the length of the subtitle span. πload FH [ CODEC ]β reads subtitle content into the object. if it works, returns1; otherwiseundefcomes back and$@holds the error. by default it tries to deduce which codec to use, but to point the selection explicitly you pass theCODECstring. π¦linesβ returns the number of subtitle cues. count 'em π’newβ creates a new instance. to force a particular codec, supply thecodecstring right here. β¨parse_time STRINGβ parsesSTRING, which is either a"[[HH:]MM:]SS[,MSEC]"string, or a string in a format specific to a codec β for example, the number of a frame. π₯rate FPSβ forces a particular frame-per-second rate, if a codec can make use of it. ποΈsave FHβ writes the content of the instance into theFHfile handle, using the associated codec. πΎscale Aβ changes the time-scale. ifAis2, the subtitles go off 2 times slower; if0.5, two times faster, etc. β±οΈshift Bβ shifts timings byBseconds.Bcan be negative. βͺsplit TIMEβ splits the content of the instance between two newly created instances of the same class, byTIME, and returns them. both resulting subtitles begin at time 0. π±transform A, B [FROM, TO]β applies a linear transformation to the time-scale, likeu = At + B, wheretis the original time anduis the result. if theFROMandTObrackets are set, the changes are applied only to the lines in the timeframe between these. β¨
π BUGS π
this is alpha code, more a proof-of-concept than anything else, so most surely bugs are lurking. bestie, be careful. π
anyway, also: not all subtitle types are recognized. and the module doesn't handle multi-language subtitles. π
π SEE ALSO π
subs β command-line wrapper for this module π«Ά
π THANKS π
<http://dvd.box.sk/>, <http://subs.2ya.com>. π
π AUTHOR π
Dmitry Karasik, <dmitry@karasik.eu.org>. π
and that's the whole thing, bestie β this page is from perl v5.34.0, dated 2022-06-17, and it's the Subtitles(3pm) page. slay, go time-shift some subtitles. π
β¨π¦
π¦ where this page comes from
- debian bookworm: libsubtitles-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsubtitles-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsubtitles-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsubtitles-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsubtitles-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms