blib/lib/Video/DVDRip/GUI/Project/Transcode.pm untested

filter: Statementstmt 0.0% 0 / 235 Branchbran 0.0% 0 / 72 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 0.0% 0 / 27 Podpod 0.0% 0 / 20 totaltotal 0.0% 0 / 398 CC 37 SCAR 37.2
CC
37
Cov
0%
add_to_cluster
156.0
build_audio_codec_settings
42.0
build_general_options_factory
30.0
CRAP 41.4
1 # $Id: Transcode.pm 2344 2007-08-09 21:37:41Z joern $
2  
3 #-----------------------------------------------------------------------
4 # Copyright (C) 2001-2006 Jörn Reder <joern AT zyn.de>.
5 # All Rights Reserved. See file COPYRIGHT for details.
6 #
7 # This module is part of Video::DVDRip, which is free software; you can
8 # redistribute it and/or modify it under the same terms as Perl itself.
9 #-----------------------------------------------------------------------
10  
11 package Video::DVDRip::GUI::Project::Transcode;
12  
13 use base qw( Video::DVDRip::GUI::Base );
14  
15 use Locale::TextDomain qw (video.dvdrip);
16  
17 use Carp;
18 use strict;
19  
20 sub new {
21 my $class = shift;
22  
23 my $self = $class->SUPER::new(@_);
24  
25 $self->get_context->set_object( "transcode" => $self );
26  
27 return $self;
28 }
29  
30 sub build_factory {
31 my $self = shift;
32  
33 my $context = $self->get_context;
34  
35 return Gtk2::Ex::FormFactory::VBox->new(
36 $self->get_optimum_screen_size_options("page"),
37 object => "title",
38 title => '[gtk-convert]'.__ "Transcode",
39 active_cond => sub {
40 $self->selected_title
41 && $self->project
42 && $self->project->created;
43 },
44 active_depends => "project.created",
45 no_frame => 1,
46 content => [
47 Video::DVDRip::GUI::Main->build_selected_title_factory,
48 Gtk2::Ex::FormFactory::Table->new(
49 expand => 1,
50 layout => "
51 +>>>>>>>>>>>>>>>>>>>>>+>>>>>>>>>>>>>>>>>>>>>+
52 | Video & Bitrate ^ Audio & General |
53 +---------------------+---------------------|
54 ^ Calculated Storage | Operate |
55 +---------------------+---------------------+
56 ",
57 content => [
58 Gtk2::Ex::FormFactory::VBox->new(
59 content => [
60 $self->build_container_factory,
61 $self->build_video_factory,
62 $self->build_video_bitrate_factory,
63 ],
64 ),
65 Gtk2::Ex::FormFactory::VBox->new(
66 content => [
67 $self->build_audio_factory,
68 $self->build_general_options_factory,
69 ],
70 ),
71 $self->build_calc_storage_factory,
72 $self->build_operate_factory,
73 ],
74 ),
75 ],
76 );
77 }
78  
79 sub build_container_factory {
80 my $self = shift;
81  
82 return Gtk2::Ex::FormFactory::Form->new(
83 title => __ "Container options",
84 content => [
85 Gtk2::Ex::FormFactory::Popup->new(
86 label => __ "Select container",
87 label_group => "video_labels",
88 attr => "title.tc_container",
89 expand_h => 0,
90 width => 70,
91 ),
92 ],
93 );
94 }
95  
96 sub build_video_factory {
97 my $self = shift;
98  
99 return Gtk2::Ex::FormFactory::Table->new(
100 title => __ "Video options",
101 properties => { column_spacing => 5, },
102 layout => "
103 +>------------+[>--------------+[>--------------------+
104 | Codec Label | VC Popup | Cfg Button |
105 +-------------+[---------------+--------------+-------+
106 | ffmpeg Label| ffmpeg Entry | KFI Label | KFI |
107 +-------------+[---------------+--------------+-------+
108 | FRate Label | Frame-Rate | |
109 +-------------+[---------------+----------------------+
110 | 2pass Label | 2pass Yes/No | Reuse log |
111 +-------------+----------------+----------------------+
112 | Deint Label | Deinterlacing |
113 +-------------+---------------------------------------+
114 | Filt Label | Filters Button |
115 +-------------+---------------------------------------+
116 ",
117 content => [
118  
119 #-- 1st row
120 Gtk2::Ex::FormFactory::Label->new(
121 label => __ "Video codec",
122 label_group => "video_labels",
123 ),
124 Gtk2::Ex::FormFactory::Combo->new(
125 attr => "title.tc_video_codec",
126 width => 80,
127 tip => __ "Choose a video codec here. If you don't "
128 . "find the codec you want in the list, just "
129 . "enter its transcode name by hand",
130 ),
131 Gtk2::Ex::FormFactory::Button->new(
132 object => "title",
133 label => __ "Configure...",
134 stock => "gtk-preferences",
135 tip => __ "The xvid4 video codec may be configured in detail "
136 . "if you have the xvid4conf utility installed",
137 clicked_hook => sub {
138 $self->open_video_configure_window;
139 },
140 active_cond => sub {
141 $_[0] ? $_[0]->tc_video_codec =~ /^(xvid|xvid4)$/ : 0;
142 },
143 active_depends => ["title.tc_video_codec"],
144 ),
145  
146 #-- 2nd row
147 Gtk2::Ex::FormFactory::Label->new(
148 label => __ "ffmpeg/af6 codec",
149 for => "sibling(1)"
150 ),
151 Gtk2::Ex::FormFactory::Combo->new(
152 attr => "title.tc_video_af6_codec",
153 width => 80,
154 tip => __ "Some transcode video export modules support "
155 . "multiple video codecs, e.g. the ffmpeg module. "
156 . "Enter the name of the video codec the module "
157 . "should use here"
158 ),
159 Gtk2::Ex::FormFactory::Label->new( label => __ "Keyframes", ),
160 Gtk2::Ex::FormFactory::Combo->new(
161 attr => "title.tc_keyframe_interval",
162 width => 50,
163 tip => __ "This setting controls the number of frames "
164 . "after which a keyframe should be inserted "
165 . "into the video stream. The lower this value "
166 . "the better the quality, but filesize may "
167 . "increase as well",
168 rules => ["positive-integer"],
169 ),
170  
171 #-- 3rd row
172 Gtk2::Ex::FormFactory::Label->new(
173 label => __ "Video framerate",
174 ),
175 Gtk2::Ex::FormFactory::Combo->new(
176 attr => "title.tc_video_framerate",
177 width => 80,
178 tip => __ "This is the video framerate of this movie. "
179 . "Only change this if transcode detected the "
180 . "framerate wrong, which may happen sometimes. "
181 . "If you want true framerate conversion check "
182 . "out the Filters dialog, which provides some "
183 . "video filters for this task",
184 rules => ["positive-float"],
185 ),
186  
187 #-- 4th row
188 Gtk2::Ex::FormFactory::Label->new(
189 label => __ "2-pass encoding",
190 ),
191 Gtk2::Ex::FormFactory::YesNo->new(
192 attr => "title.tc_multipass",
193 tip => __ "2-pass encoding increases video quality and "
194 . "video bitrate accuracy significantly. But the "
195 . "whole transcoding needs nearly twice the time. "
196 . "It's strongly recommended to use 2-pass encoding "
197 . "whenever possible.",
198 true_label => __"Yes",
199 false_label => __"No",
200 ),
201 Gtk2::Ex::FormFactory::CheckButton->new(
202 label => __ "Reuse log",
203 attr => "title.tc_multipass_reuse_log",
204 tip => __ "During the first pass of a 2-pass transcoding "
205 . "a logfile with statistic information about the "
206 . "movie is written. If you didn't change any "
207 . "parameters affecting the video you may reuse "
208 . "this logfile for subsequent transcodings "
209 . "by activating this button. dvd::rip "
210 . "will skip the first pass saving much time."
211 ),
212  
213 #-- 5th row
214 Gtk2::Ex::FormFactory::Label->new(
215 label => __ "Deinterlace mode",
216 ),
217 Gtk2::Ex::FormFactory::Popup->new(
218 attr => "title.tc_deinterlace",
219 expand_h => 0,
220 width => 160,
221 tip => __ "Choose a deinterlacer algorithm here if the "
222 . "movie is interlaced, otherwise the transcoded "
223 . "movie is likely to have many artefacts. The "
224 . "'Smart deinterlacing' setting is recommended."
225 ),
226  
227 #-- 5th row
228 Gtk2::Ex::FormFactory::Label->new( label => __ "Filters", ),
229 Gtk2::Ex::FormFactory::Button->new(
230 object => "title",
231 label => __ "Configure filters & preview...",
232 tip => __ "This opens a dialog which gives you access "
233 . "all filters transcode supports.",
234 clicked_hook => sub {
235 $self->open_filters_window;
236 },
237 ),
238  
239 ],
240 );
241 }
242  
243 sub build_audio_factory {
244 my $self = shift;
245  
246 return Gtk2::Ex::FormFactory::Table->new(
247 title => __ "Audio options",
248 object => "audio_track",
249 layout => "
250 +-----------+>------------+-------+
251 | DVD Track | Popup | Multi |
252 +---------------------------------+
253 | Settings Notebook |
254 | |
255 +---------------------------------+
256 ",
257 content => [
258 Gtk2::Ex::FormFactory::Label->new( label => __ "Select track", ),
259 Gtk2::Ex::FormFactory::Popup->new(
260 attr => "title.audio_channel",
261 width => 120
262 ),
263 Gtk2::Ex::FormFactory::Button->new(
264 label => __ "Multi...",
265 stock => "dvdrip-audio-matrix",
266 clicked_hook => sub {
267 $self->open_multi_audio_window;
268 },
269 tip => __ "Manage multiple audio tracks"
270 ),
271 Gtk2::Ex::FormFactory::Notebook->new(
272 attr => "audio_track.tc_audio_codec",
273 changed_hook_after => sub {
274 my $audio_track = $self->get_context->get_object("audio_track");
275 return if ! $audio_track;
276 if ( $audio_track->tc_audio_codec =~ /^(?:ac3|pcm)$/ ) {
277 $self->detect_audio_bitrate
278 unless $audio_track->bitrate;
279 }
280 },
281 content => [
282 $self->build_audio_codec_settings( type => "mp3" ),
283 $self->build_audio_codec_settings( type => "mp2" ),
284 $self->build_audio_codec_settings( type => "vorbis" ),
285 $self->build_audio_codec_settings( type => "ac3" ),
286 $self->build_audio_codec_settings( type => "pcm" ),
287 ],
288 ),
289 ],
290 );
291 }
292  
293 sub build_audio_codec_settings {
294 my $self = shift;
295 my %par = @_;
296 my ($type) = @par{'type'};
297  
298 my ( $title, @additional_widgets );
299  
300 my $bitrate_entry_class = "Gtk2::Ex::FormFactory::Combo";
301 my $samplerate_entry_class = "Gtk2::Ex::FormFactory::Combo";
302 my $bitrate_attr = "tc_${type}_bitrate";
303 my $samplerate_attr = "tc_${type}_samplerate";
304 my $changed_hook;
305  
306 if ( $type eq 'mp3' ) {
307 $title = "MP3";
308 push @additional_widgets,
309 Gtk2::Ex::FormFactory::Popup->new(
310 attr => "audio_track.tc_mp3_quality",
311 label => __ "Quality",
312 ),
313 ;
314 }
315 elsif ( $type eq 'mp2' ) {
316 $title = "MP2";
317 $samplerate_entry_class = "Gtk2::Ex::FormFactory::Entry";
318  
319 }
320 elsif ( $type eq 'vorbis' ) {
321 $title = "Vorbis";
322 push @additional_widgets,
323 Gtk2::Ex::FormFactory::HBox->new(
324 label => __ "Quality",
325 label_for => "tc_vorbis_quality",
326 content => [
327 Gtk2::Ex::FormFactory::Combo->new(
328 name => "tc_vorbis_quality",
329 attr => "audio_track.tc_vorbis_quality",
330 width => 70,
331 rules => ["positive-integer"],
332 ),
333 Gtk2::Ex::FormFactory::CheckButton->new(
334 attr => "audio_track.tc_vorbis_quality_enable",
335 label => __ "Use quality mode",
336 ),
337 ],
338 ),
339 ;
340 }
341 else {
342 my $codec = $type eq 'ac3' ? "AC3" : "PCM";
343 my $bitrate_attr_method = $bitrate_attr;
344 $title = $codec;
345 push @additional_widgets,
346 Gtk2::Ex::FormFactory::Label->new(
347 label => __x(
348 "{ac3_or_pcm} sound is passed through. Bit- and\n"
349 . "samplerate are detected from source,\n"
350 . "so you can't change them here.",
351 ac3_or_pcm => $codec
352 ),
353 );
354 $bitrate_entry_class = "Gtk2::Ex::FormFactory::Entry";
355 $samplerate_entry_class = "Gtk2::Ex::FormFactory::Entry";
356 $bitrate_attr = "bitrate";
357 $samplerate_attr = "sample_rate";
358 }
359  
360 if ( $type ne 'ac3' and $type ne 'pcm' ) {
361 push @additional_widgets, (
362 Gtk2::Ex::FormFactory::Popup->new(
363 attr => "audio_track.tc_audio_filter",
364 label => __ "Filter",
365 ),
366 Gtk2::Ex::FormFactory::HBox->new(
367 label => __ "Volume rescale",
368 content => [
369 Gtk2::Ex::FormFactory::Entry->new(
370 attr => "audio_track.tc_volume_rescale",
371 width => 70,
372 rules => [ "positive-float", "or-empty" ],
373 ),
374 Gtk2::Ex::FormFactory::Button->new(
375 label => __ "Scan value",
376 stock => "dvdrip-scan-volume",
377 clicked_hook => sub {
378 $self->scan_rescale_volume;
379 },
380 active_cond => sub { !$self->progress_is_active },
381 active_depends => "progress.is_active",
382 ),
383 ],
384 ),
385 ),
386 ;
387 }
388  
389 return Gtk2::Ex::FormFactory::Form->new(
390 attr => "audio_track.audio_codec_${type}_form",
391 inactive => "invisible",
392 title => $title,
393 content => [
394 Gtk2::Ex::FormFactory::HBox->new(
395 label => __ "Bit-/Samplerate",
396 content => [
397 $bitrate_entry_class->new(
398 name => "bit_samplerate_$type",
399 attr => "audio_track.$bitrate_attr",
400 width => 70,
401 rules => ["positive-integer"],
402 ),
403 Gtk2::Ex::FormFactory::Label->new(
404 label => __ "kbit/s",
405 for => "bit_samplerate_$type",
406 ),
407 $samplerate_entry_class->new(
408 name => $type . $samplerate_attr,
409 attr => "audio_track.$samplerate_attr",
410 width => 70,
411 rules => ["positive-integer"],
412 ),
413 Gtk2::Ex::FormFactory::Label->new(
414 label => __ "hz",
415 for => $type . $samplerate_attr,
416 ),
417 ],
418 ),
419 @additional_widgets,
420 ],
421 );
422 }
423  
424 sub build_video_bitrate_factory {
425 my $self = shift;
426  
427 my $context = $self->get_context;
428  
429 return Gtk2::Ex::FormFactory::Notebook->new(
430 attr => "title.tc_video_bitrate_mode",
431 title => __ "Video bitrate calculation",
432 expand => 1,
433 active_cond => sub { $_[0] ? $_[0]->tc_video_codec ne 'VCD' : 1 },
434 active_depends => "title.tc_video_codec",
435 content => [
436 Gtk2::Ex::FormFactory::Form->new(
437 title => __ "By target size",
438 content => [
439 Gtk2::Ex::FormFactory::HBox->new(
440 label => __ "Target media",
441 label_group => "vbr_calc_group",
442 content => [
443 Gtk2::Ex::FormFactory::Popup->new(
444 attr => "title.tc_disc_cnt",
445 width => 70,
446 tip => __
447 "Choose the desired number of discs here. "
448 . "dvd::rip computes the target size from it "
449 . "and optionally splits the result file accordingly.",
450 ),
451 Gtk2::Ex::FormFactory::Label->new(
452 label => "x",
453 ),
454 Gtk2::Ex::FormFactory::Combo->new(
455 width => 60,
456 attr => "title.tc_disc_size",
457 tip => __
458 "Select the size of your media here (several "
459 . "CD and DVD form factors). The unit is a true "
460 . "megabyte (1024KB). You may enter an arbitrary "
461 . "value if the preset don't fit your needs.",
462 rules => [ "positive-integer", "not-zero" ],
463 ),
464 Gtk2::Ex::FormFactory::Label->new(
465 label => __ "MB",
466 ),
467 ],
468 ),
469 Gtk2::Ex::FormFactory::HBox->new(
470 label => __ "Target size",
471 label_group => "vbr_calc_group",
472 content => [
473 Gtk2::Ex::FormFactory::Entry->new(
474 attr => "title.tc_target_size",
475 width => 50,
476 tip => __
477 "This entry is computed based on the settings above, "
478 . "but you may enter an arbitrary value as well.",
479 rules => [ "positive-integer", "not-zero" ],
480 ),
481 Gtk2::Ex::FormFactory::Label->new(
482 label => __ "MB",
483 ),
484 Gtk2::Ex::FormFactory::CheckButton->new(
485 attr => "title.tc_video_bitrate_range",
486 label => __ "Consider frame range",
487 tip => __
488 "If you specified a frame range in the 'General options' "
489 . "section activate this checkbutton if the video bitrate "
490 . "calculation should be based on this frame range, and not on "
491 . "the full title length. You need this if you entered the frame "
492 . "range not just for testing purposes but also for the final "
493 . "transcoding, e.g. for cutting off credits."
494 ),
495 ],
496 ),
497 ],
498 ),
499 Gtk2::Ex::FormFactory::Form->new(
500 title => __ "By quality",
501 content => [
502 Gtk2::Ex::FormFactory::Combo->new(
503 attr => "title.tc_video_bpp_manual",
504 label => __ "BPP value",
505 label_group => "vbr_calc_group",
506 width => 80,
507 expand_h => 0,
508 tip => __
509 "BPP stands for Bits Per Pixel and is a measure for "
510 . "the video quality. Values around 0.25 give fair results "
511 . "(VHS quality), 0.4-0.5 very good quality near DVD.",
512 rules => [ "positive-float", "not-zero" ],
513 ),
514 ],
515 ),
516 Gtk2::Ex::FormFactory::Form->new(
517 title => __ "Manually",
518 content => [
519 Gtk2::Ex::FormFactory::HBox->new(
520 label => __ "Video bitrate",
521 label_group => "vbr_calc_group",
522 content => [
523 Gtk2::Ex::FormFactory::Entry->new(
524 attr => "title.tc_video_bitrate_manual",
525 width => 60,
526 expand_h => 0,
527 tip => __
528 "If you don't want a calculated video bitrate "
529 . "just enter an arbitrary value here.",
530 rules => [ "positive-integer", "not-zero" ],
531 ),
532 Gtk2::Ex::FormFactory::Label->new(
533 label => __ "kbit/s",
534 ),
535 ],
536 ),
537 ],
538 ),
539 ],
540 );
541 }
542  
543 sub build_general_options_factory {
544 my $self = shift;
545  
546 my $context = $self->get_context;
547  
548 return Gtk2::Ex::FormFactory::Form->new(
549 title => __ "General options",
550 expand => 1,
551 content => [
552 Gtk2::Ex::FormFactory::HBox->new(
553 label => __ "Frame range",
554 content => [
555 Gtk2::Ex::FormFactory::Entry->new(
556 attr => "title.tc_start_frame",
557 width => 60,
558 rules => [
559 "positive-integer",
560 "or-empty",
561 sub {
562 my ($start) = @_;
563 my $title = $self->selected_title;
564 my $end = $title->tc_end_frame;
565 return __x( "Movie has only {number} frames",
566 number => $title->frames )
567 if $start > $title->frames;
568 $end ne ''
569 && $start >= $end
570 ? __
571 "Start frame number must be smaller than end frame number"
572 : "";
573 },
574 ],
575 ),
576 Gtk2::Ex::FormFactory::Label->new( label => " - ", ),
577 Gtk2::Ex::FormFactory::Entry->new(
578 attr => "title.tc_end_frame",
579 width => 60,
580 rules => [
581 "positive-integer",
582 "or-empty",
583 sub {
584 my ($end) = @_;
585 my $title = $self->selected_title;
586 my $start = $title->tc_start_frame;
587 return __x( "Movie has only {number} frames",
588 number => $title->frames )
589 if $end > $title->frames;
590 $start ne ''
591 && $start >= $end
592 ? __
593 "End frame number must be greated than start frame number"
594 : "";
595 },
596 ],
597 ),
598 ],
599 ),
600 Gtk2::Ex::FormFactory::Entry->new(
601 attr => "title.tc_options",
602 label => __ "transcode options",
603 width => 20,
604 ),
605 Gtk2::Ex::FormFactory::Combo->new(
606 attr => "title.tc_nice",
607 label => __ "Process nice level",
608 width => 60,
609 expand_h => 0,
610 rules => [ "integer", "or-empty" ],
611 ),
612 Gtk2::Ex::FormFactory::YesNo->new(
613 attr => "title.tc_preview",
614 label => __ "Preview window",
615 true_label => __"Yes",
616 false_label => __"No",
617 ),
618 Gtk2::Ex::FormFactory::YesNo->new(
619 attr => "title.tc_psu_core",
620 label => __ "Use PSU core",
621 true_label => __"Yes",
622 false_label => __"No",
623 ),
624 Gtk2::Ex::FormFactory::HBox->new(
625 label => __ "Execute afterwards",
626 content => [
627 Gtk2::Ex::FormFactory::Entry->new(
628 attr => "title.tc_execute_afterwards",
629 expand => 1,
630 width => 20,
631 ),
632 Gtk2::Ex::FormFactory::CheckButton->new(
633 attr => "title.tc_exit_afterwards",
634 label => __ "and exit",
635 ),
636 ],
637 ),
638 ],
639 );
640 }
641  
642 sub build_operate_factory {
643 my $self = shift;
644  
645 return Gtk2::Ex::FormFactory::VBox->new(
646 title => __ "Operate",
647 content => [
648 Gtk2::Ex::FormFactory::HBox->new(
649 content => [
650 Gtk2::Ex::FormFactory::Button->new(
651 label => __ "Transcode",
652 stock => "gtk-convert",
653 widget_group => "operate_buttons",
654 expand => 1,
655 clicked_hook => sub {
656 $self->transcode;
657 },
658 active_cond => sub { !$self->progress_is_active },
659 active_depends => "progress.is_active",
660 ),
661 Gtk2::Ex::FormFactory::Button->new(
662 label => __ "View",
663 stock => "gtk-media-play",
664 widget_group => "operate_buttons",
665 expand => 1,
666 clicked_hook => sub {
667 $self->view_avi,;
668 },
669 active_cond => sub { !$self->progress_is_active },
670 active_depends => "progress.is_active",
671 ),
672 Gtk2::Ex::FormFactory::Button->new(
673 label => __ "Add to cluster",
674 stock => "gtk-network",
675 widget_group => "operate_buttons",
676 expand => 1,
677 clicked_hook => sub {
678 $self->add_to_cluster;
679 },
680 active_cond => sub {
681 my $title = $self->selected_title;
682 return 0 if not $title;
683 return $title->tc_container ne 'vcd';
684 },
685 active_depends => "title.tc_container",
686 ),
687 ],
688 ),
689 Gtk2::Ex::FormFactory::CheckButton->new(
690 attr => "title.tc_split",
691 label => __ "Split files on transcoding",
692 ),
693  
694 ],
695 );
696 }
697  
698 sub build_calc_storage_factory {
699 my $self = shift;
700  
701 return Gtk2::Ex::FormFactory::Table->new(
702 title => __ "Calculated storage",
703 layout => "
704 +>---------------+>--------]+>--+>---------------+>---------]+-----+
705 | V-Rate | Value | X | Video Size | Value | MB |
706 +----------------+---------]+---+----------------+----------]+-----+
707 | BPP | Value | | Audio Size | Value | MB |
708 +----------------+----------+---+----------------+----------]+-----+
709 | | | Other Size | Value | MB |
710 +[---------------+----------+---+----------------+-----------+-----+
711 | | | Separator |
712 | +---+----------------+----------]+-----+
713 _ Details | | Total Size | Value | MB |
714 +----------------+----------+---+----------------+-----------+-----+
715 ",
716 content => [
717  
718 #-- 1st row
719 Gtk2::Ex::FormFactory::Label->new( label => __ "V-Rate:", ),
720 Gtk2::Ex::FormFactory::Label->new(
721 attr => "title.tc_video_bitrate",
722 ),
723 Gtk2::Ex::FormFactory::Label->new( label => " " ),
724 Gtk2::Ex::FormFactory::Label->new( label => __ "Video size:", ),
725 Gtk2::Ex::FormFactory::Label->new(
726 attr => "title.storage_video_size",
727 ),
728 Gtk2::Ex::FormFactory::Label->new( label => __ "MB", ),
729  
730 # Gtk2::Ex::FormFactory::Label->new ( label => " " ),
731  
732 #-- 2nd row
733 Gtk2::Ex::FormFactory::Label->new( label => __ "BPP:", ),
734 Gtk2::Ex::FormFactory::Label->new(
735 attr => "title.tc_video_bpp",
736 ),
737 Gtk2::Ex::FormFactory::Label->new( label => __ "Audio size:", ),
738 Gtk2::Ex::FormFactory::Label->new(
739 attr => "title.storage_audio_size",
740 ),
741 Gtk2::Ex::FormFactory::Label->new( label => __ "MB", ),
742  
743 #-- 3rd row
744 Gtk2::Ex::FormFactory::Label->new( label => __ "Other size:", ),
745 Gtk2::Ex::FormFactory::Label->new(
746 attr => "title.storage_other_size",
747 ),
748 Gtk2::Ex::FormFactory::Label->new( label => __ "MB", ),
749  
750 #-- 4th row
751 Gtk2::Ex::FormFactory::Button->new(
752 label => __ "Details...",
753 stock => "gtk-zoom-in",
754 clicked_hook => sub {
755 $self->open_bitrate_calc_details;
756 },
757 ),
758 Gtk2::Ex::FormFactory::HSeparator->new,
759  
760 #-- 5th row
761 Gtk2::Ex::FormFactory::Label->new(
762 label => "<b>" . __("Total size:") . "</b>",
763 with_markup => 1,
764 ),
765 Gtk2::Ex::FormFactory::Label->new(
766 attr => "title.storage_total_size",
767 bold => 1,
768 ),
769 Gtk2::Ex::FormFactory::Label->new(
770 label => "<b>" . __("MB") . "</b>",
771 with_markup => 1,
772 ),
773 ],
774 );
775 }
776  
777 sub open_bitrate_calc_details {
778 my $self = shift;
779  
780 require Video::DVDRip::GUI::BitrateCalc;
781  
782 my $bc = Video::DVDRip::GUI::BitrateCalc->new(
783 form_factory => $self->get_form_factory );
784  
785 $bc->open_window;
786  
787 1;
788  
789 }
790  
791 sub open_filters_window {
792 my $self = shift;
793  
794 require Video::DVDRip::GUI::Filters;
795  
796 my $filters = Video::DVDRip::GUI::Filters->new(
797 form_factory => $self->get_form_factory );
798  
799 $filters->open_window;
800  
801 1;
802  
803 }
804  
805 sub open_multi_audio_window {
806 my $self = shift;
807  
808 require Video::DVDRip::GUI::MultiAudio;
809  
810 my $maudio = Video::DVDRip::GUI::MultiAudio->new(
811 form_factory => $self->get_form_factory );
812  
813 $maudio->open_window;
814  
815 1;
816 }
817  
818 sub transcode {
819 my $self = shift;
820 my %par = @_;
821 my ($subtitle_test) = @par{'subtitle_test'};
822  
823 return 1 if $self->progress_is_active;
824 my $title = $self->selected_title;
825 return 1 if not $title;
826  
827 my $job_planner = $self->get_context->get_object("job_planner");
828 my $exec_flow_gui = $self->get_context->get_object("exec_flow_gui");
829 my $job = $job_planner->build_transcode_job();
830  
831 $exec_flow_gui->start_job($job);
832  
833 1;
834 }
835  
836 sub view_avi {
837 my $self = shift;
838 my %par = @_;
839 my ($title) = @par{'title'};
840  
841 $title ||= $self->selected_title;
842 return 1 if not $title;
843  
844 my $command = $title->get_view_avi_command(
845 command_tmpl => $self->config('play_file_command'), );
846  
847 system( $command. " &" );
848 }
849  
850 sub scan_rescale_volume {
851 my $self = shift;
852  
853 my $title = $self->selected_title;
854 return 1 if $self->progress_is_active;
855 return 1 if not $title;
856  
857 if ( not $title->is_ripped ) {
858 $self->message_window(
859 message => __ "You first have to rip this title." );
860 return 1;
861 }
862  
863 my $job_planner = $self->get_context->get_object("job_planner");
864 my $exec_flow_gui = $self->get_context->get_object("exec_flow_gui");
865 my $job = $job_planner->build_scan_volume_job($title);
866  
867 $job->get_post_callbacks->add(sub {
868 $self->get_context->update_object_attr_widgets(
869 "audio_track.tc_volume_rescale", );
870 1;
871 });
872  
873 $exec_flow_gui->start_job($job);
874  
875 1;
876 }
877  
878 sub add_to_cluster {
879 my $self = shift;
880  
881 my $title = $self->selected_title;
882 return 1 if not $title;
883  
884 if ( $title->tc_use_chapter_mode ) {
885 $self->message_window(
886 message => __ "Titles in chapter mode are not supported" );
887 return 1;
888 }
889  
890 if ( $title->tc_psu_core ) {
891 $self->message_window(
892 message => __ "PSU core mode currently not supported" );
893 return 1;
894 }
895  
896 if ( $title->project->rip_mode ne 'rip' ) {
897 $self->message_window( message => __
898 "Cluster mode is only supported\nfor ripped DVD's." );
899 return 1;
900 }
901  
902 if ( not $title->is_ripped ) {
903 $self->message_window(
904 message => __ "You first have to rip this title." );
905 return 1;
906 }
907  
908 if ( $title->tc_container eq 'vcd' ) {
909 $self->message_window( message => __
910 "MPEG processing is not supported for cluster mode." );
911 return 1;
912 }
913  
914 if ( not $title->has_target_audio_tracks and $title->is_ogg ) {
915 $self->message_window( message => __
916 "Transcoding without audio in an OGG container isn't ".
917 "supported in cluster mode." );
918 return 1;
919 }
920  
921 if ( $title->tc_start_frame ne ''
922 or $title->tc_end_frame ne '' ) {
923 $self->message_window(
924 message => __ "WARNING: your frame range setting\n"
925 . "is ignored in cluster mode" );
926 }
927  
928 # calculate program stream units, if not already done
929 $title->calc_program_stream_units
930 if not $title->program_stream_units
931 or not @{ $title->program_stream_units };
932  
933 $self->get_context_object("main")->cluster_control;
934  
935 my $cluster_gui = eval { $self->get_context_object('cluster_gui') };
936 return if not $cluster_gui;
937 return if not $cluster_gui->master;
938  
939 $cluster_gui->add_project(
940 project => $self->project,
941 title => $title,
942 );
943  
944 1;
945 }
946  
947 sub create_wav {
948 my $self = shift;
949  
950 my $title = $self->selected_title;
951 return 1 if not $title;
952  
953 my $job_planner = $self->get_context->get_object("job_planner");
954 my $exec_flow_gui = $self->get_context->get_object("exec_flow_gui");
955 my $job = $job_planner->build_create_wav_job($title);
956  
957 $exec_flow_gui->start_job($job);
958  
959 1;
960 }
961  
962 sub detect_audio_bitrate {
963 my $self = shift;
964 my ($codec_attr) = @_;
965  
966 my $title = $self->selected_title;
967 return 1 if not $title;
968  
969 my $job_planner = $self->get_context->get_object("job_planner");
970 my $exec_flow_gui = $self->get_context->get_object("exec_flow_gui");
971 my $job = $job_planner->build_detect_audio_bitrate_job($title, $codec_attr);
972  
973 $exec_flow_gui->start_job($job);
974  
975 1;
976 }
977  
978 sub open_video_configure_window {
979 my $self = shift;
980  
981 my $title = $self->selected_title;
982 return 1 if not $title;
983  
984 my $in_filename = $title->multipass_log_dir . "/xvid4.cfg";
985 my $out_filename = $in_filename;
986  
987 if ( not -f $in_filename ) {
988 system(
989 "xvid4conf '$out_filename' '$ENV{HOME}/.transcode/xvid4.cfg' &");
990 }
991 else {
992 system("xvid4conf '$out_filename' '$in_filename' &");
993 }
994  
995 1;
996 }
997  
998 1;