#1 2006-08-12 13:05

willy
Member
Registered: 2006-08-12
Posts: 2

Using the file size in the new filename

Hi guys,

I need to capture somehow the actual file size in a rule so that I can calculate the duration of various mpeg clips (I want to append the duration to the filename). E.g. if a file is, say 250MB, it'll give me, say a "03m30s" duration string, which I then want to append at the end of the filename.

QUESTION: Any suggestions how to get the file size into the ReNamer? (the key problem)

I suppose this is fairly simple to do (built-in Pascal function?), and I'm sorry if I'm wasting your time with stupid questions, but I'm just a newbee here...

And Denis, thanks for the brilliant utility! Much appreciated.

Cheers,
Willy

Offline

#2 2006-08-12 16:16

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Using the file size in the new filename

Hi willy!

There are meta tags such as :File_SizeBytes: :File_SizeKB: :File_SizeMB: that will retrieve a file size of a file, and for some reason I thought it would be enought and people will not need to retrieve a file size from the PascalScript rule. Well, I was wrong wink

I had a free moment, so I've added a function WideFileSize to PascalScript, it wasn't a big deal.
You can download the latest development version from here: ReNamerBeta.zip

Here is an example of how to use that function:

begin
  FileName := IntToStr(WideFileSize(FilePath));
end.

P.S. packing my bags now, with a bit of a hang-over after last night, leaving in about 16 hours, with more drunkenness ahead big_smile

Offline

#3 2006-08-12 17:20

willy
Member
Registered: 2006-08-12
Posts: 2

Re: Using the file size in the new filename

Denis, you're a legend! Thanks a million, and enjoy your ride cool
/w

Offline

#4 2006-08-12 19:30

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Using the file size in the new filename

I wish <crosses fingers> that more software developers were like Denis

Offline

#5 2006-08-13 21:27

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Using the file size in the new filename

ps

Denis, if you want a couple of units to retrieve information about mpg's and avi's like the jpeg metadata you already have
eg timelength, codecs  etc
I can give you a couple (the .avi one's written by me and is freesource, no limitations - the mpeg one is haevily altered by me and as far as I know the origional has no restrictions either)

The mpeg version cannot give the file lenght time, as mpeg has a timecode in it, and this can change in the middle of the filestream (usually due to two mpegs being appended)
Apart from that problem - they are about 500 times faster than other routines I've tried that use the microsoft api's (Actually I only wrote the avi decoder because msoft's api's were so slow)

If you'd like to see an example, there's an exe here ftp://dloneranger.dynu.com/AviInfo.rar - drag any file or folder to the main screen for an exaple of it's speed
It's a bit a confusing at first glance (why is there an ok section and a bad section?) but I wrote it quickly to be able to see what avi's my divx player would play correctly, and anything out of spec shows up in the 'bad' section

But as an example for the speed it decodes at it's ok
(source code available if needed)

---------------------
here's the interface section so you can see what's in it

type

  TAVIInfo = record
    Width, Height,
      FPS1000,                          //Frames per second * 1000: for NTSC, FPS1000 = 29970
    AspectRatio,                        // always 1 for avi
    Streams,                            //Number of Streams (audio and video) - AVI only
    TimeLength,                         // in seconds (approx only it seems)
    AudioChannels,
      AudioFreq,
      AudioCodec: Integer;
    FPS: double;                        //Frames per second in floating point format
    Frames: LongInt;                    //Number of frames - only detected for AVI files
    PiDAR: Single;
    //Pixel Display Aspect Ratio:
    //when displaying the video, the width of a pixel
    //should be its height multiplied by PiDAR
    FourCC: string;
    AudioCC: string;
  end;

  TMPGInfo = record
    Width, Height,
      //resolution of the video; might be different from
//correct display resolution (as NTSC SVCDs have a
//resolution of 480*480 but are displayed with e.g.
//640*480

    FPS1000,
      //Frames per second * 1000: for NTSC, FPS1000 = 29970

    MPEGversion,
      //1 for MPEG-1, 2 for MPEG-2

    AspectRatio,
      //1 = 1:1 square pixels (VGA)
  //2 = 4:3 standard television
  //3 = 16:9 wide screen television
  //4 = 2.21:1 cinema format
    AspectDetail,
      //1 = 1:1 square pixels (VGA)                    0001
  //2 = 4:3 standard television                    0010
  //3 = 16:9 wide screen television (pal)          0011
  //4 = 2.21:1 cinema format                       0100
  //6 = 16:9 wide screen television (ntsc)         0110
  //8 = 4:3 standard television (pal)              1000
  //12 = 4:3 standard television (ntsc)            1100

    AudioChannels,
      AudioFreq,
      AudioBitrate
      : Integer;
    Ac3: boolean;
    FPS: double;
    //Frames per second in floating point format

    PiDAR: Single;
    //Pixel Display Aspect Ratio:
    //when displaying the video, the width of a pixel
    //should be its height multiplied by PiDAR
  end;

function getAVIInfo( FileName: string ): TAVIInfo;
function getMPGInfo( FileName: string ): TMPGInfo;



source at ftp://dloneranger.dynu.com/VidInfo.rar 5K

Last edited by dloneranger (2006-08-13 21:36)

Offline

#6 2006-08-23 15:14

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Using the file size in the new filename

Thanks!!  I will defiantly have a look when I get back! smile

By the way, ReNamer already has few meta tags to read AVI header information.

Offline

Board footer

Powered by FluxBB