From 45983e98061d2fb8ce781693f41bf663654a2d0c Mon Sep 17 00:00:00 2001 From: sascha Date: Sun, 18 Aug 2024 12:40:10 +0200 Subject: [PATCH] Dateien nach "/" hochladen --- marks2bytepos.pl | 117 +++++++++++++++++++++++++++++++++++++++++++++++ preparevdr.sh | 34 ++++++++++++++ showts.sh | 29 ++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 marks2bytepos.pl create mode 100644 preparevdr.sh create mode 100644 showts.sh diff --git a/marks2bytepos.pl b/marks2bytepos.pl new file mode 100644 index 0000000..ab143ee --- /dev/null +++ b/marks2bytepos.pl @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# +# marks2bytepos.pl: perl script to convert VDR cutting marks (marks.vdr) to byte positions +# +# Copyright (C) 2007 - 2010 Christoph Haubrich +# +# V 1.0 first public release +# V 1.1 added support for ts format +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# +# The author can be reached at christoph.haubrich(AT)web.de +# +# The project's page is at http://firefly.vdr-developer.org/patches +# +# This script is intended to be used for cutting with Project X +# set CollectionPanel.CutMode=0 in the X.ini file or +# select "(0) use bytepos for cuts" in the GUI for the correct cut mode +# +# usage: marks2bytepos.pl /path/to/recording/with/timestamp +# output: byte positions (one per line) are printed on STDOUT +# +# Example: +# marks2bytepos.pl /path/to/recording/with/timestamp >cut.px +# java -jar ProjectX.jar -demux -cut cut.px /path/to/recording/with/timestamp/[0-9]*.vdr +# + +use strict; +use bigint; + + +if (1 != @ARGV) +{ + print "\nmarks2bytepos - convert vdr cutting marks to byte positions\n\n"; + print "Usage: $0 /path/to/recording\n"; + print "byte positions (one per line) are printed on STDOUT\n"; + + exit (1); +} + +my $type = ""; +my $ext = ""; +my $fps = 25; # assume 25 frames/sec + +if ( -e "$ARGV[0]/marks.vdr" && -e "$ARGV[0]/index.vdr") +{ + $type="pes"; + $ext=".vdr"; +} + +if ( -e "$ARGV[0]/marks" && -e "$ARGV[0]/index") +{ + $type="ts"; + + if (defined(open (INFO, "<$ARGV[0]/info"))) + { + $fps=1*substr((grep(/^F /,))[0], 2); + close(INFO); + } +} + +if ($type eq "") { die ("Couldn't find marks or index file in $ARGV[0]") }; + + +open (MARKS, "<$ARGV[0]/marks${ext}") or die ("Couldn't open $ARGV[0]/marks${ext}"); +my @marks=; +close(MARKS); + +open (INDEX, "<$ARGV[0]/index${ext}") or die ("Couldn't open $ARGV[0]/index${ext}"); + +foreach (@marks) +{ + my $buffer; + my $bytepos = 0; + my ($h, $m, $s, $f) = split /[:.]/,$_; + ($f, undef) = split / /, $f; + my $frame = ($h * 3600 + $m * 60 + $s)* $fps + $f-1; + + seek (INDEX, 8*$frame, 'SEEK_SET'); + read (INDEX, $buffer, 8); + + my ($offset, $offset2, $filenumber); + + if ( $type eq "pes" ) + { + ($bytepos, undef, $filenumber, undef) = unpack("LCCS", $buffer); + } + else + { + ($bytepos, $offset2, undef, $filenumber) = unpack("LCCS", $buffer); + $bytepos += 32*$offset2; + } + + for (my $i=1; $i<$filenumber; $i++) + { + $bytepos += (-s sprintf (($type eq "pes") ? "%s/%03d.vdr" : "%s/%05d.ts", $ARGV[0], $i)); + } + + printf("%.0f\n", $bytepos); +}; + +close (INDEX); + +exit (0); diff --git a/preparevdr.sh b/preparevdr.sh new file mode 100644 index 0000000..ba71bf4 --- /dev/null +++ b/preparevdr.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +if [ "$#" -ne 1 ]; then + echo "usage preparevdr.sh [path to vdr recordings]"; + exit 1; +fi + +if [ ! -d "$1" ]; then + echo "vdr recordings directory not valid: $1"; + exit 1; +fi + +echo "vdr recordings directory: $1"; + +echo "changing into vdr recordings directory '$1'"; +cd "$1"; + +echo `pwd` + +FILE_LIST="$1/tompg.lst" +while IFS= read -r LINE +do + echo "processing '$LINE'"; + cd "$LINE"; + for j in *.rec; do + MOVIENAME=$(sed -n -e 's/^T \(.*\)$/\1/p' ${j}/info); + echo "preparing $MOVIENAME" + markad -vG - $j + cd $j; + marks2bytepos.pl ./ > marks.bytepos + cd ..; + done; + cd ..; +done < "$FILE_LIST" diff --git a/showts.sh b/showts.sh new file mode 100644 index 0000000..85a5e51 --- /dev/null +++ b/showts.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ "$#" -ne 1 ]; then + echo "usage ts2mp4.sh [path to vdr recordings]"; + exit 1; +fi + +if [ ! -d $1 ]; then + echo "vdr recordings directory not valid: $1"; + exit 1; +fi + +echo "vdr recordings directory: $1"; + +echo "changing into vdr recordings directory '$1'"; +cd $1; + +echo `pwd` + +for i in %*; do + cd $i; + for j in *.rec; do + cd $j; + MOVIENAME=$(sed -n -e 's/^T \(.*\)$/\1/p' info); + echo "'$MOVIENAME' is ready for transcoding" + cd ..; + done + cd ..; +done