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