From ef7018cca4211dd57bcdff0e8fcf251bd674356c Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 6 Oct 2017 15:12:25 +0200 Subject: [PATCH] Adapted the pic2mpg script to new ffmpeg options; no longer using 'convert' to scale/rotate the pictures --- PLUGINS/src/pictures/HISTORY | 7 ++++++- PLUGINS/src/pictures/pic2mpg | 22 +++++++++++++++------- PLUGINS/src/pictures/pictures.c | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/PLUGINS/src/pictures/HISTORY b/PLUGINS/src/pictures/HISTORY index 0d009fa1..686a8aa6 100644 --- a/PLUGINS/src/pictures/HISTORY +++ b/PLUGINS/src/pictures/HISTORY @@ -100,6 +100,11 @@ VDR Plugin 'pictures' Revision History - Official release. -2015-07.23: Version 2.3.1 +2015-07-23: Version 2.3.1 - Added a missing 'const'. + +2017-10-06: Version 2.3.2 + +- Adapted the pic2mpg script to new ffmpeg options. +- No longer using 'convert' to scale/rotate the pictures. diff --git a/PLUGINS/src/pictures/pic2mpg b/PLUGINS/src/pictures/pic2mpg index f29ef1e5..1c7d31ba 100755 --- a/PLUGINS/src/pictures/pic2mpg +++ b/PLUGINS/src/pictures/pic2mpg @@ -7,7 +7,7 @@ # # See the README file for copyright information and how to reach the author. # -# $Id: pic2mpg 3.1 2013/05/23 10:00:23 kls Exp $ +# $Id: pic2mpg 4.1 2017/10/06 14:42:18 kls Exp $ use File::Path; use File::Spec; @@ -128,7 +128,7 @@ for ($i = 0; $i < 10; $i++) { # dirs might become empty when removing empty subd for $dir (@Dirs) { $dir = EscapeMeta($dir); print "removing $dir\n"; - !system("rm -rf $dir") || die "$dir: $!\n"; + Exec("rm -rf $dir"); } } @@ -142,17 +142,18 @@ sub ConvertFile my $Exif = ImageInfo($Pict); my $Orientation = $$Exif{"Orientation"}; my ($Degrees) = $Orientation =~ /Rotate ([0-9]+)/; - my $Rotate = $Degrees ? "-rotate $Degrees" : ""; + my $Rotate = ($Degrees == 90) ? "transpose=clock" : ($Degrees == 180) ? "hflip,vflip" : ($Degrees == 270) ? "transpose=cclock" : ""; + $Rotate .= ',' if ($Rotate); + my $Background = '#000000@1'; print "orientation = '$Orientation' -> rotation = $Rotate\n" if ($Detailed); $Pict = EscapeMeta($Pict); $Mpeg = EscapeMeta($Mpeg); print "$Pict -> $Mpeg $Rotate\n" if $ListFiles; - my $Cmd = "convert $Pict -background '#000000' $Rotate -resize $Size -gravity center -extent $Extent ppm:- | " - . "ffmpeg -f image2pipe -vcodec ppm -i pipe:0 -an -vcodec libx264 -vpre baseline -s $Size -qscale 2 -f mpegts -y $Mpeg " + my $Cmd = "ffmpeg -i $Pict -vf '${Rotate}scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:$Background' -c:v libx264 -pix_fmt yuv420p -f mpegts -y $Mpeg " . ($Detailed ? "" : "2>/dev/null"); - !system($Cmd) || die "$Cmd: $!\n"; + Exec($Cmd); $Cmd = "touch -r $Pict $Mpeg"; - !system($Cmd) || die "$Cmd: $!\n"; + Exec($Cmd); } sub EscapeMeta @@ -162,3 +163,10 @@ sub EscapeMeta $s =~ s/([$META])/\\$1/g; return $s; } + +sub Exec +{ + my $Cmd = shift; + print "==> '$Cmd'\n" if ($Verbose); + !system($Cmd) || die "$Cmd: $!\n"; +} diff --git a/PLUGINS/src/pictures/pictures.c b/PLUGINS/src/pictures/pictures.c index cb020e6e..430ebe28 100644 --- a/PLUGINS/src/pictures/pictures.c +++ b/PLUGINS/src/pictures/pictures.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: pictures.c 4.1 2015/07/17 10:14:22 kls Exp $ + * $Id: pictures.c 4.2 2017/10/06 15:10:44 kls Exp $ */ #include @@ -11,7 +11,7 @@ #include "menu.h" #include "player.h" -static const char *VERSION = "2.3.1"; +static const char *VERSION = "2.3.2"; static const char *DESCRIPTION = trNOOP("A simple picture viewer"); static const char *MAINMENUENTRY = trNOOP("Pictures");