[18425] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # TimedHTMLPlug.pm --
|
---|
| 4 | #
|
---|
| 5 | # A component of the Greenstone digital library software
|
---|
| 6 | # from the New Zealand Digital Library Project at the
|
---|
| 7 | # University of Waikato, New Zealand.
|
---|
| 8 | #
|
---|
| 9 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 10 | #
|
---|
| 11 | # This program is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # This program is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with this program; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | #
|
---|
| 25 | ###########################################################################
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | package TimedHTMLPlugin;
|
---|
| 29 |
|
---|
[18897] | 30 | ##use videoconvert;
|
---|
[18425] | 31 |
|
---|
| 32 | use HTMLPlugin;
|
---|
[18897] | 33 | use VideoConverter;
|
---|
[18425] | 34 |
|
---|
| 35 | sub BEGIN {
|
---|
[18897] | 36 | @TimedHTMLPlugin::ISA = ('HTMLPlugin', 'VideoConverter');
|
---|
[18425] | 37 | }
|
---|
| 38 |
|
---|
[18897] | 39 |
|
---|
[18425] | 40 | use strict; # every perl program should have this!
|
---|
| 41 | no strict 'refs'; # make an exception so we can use variables as filehandles
|
---|
| 42 |
|
---|
| 43 | my $arguments =
|
---|
| 44 | [
|
---|
| 45 | { 'name' => "video_excerpt_duration",
|
---|
| 46 | 'desc' => "{VideoPlug.video_excerpt_duration}",
|
---|
| 47 | 'type' => "string",
|
---|
| 48 | 'reqd' => "no" }
|
---|
| 49 | ];
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | my $options = { 'name' => "TimedHTMLPlugin",
|
---|
| 55 | 'desc' => "{TimedHTMLPlugin.desc}",
|
---|
| 56 | 'abstract' => "no",
|
---|
| 57 | 'inherits' => "yes",
|
---|
| 58 | 'args' => $arguments };
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | sub new {
|
---|
| 62 | my ($class) = shift (@_);
|
---|
| 63 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 64 | push(@$pluginlist, $class);
|
---|
| 65 |
|
---|
| 66 | if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
|
---|
| 67 | if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
|
---|
| 68 |
|
---|
[18897] | 69 | new VideoConverter($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[18425] | 70 |
|
---|
| 71 | my $self = (defined $hashArgOptLists)
|
---|
| 72 | ? new HTMLPlugin($pluginlist,$inputargs,$hashArgOptLists)
|
---|
| 73 | : new HTMLPlugin($pluginlist,$inputargs);
|
---|
| 74 |
|
---|
| 75 | my $collect_dir = $ENV{'GSDLCOLLECTDIR'};
|
---|
| 76 |
|
---|
| 77 | my $collect_bin = &util::filename_cat($collect_dir,"bin");
|
---|
| 78 | my $collect_script = &util::filename_cat($collect_bin,"script");
|
---|
| 79 |
|
---|
| 80 | $ENV{'PATH'} .= ":" if (defined $ENV{'PATH'});
|
---|
| 81 | $ENV{'PATH'} .= "$collect_bin:$collect_script";
|
---|
| 82 |
|
---|
| 83 | return bless $self, $class;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
[18897] | 86 | sub begin {
|
---|
| 87 | my $self = shift (@_);
|
---|
| 88 | my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
|
---|
| 89 |
|
---|
| 90 | $self->SUPER::begin(@_);
|
---|
| 91 | $self->VideoConverter::begin(@_);
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | sub init {
|
---|
| 96 | my $self = shift (@_);
|
---|
| 97 | my ($verbosity, $outhandle, $failhandle) = @_;
|
---|
| 98 |
|
---|
| 99 | $self->SUPER::init(@_);
|
---|
| 100 | $self->VideoConverter::init(@_);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 |
|
---|
[18425] | 104 | sub html_to_text
|
---|
| 105 | {
|
---|
| 106 | my ($self, $text) = @_;
|
---|
| 107 |
|
---|
| 108 | $text =~ s/<\/?[^>]*>//g;
|
---|
| 109 |
|
---|
| 110 | $text =~ s/ / /g;
|
---|
| 111 |
|
---|
| 112 | $text =~ s/\s+/ /gs;
|
---|
| 113 | $text =~ s/^\s+//;
|
---|
| 114 | $text =~ s/\s+$//;
|
---|
| 115 |
|
---|
| 116 | return $text;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | sub extract_metadata_table
|
---|
| 121 | {
|
---|
| 122 | my ($self, $textref) = @_;
|
---|
| 123 |
|
---|
| 124 | my $metatable_store = {};
|
---|
| 125 |
|
---|
| 126 | my $metatable_re = "<table([^>]*)>(.*?<p class=\"?Metadata\"?>.*?)<\\/table>";
|
---|
| 127 |
|
---|
| 128 | if ($$textref =~ m/$metatable_re/gsi) {
|
---|
| 129 | my $metatable_attr = $1;
|
---|
| 130 | my $metatable_body = $2;
|
---|
| 131 |
|
---|
| 132 | my @tr_list = ($metatable_body =~ m/(<tr[^>]*>.*?<\/tr>)/gsi);
|
---|
| 133 |
|
---|
| 134 | my @filtered_tr_list = ();
|
---|
| 135 |
|
---|
| 136 | foreach my $tr (@tr_list) {
|
---|
| 137 |
|
---|
| 138 | my $in_filtered_tr = 1;
|
---|
| 139 |
|
---|
| 140 | my @td_list = ($tr =~ m/<td[^>]*>(.*?)<\/td>/gsi);
|
---|
| 141 | my $td_list_num = scalar(@td_list);
|
---|
| 142 |
|
---|
| 143 | if ($td_list_num == 2) {
|
---|
| 144 | my $meta_name = $self->html_to_text($td_list[0]);
|
---|
| 145 | my $meta_value = $self->html_to_text($td_list[1]);
|
---|
| 146 |
|
---|
| 147 | $meta_name =~ s/\s*//g;
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | if ($meta_value =~ m/^(\s*|\?+)$/) {
|
---|
| 151 | $in_filtered_tr = 0;
|
---|
| 152 | }
|
---|
| 153 | else {
|
---|
| 154 | my $meta_name_label = $meta_name;
|
---|
| 155 | $meta_name_label =~ s/\s+//g;
|
---|
| 156 |
|
---|
| 157 | $metatable_store->{$meta_name_label} = $meta_value;
|
---|
| 158 |
|
---|
| 159 | if ($meta_name_label =~ m/^GS\./) {
|
---|
| 160 | # even though we want to store this as metadata, we
|
---|
| 161 | # don't want this going into table presented at top of document
|
---|
| 162 | $in_filtered_tr = 0;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
| 167 | else {
|
---|
| 168 | print STDERR "Warning: Metadata table does not consist of two cells (metadata name : metadata value)\n";
|
---|
| 169 | print STDERR " Skipping\n";
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 |
|
---|
| 173 | if ($in_filtered_tr) {
|
---|
| 174 | push(@filtered_tr_list,$tr);
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | my $filtered_tr_block = join("\n",@filtered_tr_list);
|
---|
| 179 | my $filtered_table = "<table$metatable_attr>$filtered_tr_block</table>";
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | ### my $metatable_re = "<table[^>]*>.*?<p class=\"?Metadata\"?>.*?<\\/table>";
|
---|
| 183 |
|
---|
| 184 | ### print STDERR "*** filtered table = $filtered_table\n";
|
---|
| 185 |
|
---|
| 186 | $$textref =~ s/$metatable_re/$filtered_table/si;
|
---|
| 187 |
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | return $metatable_store;
|
---|
| 191 |
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 | my $only_num = 0;
|
---|
| 199 | my $only_limit = 100;
|
---|
| 200 |
|
---|
| 201 | sub hms_to_secs
|
---|
| 202 | {
|
---|
| 203 | my $self = shift @_;
|
---|
| 204 | my ($hh,$mm,$ss) = @_;
|
---|
| 205 |
|
---|
| 206 | return $hh*3600 + $mm*60 + $ss;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | sub timed_event
|
---|
| 212 | {
|
---|
| 213 | my $self = shift (@_);
|
---|
| 214 |
|
---|
| 215 | my ($front, $tape, $hh, $mm, $ss, $back) = @_;
|
---|
| 216 |
|
---|
| 217 | my $time_encoded = "$hh:$mm:$ss";
|
---|
| 218 | my $time_encoded_file = "$hh$mm$ss";
|
---|
| 219 |
|
---|
| 220 | my $time_pos = $self->{'time_pos'};
|
---|
| 221 | my $time_num = scalar(@{$self->{'time_seq'}});
|
---|
| 222 |
|
---|
[18897] | 223 | #### my $videoconvert = $self->{'videoconvert'};
|
---|
[18425] | 224 |
|
---|
| 225 | # excerpt from tim_pos -> time_pos + 2;
|
---|
| 226 | my $adv_time_pos = $time_pos+2;
|
---|
| 227 | $adv_time_pos = $time_num-1 if ($adv_time_pos>=$time_num);
|
---|
| 228 |
|
---|
| 229 | my $adv_time_elem = $self->{'time_seq'}->[$adv_time_pos];
|
---|
| 230 |
|
---|
| 231 | # print STDERR "*** ", substr($adv_time_elem,0,800), "\n";
|
---|
| 232 |
|
---|
| 233 | my ($atape,$ah,$am,$as) = ($adv_time_elem =~ m/(T\d+:) ?(\d\d):(\d\d):(\d\d)(?:\:\d\d)?/);
|
---|
| 234 |
|
---|
| 235 | my $excerpt_len = undef;
|
---|
| 236 | my $time_in_secs = $self->hms_to_secs($hh,$mm,$ss);
|
---|
| 237 |
|
---|
| 238 | if (!defined $tape) {
|
---|
| 239 | if (defined $self->{'ptape'}) {
|
---|
| 240 | $tape = $self->{'ptape'};
|
---|
| 241 | }
|
---|
| 242 | else {
|
---|
| 243 | print STDERR "Warning: First time offset does not define tape side\n";
|
---|
| 244 | print STDERR " Defaulting to 1\n";
|
---|
| 245 | $tape = "T1:";
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | if (!defined $atape) {
|
---|
| 250 | $atape = "T1";
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | # print STDERR "**** atape = $atape\n";
|
---|
| 254 | # print STDERR "*** tape = $tape\n";
|
---|
| 255 |
|
---|
| 256 | if ($atape eq $tape) {
|
---|
| 257 | my $adv_time_in_secs = $self->hms_to_secs($ah,$am,$as);
|
---|
| 258 |
|
---|
| 259 | $excerpt_len = $adv_time_in_secs - $time_in_secs;
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | my $collect_dir = $ENV{'GSDLCOLLECTDIR'};
|
---|
| 263 |
|
---|
| 264 | my $media_type = $self->{'media_type'};
|
---|
| 265 | my $media_dir = $self->{'media_dir'};
|
---|
| 266 | my $media_root = $self->{'media_root'};
|
---|
| 267 |
|
---|
| 268 | my $media_base_dir = $self->{'media_base_dir'};
|
---|
| 269 |
|
---|
| 270 | my $mp3_html;
|
---|
| 271 | my $avi_html;
|
---|
| 272 |
|
---|
| 273 | my $tape_num = "1";
|
---|
| 274 |
|
---|
| 275 | if (defined $media_type) {
|
---|
| 276 |
|
---|
| 277 | my $src_file;
|
---|
| 278 | my $src_filename;
|
---|
| 279 |
|
---|
| 280 | if ($media_type eq "video") {
|
---|
| 281 | $src_file = "$media_root\_01_$tape_num.VOB";
|
---|
| 282 | $src_filename
|
---|
| 283 | = &util::filename_cat($media_base_dir, $src_file);
|
---|
| 284 | }
|
---|
| 285 | elsif ($media_type =~ m/^audio$/) {
|
---|
| 286 | $src_file = "$media_root\_Tape$tape_num.mp3";
|
---|
| 287 | $src_filename
|
---|
| 288 | = &util::filename_cat($media_base_dir, $src_file);
|
---|
| 289 | }
|
---|
| 290 | else {
|
---|
| 291 | print STDERR "Warning: Unrecognised media type: $media_type\n";
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | if ($media_type eq "video") {
|
---|
| 296 |
|
---|
| 297 | # video excerpt
|
---|
| 298 |
|
---|
| 299 | my $encoded_file = "$media_dir\_$time_encoded_file.avi";
|
---|
| 300 |
|
---|
| 301 | my $ve_filename
|
---|
| 302 | = &util::filename_cat($collect_dir,"media","video_excerpt",$encoded_file);
|
---|
| 303 |
|
---|
| 304 | if ($only_num < $only_limit) {
|
---|
| 305 | if (! -e $ve_filename) {
|
---|
| 306 | # my $args = "-vcodec mpeg2video";
|
---|
| 307 | my $args = "-vcodec msmpeg4";
|
---|
| 308 |
|
---|
| 309 | my $ve_cmd = "gsmpeg.sh -v 1 -i $src_filename $args -ss $time_encoded ";
|
---|
| 310 |
|
---|
| 311 | if (defined $excerpt_len) {
|
---|
| 312 | $ve_cmd .= "-t $excerpt_len ";
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | $ve_cmd .= $ve_filename;
|
---|
| 316 |
|
---|
| 317 | ## print STDERR "$ve_cmd\n";
|
---|
| 318 |
|
---|
| 319 | ## `$ve_cmd`;
|
---|
| 320 | }
|
---|
| 321 |
|
---|
| 322 | ## my $avi_url = "http://mcgonagall.cs.waikato.ac.nz:8201/gsdl/collect/hauraki2/media/video_excerpt/$media_dir\_$time_encoded_file.avi";
|
---|
| 323 | my $avi_url = "_httpprefix_/collect/hauraki2/media/video_excerpt/$media_dir\_$time_encoded_file.avi";
|
---|
| 324 |
|
---|
| 325 | ## $avi_html = "<a class=\"mm\" href=\"$avi_url\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
|
---|
| 326 |
|
---|
| 327 |
|
---|
| 328 | ## my $stream_url = "_httpstreamserver_/$local_root.asf";
|
---|
| 329 | ## my $stream_url = "http://mcgonagall.cs.waikato.ac.nz:8090/$local_root.avi";
|
---|
| 330 | ## $avi_html .= "<a class=\"mm\" href=\"$stream_url\">Stream</a>";
|
---|
| 331 |
|
---|
| 332 |
|
---|
| 333 | ## $avi_html .= "<a class=\"mm\" href=\"_httpcurrentdocumentwithvplayer_\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
|
---|
| 334 |
|
---|
| 335 | $avi_html .= "<a class=\"mm\" href=\"javascript:videoplayerseek($hh,$mm,$ss)\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
|
---|
| 336 |
|
---|
| 337 | # save 'time-stamp' as metadata???
|
---|
| 338 |
|
---|
| 339 |
|
---|
| 340 |
|
---|
| 341 | }
|
---|
| 342 | else {
|
---|
| 343 | $avi_html = "<img src=\"_httpcimages_\/video5.gif\">";
|
---|
| 344 | }
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | if ($media_type =~ m/^(video|audio)$/) {
|
---|
| 348 |
|
---|
| 349 | # audio excerpt
|
---|
| 350 | # my $encoded_file = "$media_dir\_$time_encoded_file.mp3";
|
---|
| 351 |
|
---|
| 352 | # ## my $src_file = "$media_root\_Tape$tape_num.avi";
|
---|
| 353 |
|
---|
| 354 | # #my $src_filename
|
---|
| 355 | # # = &util::filename_cat($collect_dir,"media",$media_type ,$media_dir, $src_file);
|
---|
| 356 |
|
---|
| 357 | # my $ae_filename
|
---|
| 358 | # = &util::filename_cat($collect_dir,"media","audio_excerpt",$encoded_file);
|
---|
| 359 |
|
---|
| 360 |
|
---|
| 361 | if ($only_num < $only_limit) {
|
---|
| 362 |
|
---|
| 363 | $excerpt_len = 120 if (!defined $excerpt_len); #######
|
---|
| 364 |
|
---|
| 365 | my ($ae_cmd,$omp3_filename,$omp3_file)
|
---|
[18897] | 366 | = $self->audio_excerpt_cmd($src_filename,
|
---|
| 367 | $hh,$mm,$ss,$excerpt_len);
|
---|
[18425] | 368 |
|
---|
[18897] | 369 | my $ae_options = { @{$self->{'ffmpeg_monitor'}},
|
---|
[18425] | 370 | 'message_prefix' => "Audio Excerpt",
|
---|
| 371 | 'message' => "Generating audio excerpt: $omp3_file" };
|
---|
| 372 |
|
---|
| 373 | my ($ae_regenerated,$ae_result,$ae_had_error)
|
---|
[18897] | 374 | = $self->run_cached_general_cmd($ae_cmd,$omp3_filename,$ae_options);
|
---|
[18425] | 375 |
|
---|
| 376 | push(@{$self->{'mp3_excerpts'}}, { 'omp3_file' => $omp3_file, 'omp3_filename' => $omp3_filename} );
|
---|
| 377 |
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 |
|
---|
| 382 |
|
---|
| 383 | # if (! -e $ae_filename) {
|
---|
| 384 | if ($only_num < $only_limit) {
|
---|
| 385 | # if (! -e $ae_filename) {
|
---|
| 386 |
|
---|
| 387 | # my $args = "-acodec mp3";
|
---|
| 388 |
|
---|
| 389 | # ## my $src_filename = "media/video/mirth/VTS_01_1.avi";
|
---|
| 390 | # my $ae_cmd = "gsmpeg.sh -v 1 -i $src_filename $args -ss $time_encoded ";
|
---|
| 391 |
|
---|
| 392 | # if (defined $excerpt_len) {
|
---|
| 393 | # $ae_cmd .= "-t $excerpt_len ";
|
---|
| 394 | # }
|
---|
| 395 |
|
---|
| 396 | # $ae_cmd .= $ae_filename;
|
---|
| 397 |
|
---|
| 398 | ## print STDERR "$ae_cmd\n";
|
---|
| 399 |
|
---|
| 400 | ## `$ae_cmd`;
|
---|
| 401 | # }
|
---|
| 402 |
|
---|
| 403 |
|
---|
| 404 | ## my $mp3_url = "http://mcgonagall.cs.waikato.ac.nz:8201/gsdl/collect/hauraki2/media/audio_excerpt/$media_dir\_$time_encoded_file.mp3";
|
---|
| 405 | # my $mp3_url = "_httpprefix_/collect/hauraki2/media/audio_excerpt/$media_dir\_$time_encoded_file.mp3";
|
---|
| 406 |
|
---|
| 407 | my ($voa_root) = ($src_file =~ m/^(.*)\..*?$/);
|
---|
| 408 |
|
---|
| 409 | my $mp3_url = "javascript:audioexcerptplay('$voa_root','$hh','$mm','$ss')";
|
---|
| 410 |
|
---|
| 411 | # my $mp3_url = "_httpcollection_/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}/$media_dir\_$time_encoded_file.mp3";
|
---|
| 412 |
|
---|
| 413 | $mp3_html = "<a class=\"mm\" href=\"$mp3_url\"><img border=1 src=\"_httpcimages_\/audio2.gif\"></a>";
|
---|
| 414 |
|
---|
| 415 | # my $baseexcerpt_url = "_httpcollection_/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}";
|
---|
| 416 |
|
---|
| 417 | ##### $doc_obj->add_metadata ($section, "audioexcerpturl",$mp3_url);
|
---|
| 418 |
|
---|
| 419 |
|
---|
| 420 | }
|
---|
| 421 | else {
|
---|
| 422 | $mp3_html = "<img src=\"_httpcimages_\/audio2.gif\">";
|
---|
| 423 |
|
---|
| 424 | }
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 | else {
|
---|
| 428 | print STDERR "Warning: no media type defined.\n";
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 |
|
---|
| 432 | $only_num++;
|
---|
| 433 |
|
---|
| 434 | $self->{'time_pos'}++;
|
---|
| 435 |
|
---|
| 436 | my $table = "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\"><tr valign=\"middle\">";
|
---|
| 437 | $table .= "<td>$avi_html</td>" if (defined $avi_html);
|
---|
| 438 | $table .= "<td>$mp3_html</td>";
|
---|
| 439 | $table .= "<td>$time_encoded</td>";
|
---|
| 440 | $table .= "</tr></table>";
|
---|
| 441 |
|
---|
| 442 | # my $line = "$front$avi_html $mp3_html $time_encoded$back";
|
---|
| 443 |
|
---|
| 444 | my $line = "$front$table$back";
|
---|
| 445 |
|
---|
| 446 | # Remember tape prefix for next call
|
---|
| 447 | $self->{'ptape'} = $tape;
|
---|
| 448 |
|
---|
| 449 | return $line;
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 |
|
---|
| 453 | sub hyperlink_timing_info
|
---|
| 454 | {
|
---|
| 455 | my ($self, $textref) = @_;
|
---|
| 456 |
|
---|
| 457 | my $media_type = $self->{'media_type'};
|
---|
| 458 | my $media_dir = $self->{'media_dir'};
|
---|
| 459 | my $media_root = $self->{'media_root'};
|
---|
| 460 |
|
---|
| 461 | my $front_re = "<p class=Timing><span\\s+.*?>";
|
---|
| 462 | my $tape_re = "T\\d+:";
|
---|
| 463 | my $tt_re = "\\d\\d";
|
---|
| 464 | my $back_re = ".*?<\\/span>";
|
---|
| 465 |
|
---|
| 466 | my $time_match_re = "$front_re$tt_re:$tt_re:$tt_re$back_re(?:\:$tt_re)?";
|
---|
| 467 | # my $time_sub_re = "($front_re)($tape_re)? ?($tt_re):($tt_re):($tt_re)(?:\:$tt_re)?($back_re)";
|
---|
| 468 |
|
---|
| 469 | my $tape_match_re = "$front_re($tape_re)? ?$tt_re:$tt_re:$tt_re(?:\:$tt_re)?$back_re";
|
---|
| 470 | my $tape_sub_re = "($front_re)($tt_re):($tt_re):($tt_re)(?:\:$tt_re)?($back_re)";
|
---|
| 471 |
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 | my @time_seq = ($$textref =~ m/$time_match_re/sgi);
|
---|
| 475 |
|
---|
| 476 | # artifically add tape information into all time indexes
|
---|
| 477 | my $extrapolate_tape = "";
|
---|
| 478 | my $num_seq = scalar(@time_seq);
|
---|
| 479 | for (my $i=0; $i<$num_seq; $i++) {
|
---|
| 480 | my ($curr_tape) = ($time_seq[$i] =~ m/$tape_match_re/sgi);
|
---|
| 481 | if (!defined $curr_tape) {
|
---|
| 482 | $time_seq[$i] =~ s/$tape_sub_re/$1$extrapolate_tape$2:$3:$4$5/sgi;
|
---|
| 483 | }
|
---|
| 484 | else {
|
---|
| 485 | if ($curr_tape ne $extrapolate_tape) {
|
---|
| 486 | $extrapolate_tape = $curr_tape;
|
---|
| 487 | }
|
---|
| 488 | }
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 |
|
---|
| 492 | $self->{'time_seq'} = \@time_seq;
|
---|
| 493 | $self->{'time_pos'} = 0;
|
---|
| 494 |
|
---|
| 495 | $$textref =~ s/(<p class=Timing><span\s+.*?>)(T\d+:)? ?(\d\d):(\d\d):(\d\d)(?:\:\d\d)?.*?(<\/span>)/$self->timed_event($1,$2,$3,$4,$5,$6)/sgie;
|
---|
| 496 |
|
---|
| 497 |
|
---|
| 498 | # knock out any div tags as they interfere with document broken up into sections
|
---|
| 499 | $$textref =~ s/<\/?div.*?>//gi;
|
---|
| 500 |
|
---|
| 501 | # Embedded word style infomation is lost by HTMLPlug => make Question
|
---|
| 502 | # style use HTML italics
|
---|
| 503 |
|
---|
| 504 | $$textref =~ s/<p class=\"Question\">(.*?)<\/p>/<p><i>$1<\/i><\/p>/gsi;
|
---|
| 505 |
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 |
|
---|
| 509 |
|
---|
| 510 | sub store_block_files
|
---|
| 511 | {
|
---|
| 512 | my $self =shift (@_);
|
---|
| 513 | my ($filename_full_path, $block_hash) = @_;
|
---|
| 514 |
|
---|
| 515 | # Would be better if this were tied to particular HTML docs that
|
---|
| 516 | # this plugin has processed.
|
---|
| 517 |
|
---|
| 518 | # For now block all files native to DVD format
|
---|
| 519 |
|
---|
| 520 | if (($filename_full_path =~ m/\.(IFO|BUP)$/) # block info and backup-info data
|
---|
| 521 | || ($filename_full_path =~ m/VIDEO_TS\..*?$/) # block top-level files
|
---|
| 522 | || ($filename_full_path =~ m/VTS_\d\d_\d\.VOB$/) #
|
---|
| 523 | ) {
|
---|
| 524 |
|
---|
| 525 | $block_hash->{'file_blocks'}->{$filename_full_path} = 1;
|
---|
| 526 | }
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | sub read_block {
|
---|
| 530 | my $self = shift (@_);
|
---|
| 531 |
|
---|
| 532 | my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
|
---|
| 533 |
|
---|
| 534 | print STDERR "***** TimedHTMLPlugin read_block\n";
|
---|
| 535 |
|
---|
| 536 | my $filename = $file;
|
---|
| 537 | $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
|
---|
| 538 |
|
---|
| 539 | if (($filename =~ m/\.(IFO|BUP)$/) # block info and backup-info data
|
---|
| 540 | || ($filename =~ m/VIDEO_TS\..*?$/) # block top-level files
|
---|
| 541 | || ($filename =~ m/VTS_\d\d_\d\.VOB$/) #
|
---|
| 542 | ) {
|
---|
| 543 | $self->{'num_blocked'} ++;
|
---|
| 544 | return (0,undef); # blocked
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 |
|
---|
| 548 | ##### || ($filename =~ m/VTS_\d\d_0\.VOB$/) # block menu item for this track
|
---|
| 549 |
|
---|
| 550 |
|
---|
| 551 | if (defined $self->{'file_blocks'}->{$filename} && $self->{'file_blocks'}->{$filename} == 1){
|
---|
| 552 | $self->{'num_blocked'} ++;
|
---|
| 553 | return (0,undef); # blocked
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 |
|
---|
| 557 | if (defined $self->{'re_file_block'}) {
|
---|
| 558 | my $re_file_blocks = $self->{'re_file_block'};
|
---|
| 559 | foreach my $re_file_block (@$re_file_blocks) {
|
---|
| 560 | ### print STDERR "**** re file block: $filename =~ m $re_file_block\n";
|
---|
| 561 | if ($filename =~ m/$re_file_block/) {
|
---|
| 562 | ### print STDERR "*** blocking $filename\n";
|
---|
| 563 |
|
---|
| 564 | $self->{'num_blocked'} ++;
|
---|
| 565 | return (0,undef); # blocked
|
---|
| 566 | }
|
---|
| 567 | }
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 |
|
---|
| 571 | return $self->SUPER::read_block(@_);
|
---|
| 572 |
|
---|
| 573 | }
|
---|
| 574 |
|
---|
| 575 |
|
---|
| 576 | sub read_file {
|
---|
| 577 | my $self = shift @_;
|
---|
| 578 | my ($filename, $encoding, $language, $textref) = @_;
|
---|
| 579 |
|
---|
| 580 | $only_num = 0;
|
---|
| 581 |
|
---|
| 582 | $self->SUPER::read_file(@_);
|
---|
| 583 |
|
---|
| 584 | my $metatable_store = $self->extract_metadata_table($textref);
|
---|
| 585 | $self->{'metatable_store'} = $metatable_store;
|
---|
| 586 |
|
---|
| 587 | my ($root, $dirname, $suffix)
|
---|
| 588 | = &File::Basename::fileparse($filename, "\\.[^\\.]+\$");
|
---|
| 589 |
|
---|
| 590 | # media defaults
|
---|
| 591 | my $media_type = undef;
|
---|
| 592 | my $media_dir = $root;
|
---|
| 593 | ## my $media_root = "VTS_%02d_%02d";
|
---|
| 594 | my $media_root = "VTS";
|
---|
| 595 |
|
---|
| 596 | if (defined $metatable_store->{'GS.Media'}) {
|
---|
| 597 | $media_type = $metatable_store->{'GS.Media'};
|
---|
| 598 | $media_type = lc($media_type);
|
---|
| 599 | }
|
---|
| 600 | if (defined $metatable_store->{'GS.MediaDirectory'}) {
|
---|
| 601 | $media_dir = $metatable_store->{'GS.MediaDirectory'};
|
---|
| 602 | }
|
---|
| 603 | if (defined $metatable_store->{'GS.MediaRoot'}) {
|
---|
| 604 | $media_root = $metatable_store->{'GS.MediaRoot'};
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | $self->{'media_type'} = $media_type;
|
---|
| 608 | $self->{'media_dir'} = $media_dir;
|
---|
| 609 | $self->{'media_root'} = $media_root;
|
---|
| 610 |
|
---|
| 611 | my $media_base_dir = &util::filename_cat($dirname,$media_dir);
|
---|
| 612 | $self->{'media_base_dir'} = $media_base_dir;
|
---|
| 613 |
|
---|
[18897] | 614 | $self->{'vob_duration_info'} = &VideoConverter::vob_durations($media_base_dir,"1",$self->{'outhandle'});
|
---|
[18425] | 615 |
|
---|
| 616 | ## $self->hyperlink_timing_info($textref);
|
---|
| 617 |
|
---|
| 618 | # Convert entities to their UTF8 equivalents
|
---|
| 619 | $$textref =~ s/&(lt|gt|amp|quot|nbsp);/&z$1;/go;
|
---|
| 620 | $$textref =~ s/&([^;]+);/&ghtml::getcharequiv($1,1)/gseo;
|
---|
| 621 | $$textref =~ s/&z(lt|gt|amp|quot|nbsp);/&$1;/go;
|
---|
| 622 | }
|
---|
| 623 |
|
---|
| 624 |
|
---|
| 625 | sub streamable_video
|
---|
| 626 | {
|
---|
| 627 | my $self = shift (@_);
|
---|
| 628 |
|
---|
| 629 | my ($base_dir,$filename,$doc_obj,$section) = @_;
|
---|
| 630 |
|
---|
| 631 | my $outhandle = $self->{'outhandle'};
|
---|
| 632 | my $verbosity = $self->{'verbosity'};
|
---|
| 633 |
|
---|
| 634 | my $media_base_dir = $self->{'media_base_dir'};
|
---|
| 635 |
|
---|
| 636 | #---
|
---|
| 637 | # Determine size of input video
|
---|
| 638 |
|
---|
| 639 | my $collect_dir = $ENV{'GSDLCOLLECTDIR'};
|
---|
| 640 |
|
---|
| 641 | my $media_type = $self->{'media_type'};
|
---|
| 642 | my $media_dir = $self->{'media_dir'};
|
---|
| 643 | my $media_root = $self->{'media_root'};
|
---|
| 644 |
|
---|
| 645 | my $tape_num = "1";
|
---|
| 646 |
|
---|
| 647 | my $src_file;
|
---|
| 648 | my $src_filename;
|
---|
| 649 |
|
---|
| 650 | if ($media_type eq "video") {
|
---|
| 651 | $src_file = "$media_root\_01_$tape_num.VOB";
|
---|
| 652 | $src_filename
|
---|
| 653 | = &util::filename_cat($media_base_dir, $src_file);
|
---|
| 654 | }
|
---|
| 655 | elsif ($media_type =~ m/^audio$/) {
|
---|
| 656 | $src_file = "$media_root\_Tape$tape_num.mp3";
|
---|
| 657 | $src_filename
|
---|
| 658 | = &util::filename_cat($media_base_dir, $src_file);
|
---|
| 659 | }
|
---|
| 660 | else {
|
---|
| 661 | print STDERR "Warning: Unrecognised media type: $media_type\n";
|
---|
| 662 | }
|
---|
| 663 |
|
---|
| 664 | if (-e $src_filename) {
|
---|
| 665 | $self->{'file_blocks'}->{$src_filename} = 1;
|
---|
| 666 |
|
---|
| 667 | my $re_file_block = $src_filename;
|
---|
| 668 | $re_file_block =~ s/_01_$tape_num.VOB$/_\\d+_\\d+.VOB\$/;
|
---|
| 669 |
|
---|
| 670 |
|
---|
| 671 | push(@{$self->{'re_file_block'}},$re_file_block);
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 | my ($video_type, $video_width, $video_height, $video_duration, $video_size,
|
---|
| 675 | $vcodec,$vfps,$atype,$afreq,$achan,$arate)
|
---|
[18897] | 676 | = &VideoConverter::identify($src_filename, $outhandle, $verbosity);
|
---|
[18425] | 677 |
|
---|
| 678 | if ($vfps eq "unknown") {
|
---|
| 679 | print $outhandle "Unknown framerate, defaulting to 25 frames per second.\n";
|
---|
| 680 | $vfps = 25;
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | ### print STDERR "*** video duration = $video_duration\n";
|
---|
| 684 | my ($dur_hour,$dur_min,$dur_sec)
|
---|
| 685 | = ($video_duration =~ m/(\d+):(\d+):(\d+\.\d+)/);
|
---|
| 686 | my $total_dur_secs = $dur_hour*3600 + $dur_min*60 + $dur_sec;
|
---|
| 687 |
|
---|
| 688 | $self->{'video-fps'} = $vfps;
|
---|
| 689 | $self->{'num-total-frames'} = $total_dur_secs * $vfps;
|
---|
| 690 |
|
---|
| 691 |
|
---|
| 692 | # shorten duration prcessed for experimentation purposes
|
---|
| 693 | my $exp_duration = undef;
|
---|
| 694 |
|
---|
| 695 | my $video_excerpt_duration = $self->{'video_excerpt_duration'};
|
---|
| 696 |
|
---|
| 697 | print STDERR "**** video duration (secs) = $total_dur_secs\n";
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 | if ((defined $video_excerpt_duration) && ($video_excerpt_duration ne "")) {
|
---|
| 701 | $exp_duration = $video_excerpt_duration;
|
---|
| 702 | my ($hh,$mm,$ss,$ms) = ($exp_duration =~ m/^(\d\d):(\d\d):(\d\d)\.?(\d\d)?/);
|
---|
| 703 | my $excerpt_dur_in_secs = $hh * 3600 + $mm * 60 + $ss;
|
---|
| 704 |
|
---|
| 705 | if ($excerpt_dur_in_secs < $total_dur_secs) {
|
---|
| 706 | $self->{'num-total-frames'} = $excerpt_dur_in_secs * $vfps; # override calculation for full length duration
|
---|
| 707 | }
|
---|
| 708 | else {
|
---|
| 709 | # clip is already shorter than requested video excerpt duration
|
---|
| 710 | # set exp_duration back to undefined
|
---|
| 711 | $exp_duration = undef;
|
---|
| 712 | }
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 | print $outhandle "TimedHTMLPlug: Preparing video files associated with $filename for HTMLPlug\n";
|
---|
| 716 |
|
---|
| 717 | if (defined $exp_duration)
|
---|
| 718 | {
|
---|
| 719 | print $outhandle "Only encoding first $exp_duration of video.\n";
|
---|
| 720 | $self->{'exp_duration'} = $exp_duration;
|
---|
| 721 | }
|
---|
| 722 |
|
---|
| 723 |
|
---|
[18897] | 724 | ### my $videoconvert
|
---|
| 725 | ### = new videoconvert($base_dir,$src_filename,$verbosity,$outhandle,$exp_duration);
|
---|
| 726 | ### $self->{'videoconvert'} = $videoconvert;
|
---|
[18425] | 727 |
|
---|
| 728 | #---
|
---|
| 729 | # Generate the Flash FLV format for streaming purposes
|
---|
| 730 |
|
---|
| 731 | my $streaming_bitrate = "256k"; # used to be 192k
|
---|
| 732 | my $streaming_size = "360"; # used to be 352 (CIF?)
|
---|
| 733 | my $streaming_achan = "1";
|
---|
| 734 | my $streaming_arate = "44100";
|
---|
| 735 | my $streaming_quality = "high";
|
---|
| 736 |
|
---|
| 737 | #---
|
---|
| 738 | # Convert video to flash
|
---|
| 739 | #---
|
---|
| 740 | my ($stream_cmd,$oflash_filename,$oflash_file)
|
---|
[18897] | 741 | = $self->stream_cmd($src_filename,
|
---|
| 742 | $video_width,$video_height,
|
---|
| 743 | $streaming_quality, $streaming_bitrate, $streaming_size,
|
---|
| 744 | $streaming_achan, $streaming_arate);
|
---|
[18425] | 745 |
|
---|
[18897] | 746 | my $streamable_options = { @{$self->{'ffmpeg_monitor'}},
|
---|
[18425] | 747 | 'message_prefix' => "Stream",
|
---|
| 748 | 'message' => "Generating streamable video: $oflash_file" };
|
---|
| 749 |
|
---|
| 750 | my ($streamable_regenerated,$streamable_result,$streamable_had_error)
|
---|
[18897] | 751 | = $self->run_cached_general_cmd($stream_cmd,$oflash_filename,$streamable_options);
|
---|
[18425] | 752 |
|
---|
| 753 | $self->{'streamable_regenerated'} = $streamable_regenerated;
|
---|
| 754 |
|
---|
| 755 | if (!$streamable_had_error) {
|
---|
| 756 | #---
|
---|
| 757 | # Make video seekable
|
---|
| 758 | #---
|
---|
[18897] | 759 | my ($streamseekable_cmd,$ostreamseekable_filename) = $self->streamseekable_cmd($oflash_filename);
|
---|
[18425] | 760 |
|
---|
[18897] | 761 | my $streamseekable_options = { @{$self->{'flvtool2_monitor'}},
|
---|
[18425] | 762 | 'message_prefix' => "Stream Seekable",
|
---|
| 763 | 'message' => "Reprocessing video stream to be seekable by timeline: $oflash_file" };
|
---|
| 764 |
|
---|
| 765 | if ($streamable_regenerated) {
|
---|
[18897] | 766 | $self->run_general_cmd($streamseekable_cmd,$streamseekable_options);
|
---|
[18425] | 767 | }
|
---|
| 768 |
|
---|
| 769 | my $streamable_url = $oflash_file;
|
---|
| 770 | ## $streamable_url =~ s/ /%20/g;
|
---|
| 771 |
|
---|
| 772 | $doc_obj->add_metadata ($section, "streamablevideo", $streamable_url);
|
---|
| 773 | $doc_obj->associate_file($oflash_filename,$oflash_file,"video/flash",
|
---|
| 774 | $section);
|
---|
| 775 | }
|
---|
| 776 |
|
---|
| 777 | #
|
---|
| 778 | # FlowPlayer.swf height+22 pixels
|
---|
| 779 | # FlowPlayerBlack.swf height+16 pixels
|
---|
| 780 | # FlowPlayerThermo.swf height+16 pixels
|
---|
| 781 | # FlowPlayerWhite.swf height+26 pixels
|
---|
| 782 | $doc_obj->add_metadata ($section, "flashwidth", $video_width);
|
---|
| 783 | $doc_obj->add_metadata ($section, "flashheight", $video_height + 22 + 100);
|
---|
| 784 |
|
---|
| 785 | my $base_url = "_httpstreamserverprefix_/collect/[collection]/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}/";
|
---|
| 786 |
|
---|
| 787 | $doc_obj->add_metadata ($section, "baseurl",$base_url);
|
---|
| 788 |
|
---|
| 789 | $self->{'oflash_file'} = $oflash_file;
|
---|
| 790 | $self->{'oflash_filename'} = $oflash_filename;
|
---|
| 791 |
|
---|
| 792 | }
|
---|
| 793 |
|
---|
| 794 |
|
---|
| 795 |
|
---|
| 796 | sub add_cuepoints
|
---|
| 797 | {
|
---|
| 798 | my ($self) = shift @_;
|
---|
| 799 | my ($doc_obj) = @_;
|
---|
| 800 |
|
---|
| 801 | my $section = $doc_obj->get_top_section();
|
---|
| 802 | my $chapters = $doc_obj->get_children($section);
|
---|
| 803 |
|
---|
| 804 |
|
---|
| 805 | # open file
|
---|
[18897] | 806 | my $output_dir = $self->{'cached_dir'};
|
---|
[18425] | 807 | my $cue_filename = &util::filename_cat($output_dir,"on_cue.xml");
|
---|
| 808 |
|
---|
| 809 | open(CUEOUT,">$cue_filename")
|
---|
| 810 | || die "Unable to open $cue_filename: $!\n";
|
---|
| 811 | print CUEOUT "<tags>\n";
|
---|
| 812 |
|
---|
| 813 |
|
---|
| 814 | my $cc = 0;
|
---|
| 815 |
|
---|
| 816 | foreach my $chap (@$chapters)
|
---|
| 817 | {
|
---|
| 818 | $cc++;
|
---|
| 819 |
|
---|
| 820 | my $chap_text = $doc_obj->get_text($chap);
|
---|
| 821 |
|
---|
| 822 | my @cuepoints
|
---|
| 823 | = ($chap_text =~ m/<p class=Timing><span\s+.*?>(?:T\d+:)? ?(\d\d:\d\d:\d\d)(?:\:\d\d)?/gsi);
|
---|
| 824 |
|
---|
| 825 | my $count = 0;
|
---|
| 826 |
|
---|
| 827 | foreach my $cuepoint (@cuepoints)
|
---|
| 828 | {
|
---|
| 829 | my ($hh,$mm,$ss) = ($cuepoint =~ m/(\d\d):(\d\d):(\d\d)/);
|
---|
| 830 |
|
---|
| 831 | my $cuept_insecs = $self->hms_to_secs($hh,$mm,$ss);
|
---|
| 832 |
|
---|
| 833 | if ($cuept_insecs < 2) {
|
---|
| 834 | $cuept_insecs += 2;
|
---|
| 835 | }
|
---|
| 836 | my $cuept_inmsecs = 1000 * $cuept_insecs;
|
---|
| 837 |
|
---|
| 838 | $doc_obj->add_metadata($section,"cuepoint",$cuept_inmsecs);
|
---|
| 839 | my $chap_title = $doc_obj->get_metadata_element($chap,"Title");
|
---|
| 840 |
|
---|
| 841 | # Navigation point (used in seeking)
|
---|
| 842 | # print CUEOUT " <metatag event=\"onCuePoint\" overwrite=\"true\">\n";
|
---|
| 843 | # print CUEOUT " <name>$chap_title</name>\n";
|
---|
| 844 | # print CUEOUT " <timestamp>$cuept_inmsecs</timestamp>\n";
|
---|
| 845 | # print CUEOUT " <parameters>\n";
|
---|
| 846 | # print CUEOUT " <thumb>dummy</thumb>\n";
|
---|
| 847 | # print CUEOUT " <sectionnum>$chap</sectionnum>\n";
|
---|
| 848 | # print CUEOUT " <subsectionnum>$count</subsectionnum>\n";
|
---|
| 849 | # print CUEOUT " <cuept>$cuept_inmsecs</cuept>\n";
|
---|
| 850 | # print CUEOUT " </parameters>\n";
|
---|
| 851 | # print CUEOUT " <type>navigation</type>\n";
|
---|
| 852 | # print CUEOUT " </metatag>\n";
|
---|
| 853 |
|
---|
| 854 |
|
---|
| 855 | # print CUEOUT " <metatag event=\"onCuePoint\" overwrite=\"true\">\n";
|
---|
| 856 | # print CUEOUT " <name>$chap_title</name>\n";
|
---|
| 857 | # print CUEOUT " <timestamp>$cuept_inmsecs</timestamp>\n";
|
---|
| 858 | # print CUEOUT " <parameters>\n";
|
---|
| 859 | # print CUEOUT " <thumb>foo.jpg</thumb>\n";
|
---|
| 860 | # print CUEOUT " </parameters>\n";
|
---|
| 861 | # print CUEOUT " <type>navigation</type>\n";
|
---|
| 862 | # print CUEOUT " </metatag>\n";
|
---|
| 863 |
|
---|
| 864 | if ($count==0)
|
---|
| 865 | {
|
---|
| 866 | # Event (used to hook in to javascipt callback)
|
---|
| 867 | # Only do for the first in each chapter
|
---|
| 868 |
|
---|
| 869 | print CUEOUT " <metatag event=\"onCuePoint\" overwrite=\"true\">\n";
|
---|
| 870 | ## print CUEOUT " <name>Test $cc</name>\n";
|
---|
| 871 | print CUEOUT " <name>$chap_title</name>\n";
|
---|
| 872 | print CUEOUT " <timestamp>$cuept_inmsecs</timestamp>\n";
|
---|
| 873 | print CUEOUT " <parameters>\n";
|
---|
| 874 | print CUEOUT " <cuept>$cuept_inmsecs</cuept>\n";
|
---|
| 875 | print CUEOUT " <sectionnum>$chap</sectionnum>\n";
|
---|
| 876 | print CUEOUT " </parameters>\n";
|
---|
| 877 | print CUEOUT " <type>event</type>\n";
|
---|
| 878 | ## print CUEOUT " <type>actionscript</type>\n";
|
---|
| 879 | print CUEOUT " </metatag>\n";
|
---|
| 880 | }
|
---|
| 881 |
|
---|
| 882 | $count++;
|
---|
| 883 | }
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 |
|
---|
| 887 | print CUEOUT "</tags>\n";
|
---|
| 888 | close(CUEOUT);
|
---|
| 889 |
|
---|
[18897] | 890 | #### my $videoconvert = $self->{'videoconvert'};
|
---|
[18425] | 891 | my $oflash_filename = $self->{'oflash_filename'};
|
---|
| 892 | my $oflash_file = $self->{'oflash_file'};
|
---|
| 893 |
|
---|
[18897] | 894 | my ($streamcuepts_cmd,$ostreamcuepts_filename) = $self->streamcuepts_cmd($oflash_filename);
|
---|
[18425] | 895 |
|
---|
| 896 | my $verbosity = $self->{'verbosity'};
|
---|
| 897 | my $outhandle = $self->{'outhandle'};
|
---|
| 898 |
|
---|
[18897] | 899 | my $streamcuepts_options = { @{$self->{'flvtool2_monitor'}},
|
---|
[18425] | 900 | 'message_prefix' => "Stream Cue Points",
|
---|
| 901 | 'message' => "Reprocessing video stream to add cuepoints on timeline: $oflash_file" };
|
---|
| 902 |
|
---|
| 903 | my $streamable_regenerated = $self->{'streamable_regenerated'};
|
---|
| 904 |
|
---|
| 905 | if ($streamable_regenerated) {
|
---|
[18897] | 906 | $self->run_general_cmd($streamcuepts_cmd,$streamcuepts_options);
|
---|
[18425] | 907 | }
|
---|
| 908 |
|
---|
| 909 |
|
---|
| 910 |
|
---|
| 911 | }
|
---|
| 912 |
|
---|
| 913 |
|
---|
| 914 |
|
---|
| 915 | sub process {
|
---|
| 916 | my $self = shift (@_);
|
---|
| 917 | my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
|
---|
| 918 |
|
---|
| 919 | my $filename = $file;
|
---|
| 920 | $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
|
---|
| 921 |
|
---|
| 922 | my $top_section = $doc_obj->get_top_section();
|
---|
| 923 |
|
---|
| 924 | $self->streamable_video($base_dir,$filename,$doc_obj,$top_section);
|
---|
| 925 |
|
---|
| 926 | $self->hyperlink_timing_info($textref);
|
---|
| 927 |
|
---|
| 928 | foreach my $mp3_excerpt (@{$self->{'mp3_excerpts'}}) {
|
---|
| 929 | my $omp3_file = $mp3_excerpt->{'omp3_file'};
|
---|
| 930 | my $omp3_filename = $mp3_excerpt->{'omp3_filename'};
|
---|
| 931 |
|
---|
| 932 | $doc_obj->associate_file($omp3_filename,$omp3_file,"audio/mp3",
|
---|
| 933 | $top_section);
|
---|
| 934 | }
|
---|
| 935 | $self->{'mp3_excerpts'} = undef;
|
---|
| 936 |
|
---|
| 937 | my $metatable_store = $self->{'metatable_store'};
|
---|
| 938 | foreach my $metaname (keys %$metatable_store) {
|
---|
| 939 | my $metadata = $metatable_store->{$metaname};
|
---|
| 940 | $doc_obj->add_metadata($top_section,$metaname,$metadata);
|
---|
| 941 | }
|
---|
| 942 | $self->{'metatable_store'} = undef;
|
---|
| 943 |
|
---|
| 944 | my $ret_val = $self->SUPER::process(@_);
|
---|
| 945 |
|
---|
| 946 | $self->add_cuepoints($doc_obj);
|
---|
| 947 |
|
---|
| 948 |
|
---|
| 949 | return $ret_val;
|
---|
| 950 |
|
---|
| 951 | }
|
---|
| 952 |
|
---|
| 953 |
|
---|
| 954 |
|
---|
| 955 | sub replace_images {
|
---|
| 956 | my $self = shift (@_);
|
---|
| 957 | my ($front, $link, $back, $base_dir,
|
---|
| 958 | $file, $doc_obj, $section) = @_;
|
---|
| 959 |
|
---|
| 960 | if ($link =~ m/^"?_.*?_"?\//) {
|
---|
| 961 | # variety of greenstone macro, so let through unchanged
|
---|
| 962 | return $front . $link . $back ;
|
---|
| 963 | }
|
---|
| 964 |
|
---|
| 965 | return $self->SUPER::replace_images(@_);
|
---|
| 966 | }
|
---|
| 967 |
|
---|
| 968 |
|
---|
| 969 |
|
---|
| 970 |
|
---|
| 971 |
|
---|
| 972 | sub replace_href_links {
|
---|
| 973 | my $self = shift (@_);
|
---|
| 974 | my ($front, $link, $back, $base_dir, $file, $doc_obj, $section) = @_;
|
---|
| 975 |
|
---|
| 976 |
|
---|
| 977 | if ($link =~ m/^"?_.*?_"?/) {
|
---|
| 978 | # variety of greenstone macro, so let through unchanged
|
---|
| 979 | return $front . $link . $back ;
|
---|
| 980 | }
|
---|
| 981 |
|
---|
| 982 | return $self->SUPER::replace_href_links(@_);
|
---|
| 983 | }
|
---|
| 984 |
|
---|
| 985 | 1;
|
---|