@@ -20,14 +20,15 @@ package export::ffmpeg;
2020 use mythtv::recordings;
2121
2222# Load the following extra parameters from the commandline
23- $cli_args {' cutlist|use_cutlist ' } = 1; # Use the myth cutlist
24- $cli_args {' deinterlace :s' } = 1; # Deinterlace video
25- $cli_args {' denoise|noise_reduction:s ' } = 1; # Enable noise reduction
23+ $cli_args {' deinterlace:s ' } = 1; # Deinterlace video
24+ $cli_args {' denoise|noise_reduction :s' } = 1; # Enable noise reduction
25+ $cli_args {' crop ' } = 1; # Crop out broadcast overscan
2626
2727# This superclass defines several object variables:
2828#
29- # use_cutlist
30- # noise_reduction
29+ # path (defined by generic)
30+ # use_cutlist (defined by generic)
31+ # denoise
3132# deinterlace
3233# crop
3334#
@@ -60,10 +61,16 @@ package export::ffmpeg;
6061 $self -> {' deinterlace' } = query_text(' Enable deinterlacing?' ,
6162 ' yesno' ,
6263 $self -> {' deinterlace' } ? ' Yes' : ' No' );
64+
6365 # Crop video to get rid of broadcast padding
64- # $self->{'crop'} = query_text('Crop ',
65- # 'yesno',
66- # $self->{'crop'} ? 'Yes' : 'No');
66+ if ($Args {' crop' }) {
67+ $self -> {' crop' } = 1;
68+ }
69+ else {
70+ $self -> {' crop' } = query_text(' Crop broadcast overscan (2% border)?' ,
71+ ' yesno' ,
72+ $self -> {' crop' } ? ' Yes' : ' No' );
73+ }
6774 }
6875
6976 sub export {
@@ -88,12 +95,16 @@ package export::ffmpeg;
8895
8996 my $videofifo = " /tmp/fifodir_$$ /vidout" ;
9097 my $videotype = ' rawvideo' ;
91-
92- # # Crop?
93- # if (1 || $self->{'crop'}) {
94- # my $cropw = sprintf('%.0f', .02 * $episode->{'finfo'}{'width'});
95- # my $croph = sprintf('%.0f', .02 * $episode->{'finfo'}{'height'});
96- # }
98+ my $crop_w ;
99+ my $crop_h ;
100+
101+ if ($self -> {' crop' }) {
102+ $crop_w = sprintf (' %.0f' , .02 * $episode -> {' finfo' }{' width' });
103+ $crop_h = sprintf (' %.0f' , .02 * $episode -> {' finfo' }{' height' });
104+ # keep crop numbers even
105+ $crop_w -- if ($crop_w > 0 && $crop_w % 2);
106+ $crop_h -- if ($crop_h > 0 && $crop_h % 2);
107+ }
97108
98109 if ($self -> {' audioonly' }) {
99110 $ffmpeg .= " cat /tmp/fifodir_$$ /vidout > /dev/null | " ;
@@ -107,7 +118,9 @@ package export::ffmpeg;
107118 $ffmpeg .= " -i /tmp/fifodir_$$ /vidout -f yuv4mpegpipe -" ;
108119 $ffmpeg .= " 2> /dev/null | " ;
109120 $ffmpeg .= " nice -n $Args {'nice'} yuvdenoise -F -r 16" ;
110- # $ffmpeg .= " -b $cropw,$croph,-$cropw,-$croph" if( $cropw || $croph );
121+ if ($self -> {' crop' }) {
122+ $ffmpeg .= " -b $crop_w ,$crop_h ,-$crop_w ,-$crop_h " ;
123+ }
111124 $ffmpeg .= " 2> /dev/null | " ;
112125 $videofifo = " -" ;
113126 $videotype = " yuv4mpegpipe" ;
@@ -129,6 +142,12 @@ package export::ffmpeg;
129142 if ($self -> {' deinterlace' }) {
130143 $ffmpeg .= " -deinterlace" ;
131144 }
145+
146+ if ($self -> {' crop' }) {
147+
148+ $ffmpeg .= " -croptop $crop_h -cropbottom $crop_h " ;
149+ $ffmpeg .= " -cropleft $crop_w -cropright $crop_w " ;
150+ }
132151 }
133152
134153 # Add any additional settings from the child module
0 commit comments