/ Forside/ Teknologi / Operativsystemer / MS Windows / Spørgsmål
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
MS Windows
#NavnPoint
Klaudi 75853
o.v.n. 67550
refi 58409
tedd 45557
Manse9933 45149
molokyle 40687
miritdk 38357
briani 27239
BjarneD 26414
10  pallebhan.. 24310
åbning af fil med intet efternavn?
Fra : Jonn87
Vist : 497 gange
14 point
Dato : 15-01-04 22:40

Hvordan åbner jeg en fil der ikke har noget efternavn og er lavet med et perl script???
Fatter nadda :s

 
 
Kommentar
Fra : BjarneD


Dato : 15-01-04 22:42

har du prøvet med notepad?

Kommentar
Fra : h_blunck


Dato : 15-01-04 22:43

Prøv at dobbeltklikke på filen i stifinderen, og vælg Notesblok/Notepad.

Så får du en ide om formatet, når data kommer på skærmen...

--
Med venlig hilsen

Henrik, Slagelse

Kommentar
Fra : h_blunck


Dato : 15-01-04 22:43

Prøv at dobbeltklikke på filen i stifinderen, og vælg Notesblok/Notepad.

Så får du en ide om formatet, når data kommer på skærmen...

--
Med venlig hilsen

Henrik, Slagelse

Kommentar
Fra : BertelBrander


Dato : 15-01-04 22:45

Prøv at åbne den med notepad.
Hvis du kan åbne den med notepad, så prøv at skrive hvad der står i toppen af filen.
Hvis det er et perl-script skal du måske have perl instaleret.

Kommentar
Fra : BjarneD


Dato : 15-01-04 22:46

Jamen er det ikke herligt at være så enige

Kommentar
Fra : molokyle


Dato : 15-01-04 22:48

Gå i DOS. Skriv : edit nada_efternavn

</MOLOKYLE>

Kommentar
Fra : molokyle


Dato : 15-01-04 22:51

Ps. Du skal selvfølgelig angive stien :

I DOS : [sti]edit [sti]nada_efternavn

edit ligger som regel i c:\windows\command

</MOLOKYLE>

Kommentar
Fra : Jonn87


Dato : 15-01-04 22:52

ved at åbne filen i notebook kom dette frem

#!/usr/bin/perl -w

# sub2srt - Convert subtitles from microdvd or subrip ".sub" to subviewer ".srt" format
# (c) 2003 Roland "Robelix" Obermayer <roland@robelix.com>
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.

use strict;
my $version = "0.5.2";

use Getopt::Long;
Getopt::Long::Configure("pass_through","no_ignore_case");
my $help = 0;
my $fps = 25;
my $showvers = 0;
my $debug = 0;
my $quiet = 0;
my $dos = 0;
my $license = 0;
my $ntsc = 0;
GetOptions("help|h", \$help,
    "fps|f=f", \$fps,
    "ntsc|n",    \$ntsc,
    "version|v", \$showvers,
    "debug|d", \$debug,
    "quiet|q", \$quiet,
    "license|l", \$license,
    "dos", \$dos);
   
if ($quiet) { $debug = 0; }

if ($help) { help(); }

if ($showvers) { version(); }

if ($license) { license(); }

if ($ntsc) { $fps = 29.976; }

my $infile = shift || '';
if (!$infile) { help(); }

my $outfile = shift || '';
if (!$outfile) {
   $outfile = $infile;
   $outfile =~ s/\.sub$//i;
   $outfile .= ".srt";
}

if (! -f $infile) {
   print "Input file $infile does not exist.\n";
   exit 0;
}

print "Input-file: $infile\n" if (!$quiet);
print "Output-file: $outfile\n" if (!$quiet);

print "Trying to detect input format...\n" if ($debug);

my $format = detect_format($infile);
if (!$format) {
   print "Could not detect $infile format!\n";
   exit 0;
}

my $le = ($dos) ? "\r\n" : "\n";

print "Converting from $format to srt\n" if ($format ne "srt" && !$quiet);

open INFILE, "$infile" or die "Unable to open $infile for reading\n";
open OUTFILE, ">$outfile" or die "Unable to open $outfile for writing\n";

if ($format eq "subrip") {
   conv_subrip();
}
elsif ($format eq "microdvd") {
   conv_microdvd();
}
elsif ($format eq "srt") {
   print "Input file is already subviewer srt format.\n";
}

sub conv_subrip {
   my $converted = 0;
   my $failed = 0;
   while (my $line1 = <INFILE>) {
      $line1 =~ s/[\n\r]*$//;
      if ($line1 =~ m/^(\d\d:\d\d:\d\d\.\d\d),(\d\d:\d\d:\d\d\.\d\d)$/) {
         my $starttime = $1;
         my $endtime = $2;
         $starttime =~ s/\./,/;
         $endtime =~ s/\./,/;
         $starttime .= "0";
         $endtime .= "0";
         my $text = <INFILE>;
         $text =~ s/[\n\r]*$//;
         my $empty = <INFILE>;
         $converted++;
      
         print " Subtitle #$converted: start: $starttime, end: $endtime, Text: $text\n" if ($debug);
         
         # convert line-ends
         $text =~ s/\[br\]/$le/g;
         
         write_srt($converted, $starttime, $endtime, $text);
      
      } else {
         if (!$converted) {
            print " Header line: $line1 ignored\n" if ($debug);
         } else {
            $failed++;
            print " failed to convert: $line1\n" if ($debug);
         }
      }
   }
   print "$converted subtitles written\n" if (!$quiet);
   print "$failed lines failed\n" if (!$quiet);
}

close INFILE;
close OUTFILE;


sub conv_microdvd {
   my $converted = 0;
   my $failed = 0;
   while (my $line = <INFILE>) {
      $line =~ s/[\n\r]*$//;
      if ( $line =~ m/^\{(\d+)\}\{(\d+)\}(.+)$/ ) {
         my $startframe = $1;
         my $endframe = $2;
         my $text = $3;
         $converted++;
         my $starttime = frames_2_time($startframe);
         my $endtime = frames_2_time($endframe);
                  
         print " Subtitle #$converted: start: $starttime, end: $endtime, Text: $text\n" if ($debug);
         
         # convert line-ends
         $text =~ s/\|/$le/g;
         
         write_srt($converted, $starttime, $endtime, $text);
         
      } else {
         $failed++;
         print " failed to convert: $line\n" if ($debug);
      }
   }
   print "$converted subtitles written\n" if (!$quiet);
   print "$failed lines failed\n" if (!$quiet);
}

sub write_srt {
   my $nr = shift;
   my $start = shift;
   my $end = shift;
   my $text = shift;
   
   print OUTFILE "$nr$le";
   print OUTFILE "$start --> $end$le";
   print OUTFILE "$text$le";
   print OUTFILE "$le";
}

sub frames_2_time {
   # convert frames to time
   # used for microdvd format
   my $frames = shift;
   my $seconds = $frames / $fps;
   my $ms = ($seconds - int($seconds)) * 1000;
   if ( ($ms - int($ms)) >= 0.5 ) {
      # round up
      $ms = $ms + 1;
   }
   $ms = sprintf("%03u", $ms);
   $seconds = int($seconds);
   my $s = $seconds % 60;
   my $min = int($seconds / 60);
   my $m = $min % 60;
   my $h = int($min / 60);
   $s = sprintf("%02u", $s);
   $m = sprintf("%02u", $m);
   $h = sprintf("%02u", $h);
   print " $frames frames -> $seconds sec -> $h:$m:$s,$ms\n" if ($debug);
   
   return "$h:$m:$s,$ms";
}

sub detect_format {
   my $file = shift;
   open INFILE, "$file" or die "Failed to open $file.\n";
   my $detected = "";
   my $i = 0;
   while (my $line = <INFILE>) {
      $line =~ s/[\n\r]*$//;
      print " Trying line $i: $line \n" if $debug;
      
      # microdvd format
      # looks like:
      # {startframe}{endframe}Text
      
      if ( $line =~ m/^\{\d+\}\{\d+\}.+$/ ) {
         print " seems to be microdvd format\n" if ($debug);
         my $line2 = <INFILE>;
         $line2 =~ s/[\n\r]*$//;
         print " checking next line: $line2\n" if ($debug);
         if ($line2 =~ m/^\{\d+\}\{\d+\}.+$/) {
            print "microdvd format detected!\n" if ($debug);
            $detected = "microdvd";
         }
      }
      
      # trying subrip format
      # 3 lines:
      # hh:mm:ss.ms,hh:mm:ss.ms
      # test
      # (empty line)
      
      if ($line =~ m/^\d\d:\d\d:\d\d\.\d\d,\d\d:\d\d:\d\d\.\d\d$/) {
         print " seems to be subrip format\n" if ($debug);
         my $line2 = <INFILE>;
         $line2 =~ s/[\n\r]*$//;
         my $line3 = <INFILE>;
         $line3 =~ s/[\n\r]*$//;
         my $line4 = <INFILE>;
         $line4 =~ s/[\n\r]*$//;
         print " checking the next lines:\n $line2\n $line3\n $line4\n" if ($debug);
         if ($line2 =~ m/^.+$/ && $line3 =~ m/^$/ && $line4 =~ m/^\d\d:\d\d:\d\d\.\d\d,\d\d:\d\d:\d\d\.\d\d$/) {
            print "subrip format detected!\n" if ($debug);
            $detected = "subrip";
         }
      }
      
      # trying subviewer .srt format
      
      if ($line =~ m/^\d\d:\d\d:\d\d\,\d\d\d\s-->\s\d\d:\d\d:\d\d\,\d\d\d$/) {
         print "subviewer .srt format detected!\n" if ($debug);
         $detected = "srt";
      }

      $i++;
      last if ($detected or $i > 50);
   }
   close INFILE;
   return $detected;
}

sub help {
print <<__HELP__;

sub2srt [options] inputfile.sub [outputfile.srt]

Convert subrip and microdvd ".sub" subtitle files to subviewer ".srt" format
(the format accepted by ogmmerge for multiplexing into ogm files)


Options:
-h --help Display this message.
-v --version   Display Program version and exit.
-l --license   Display License information and exit.

-f=n --fps=n Fps to be used if input file is frame-based microdvd-format
         Default: 25 fps. Ignored if input format is time-based.
         
-n --ntsc      Sets the framerate to 29.976 fps. Overrides --fps.
         
--dos      Create output file with DOS line end (cr+lf)
         Default: unix line end (lf)
         
-d --debug      Print debug information
-q --quiet      No output


inputfile.sub
Input file
Both types usally have the ending .sub, the format is autodetected.


[outputfile.srt]
Output file
Default: inputfile.srt

__HELP__
exit 2;
}

sub license {
print <<__VERSION__;

sub2srt $version - Convert subtitles from .sub to .srt format
(c) 2003 Roland "Robelix" Obermayer <roland\@robelix.com>
Project Homepage: http://www.robelix.com/sub2srt/
Please report problems, ideas, patches... to sub2srt\@robelix.com


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., 675 Mass Ave, Cambridge, MA 02139, USA.

__VERSION__
exit 2;
}

sub version {
   print "sub2srt $version\n";
   exit 2;
}



:s

Kommentar
Fra : buch78


Dato : 15-01-04 22:56

undskyld men det ligner en driver til UNIX/LINUX

Kommentar
Fra : BertelBrander


Dato : 15-01-04 22:56

Det er et perl script, instaler perl:

http://www.perl.org/

Kommentar
Fra : molokyle


Dato : 15-01-04 22:57

..og ??? Så fik du den vel åbnet

</MOLOKYLE>

Kommentar
Fra : BjarneD


Dato : 15-01-04 23:03

hvad vil du bruge den til?


Kommentar
Fra : h_blunck


Dato : 15-01-04 23:05

Det bedste sted må være at lede på Project Homepage: http://www.robelix.com/sub2srt/ som der står i scriptet...

--
Med venlig hilsen

Henrik, Slagelse

Kommentar
Fra : Jonn87


Dato : 15-01-04 23:08

Er der ikke bare en der har et link hvor jeg kan downloade Sub2srt så behøver jeg ikke alt det her lort!

Kommentar
Fra : Jonn87


Dato : 15-01-04 23:09

og ikke i de forpulede gz format og hvad de nu hedder... bare i almindelig exe, zip eller rar format!

Kommentar
Fra : Jonn87


Dato : 15-01-04 23:09

Skal sove... kigger her ind imorgen!!

Kommentar
Fra : BjarneD


Dato : 15-01-04 23:10

Du kan ikke bare bruge perl uden at have noget at køre det med

Kommentar
Fra : molokyle


Dato : 15-01-04 23:22

Perl er serverside programmering ligesom ASP, PHP, *.shtml og hva' det nu hedder, i modsætning til Java, javascript, VBscript osv.. der bliver kørt hos klienten (på brugerens maskine). That's all.

\/MOLOKYLE>

Kommentar
Fra : Jonn87


Dato : 16-01-04 14:24

Er der ikke bare en der har et link hvor jeg kan downloade Sub2srt

Accepteret svar
Fra : molokyle

Modtaget 14 point
Dato : 16-01-04 14:43

Her kan du downloade (nederst) et program; Zipzag, der i 30 dage kan åbne gz filen :

http://www.zipzag.com/features.html

</MOLOKYLE>



Godkendelse af svar
Fra : Jonn87


Dato : 03-03-04 09:27

Tak for svaret molokyle.
                        

Du har følgende muligheder
Eftersom du ikke er logget ind i systemet, kan du ikke skrive et indlæg til dette spørgsmål.

Hvis du ikke allerede er registreret, kan du gratis blive medlem, ved at trykke på "Bliv medlem" ude i menuen.
Søg
Reklame
Statistik
Spørgsmål : 177429
Tips : 31962
Nyheder : 719565
Indlæg : 6407948
Brugere : 218878

Månedens bedste
Årets bedste
Sidste års bedste