+our @subtitles;
+
+sub html5tv {
+ my $sync;
+
+ foreach my $s ( @subtitles ) {
+ push @{ $sync->{htmlEvents}->{'#subtitle'} }, {
+ startTime => $s->[0],
+ endTime => $s->[1],
+ html => $s->[2],
+ };
+ next unless $s->[2] =~ m{\[(\d+)\]};
+
+ push @{ $sync->{customEvents} }, {
+ startTime => $s->[0],
+ endTime => $s->[1],
+ action => 'chapterChange',
+ args => {
+ carousel => 'theCarousel',
+ id => "chapter$1",
+ index => $1,
+ title => $s->[2],
+ description => $s->[2],
+ src => sprintf('s/117x66/p%08d.jpg', $1),
+ href => '',
+ },
+ }
+ }
+
+ warn "# sync ", dump $sync;
+
+ my $json = to_json $sync;
+ my $sync_path = 'www/video.js';
+ write_file $sync_path, "var video_sync = $json;\n";
+ warn "sync $sync_path ", -s $sync_path, " bytes\n";
+}
+
+