title
Products            Buy            Support Forum            Professional            About            Codec Central
 

Scripting and error logging

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MusicGeek

    • Mar 2007
    • 6

    Scripting and error logging

    I found that, when I convert files using VB, and signify an errorfile, that the errorfile is created regardless of whether the conversion (from MP3 to MP3, any codec to Lame, any bitrate to 128) succeeds or not.

    Initially, I tried having my app check for the existence of an error log to indicate if the conversion succeeded or not... which, of course, failed, because the file is always created.

    So, I tried making a fake MP3 file - which should, logically, generate an actual error, since it does using the dMC GUI - and yes, the log was created... but there was nothing inside it.

    This is the code I use:

    Code:
    Function Convertit(source, target) As Boolean
        Dim errorFile As String, dMC, fl As File
        Set fso = CreateObject("Scripting.FileSystemObject")
        errorFile = appPath & "converr.txt"
        If fso.FileExists(errorFile) Then fso.DeleteFile (errorFile)
        Set dMC = CreateObject("dMCScripting.Converter")
        dMC.Convert source, target, "mp3 (Lame)", "-b 128 -encoding=""SLOW"" -freq=""44100"" -channels=""joint stereo"" -crc=""1""", errorFile
        Set dMC = Nothing
        If fso.FileExists(errorFile) Then
            Set fl = fso.GetFile(errorFile)
            If fl.Size > 0 Then
                Convertit = False
            Else
                Convertit = True
            End If
            Set fl = nothing
        Else
            Convertit = True
        End If
        Set fso = Nothing
    End Function
    Is there any other way to determine if a conversion succeeded or not, perhaps using return codes? The program is supposed to batch-process any number of music files between 1 and 500, and I'd like to find the most reliable way to verify a conversion... after all, checking for error logs is quite a moot point if said logs do not provide a clue about whether or not a conversion worked.

    Thanks.
  • Spoon
    Administrator
    • Apr 2002
    • 44475

    #2
    Re: Scripting and error logging

    Your code is checking the error file size? if it is 0 bytes there is no error.
    Spoon
    www.dbpoweramp.com

    Comment

    • MusicGeek

      • Mar 2007
      • 6

      #3
      Re: Scripting and error logging

      The thing is that there is also no error when I make sure an error should occur (creating an empty text file, changing the extension to ".mp3", and attempting to convert it).

      When I use the GUI to convert a file like that, I get an actual program error popup. Using scripting, yes, the error log is there... but it's empty even when it shouldn't be. So there appears to be no distinction between a successfull conversion and a failed one, error-log-wise.

      Here's my dilemma: some of the music files we have are corrupted, so dBPowerAmp is unable to convert them, regardless. We have hundreds of files, and I'd like to set them all to the same MP3 standards. The fastest and easiest way is by scripting, because I really don't see myself waiting for the GUI to popup an error message which I have to click away, or manually adding files to the batch converter.

      When using scripting, however, it appears that an error log is always being created - whether things go wrong or not - ... and there is nothing inside the error file... again, whether things go wrong or not. So I have no way of knowing which files weren't converted except for checking all target folders (all our music files are placed inside their own genre folders)...

      ... aaaaaaand I think I just gave myself a workaround, there. :rolleyes:

      Comment

      • LtData
        dBpoweramp Guru

        • May 2004
        • 8288

        #4
        Re: Scripting and error logging

        Start --> Programs --> dBpoweramp Music Converter --> Configuration --> dBpoweramp Configuration
        Click the Codecs tab then click "Advanced Options". Scroll down to the "Decoder Options" section and change the option under mp3 from "Ignore" to "Report as Error". Does this help your problem?

        Comment

        • MusicGeek

          • Mar 2007
          • 6

          #5
          Re: Scripting and error logging

          Unfortunately, no.

          Just for sh*ts and giggles I enabled the debugger, and that actually does contain an error - in a quite unexpected place:

          Code:
            Opening file 'F:\Music\this is a fake.mp3' for read access: Opened
            ->->  [clDecoder::ReadIDTags]
              Reading Tag: APE contained 0 tags:
              Reading Tag: ID3v2 contained 0 tags:
              Reading Tag: ID3v1*** Information: Error reading ID3v1 tag.  [clDecoder::ReadIDTags]
               contained 0 tags:
            <-<-  [clDecoder::ReadIDTags]
            ->->  [clsMAD::Init]
          I mean... this is a completely null and void and utterly fake MP3 file. It's empty, zero bytes. And all the decoder complains about is an ID3V1 tag missing?

          The error file set inside the scripting module called with a simple VBScript for fast testing is still created... and still empty.

          Code:
          Call dMC.Convert("F:\Music\this is a fake.mp3", _
             "F:\Music\this is a fake, 2.mp3", "mp3 (Lame)", "-b=96", _
             "F:\Music\converror.txt")
          When I try to convert an actual music file (same options in the command line, different source file)... an error log gets created... and it's equally empty.

          Did someone forget to program the text output? :p

          As I said in my previous post, I just thought of a workaround: if the attempted conversion breaks - for whatever reason - the target MP3 file never gets created, so all I'll have to do is verify that the target exists before moving on to the next one in the list... but it kind of defeats the purpose of having error logging available in a scripting module which is created to run silently and reliably.

          Comment

          • MusicGeek

            • Mar 2007
            • 6

            #6
            Re: Scripting and error logging: A little sidenote

            What, exactly, do the properties WasConvError and GetConversionError do, or what can I do with them?

            I tried playing around a bit, and the WasConvError appears to always return 0, and whenever I try to set or read the GetConversionError property, I get squawked at, when the compiler says "Expected Function or variable"

            Comment

            • Spoon
              Administrator
              • Apr 2002
              • 44475

              #7
              Re: Scripting and error logging: A little sidenote

              The are old and not used for R12 now.

              Technically a 0 byte mp3 is valid, there is nothing to decode so there are no errors.
              Spoon
              www.dbpoweramp.com

              Comment

              • MusicGeek

                • Mar 2007
                • 6

                #8
                Re: Scripting and error logging

                That would explain that, then. :D

                Anyway, it seems that with a check for the final targetfile's existence, my program is now in working order.

                Thanks for the help, guys.

                Comment

                Working...

                ]]>