1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Adapted the pic2mpg script to new ffmpeg options; no longer using 'convert' to scale/rotate the pictures

This commit is contained in:
Klaus Schmidinger 2017-10-06 15:12:25 +02:00
parent f2a2c67152
commit ef7018cca4
3 changed files with 23 additions and 10 deletions

View File

@ -100,6 +100,11 @@ VDR Plugin 'pictures' Revision History
- Official release. - Official release.
2015-07.23: Version 2.3.1 2015-07-23: Version 2.3.1
- Added a missing 'const'. - 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.

View File

@ -7,7 +7,7 @@
# #
# See the README file for copyright information and how to reach the author. # 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::Path;
use File::Spec; use File::Spec;
@ -128,7 +128,7 @@ for ($i = 0; $i < 10; $i++) { # dirs might become empty when removing empty subd
for $dir (@Dirs) { for $dir (@Dirs) {
$dir = EscapeMeta($dir); $dir = EscapeMeta($dir);
print "removing $dir\n"; 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 $Exif = ImageInfo($Pict);
my $Orientation = $$Exif{"Orientation"}; my $Orientation = $$Exif{"Orientation"};
my ($Degrees) = $Orientation =~ /Rotate ([0-9]+)/; 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); print "orientation = '$Orientation' -> rotation = $Rotate\n" if ($Detailed);
$Pict = EscapeMeta($Pict); $Pict = EscapeMeta($Pict);
$Mpeg = EscapeMeta($Mpeg); $Mpeg = EscapeMeta($Mpeg);
print "$Pict -> $Mpeg $Rotate\n" if $ListFiles; print "$Pict -> $Mpeg $Rotate\n" if $ListFiles;
my $Cmd = "convert $Pict -background '#000000' $Rotate -resize $Size -gravity center -extent $Extent ppm:- | " 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 "
. "ffmpeg -f image2pipe -vcodec ppm -i pipe:0 -an -vcodec libx264 -vpre baseline -s $Size -qscale 2 -f mpegts -y $Mpeg "
. ($Detailed ? "" : "2>/dev/null"); . ($Detailed ? "" : "2>/dev/null");
!system($Cmd) || die "$Cmd: $!\n"; Exec($Cmd);
$Cmd = "touch -r $Pict $Mpeg"; $Cmd = "touch -r $Pict $Mpeg";
!system($Cmd) || die "$Cmd: $!\n"; Exec($Cmd);
} }
sub EscapeMeta sub EscapeMeta
@ -162,3 +163,10 @@ sub EscapeMeta
$s =~ s/([$META])/\\$1/g; $s =~ s/([$META])/\\$1/g;
return $s; return $s;
} }
sub Exec
{
my $Cmd = shift;
print "==> '$Cmd'\n" if ($Verbose);
!system($Cmd) || die "$Cmd: $!\n";
}

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * 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 <getopt.h> #include <getopt.h>
@ -11,7 +11,7 @@
#include "menu.h" #include "menu.h"
#include "player.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 *DESCRIPTION = trNOOP("A simple picture viewer");
static const char *MAINMENUENTRY = trNOOP("Pictures"); static const char *MAINMENUENTRY = trNOOP("Pictures");