QSF in endless loop at 99% ... and a strange result from trim-and-copy then QSF

hydra3333

Member
Hello.

I have a .TS file where a vrd v6 .COM scripted QSF "FileSaveAs" never finishes.
It just keeps on going around and around returning status "1" even after hovering over the VideoReDo icon in the system tray shows "Percent Complete: 100%" for ages.

Lots of other .TS files work a treat using the same script on the .ts files.


It is REALLY strange.
The .TS file is circa 2.23 Gb in size.
Using Trim-and-copy, I chopped various sizes, yielding these interactive QSF (match-source) results:
1. Full file untrimmed = freeze at 99%
2. Trim to keep the first 1800 Mb = freeze at 99%
3. Trim to keep the first 1700 Mb = freeze at 99%
4. Trim to keep the first 1600 Mb = finishes and saves .mp4 QSF'd file although VERY slow from about 63% onward
5. Trim to keep the first 1650 Mb = freeze at 99%
6. Trim to keep the first 1625 Mb = freeze at 99%
7. Trim to keep the first 1610 Mb = finishes and saves .mp4 QSF'd file although VERY slow from about 63% onward
8. Trim to keep the first 1620 Mb = freeze at 99%
9. Trim to keep the first 1615 Mb = freeze at 99%
10. Trim from 1600 for 50Mb = QSF finishes and saves .mp4 ... what ???
11. Trim from 1550 for 100Mb = QSF finishes and saves .mp4 ... what ???
12. Trim from 1500 for 200Mb = QSF finishes and saves .mp4 ... what ???

I finished trying to find a snippet of the .TS file that fails, since 2.3Gb is too large to upload for you, but to no avail.


Here's an extract of relevant completion-checking-loop code from the QSF script:
Code:
    Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: Commencing: " & vrdtvsp_current_datetime_string())
    openflag = VideoReDo.FileOpen(riqowv_FILE_AbsolutePathName, True) ' True means QSF mode
    If openflag = False Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: ERROR: VideoReDo failed to open file: """ & riqowv_FILE_AbsolutePathName & """")
        VideoReDo.ProgramExit()
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: Exiting with errorlevel code 5")
        Wscript.Quit 5
    End If
    outputOK = VideoReDo.FileSaveAs(riqowv_QSF_AbsolutePathName, riqowv_vrd6_profile_name) ' save the QSF file using the specified QSF profile
    If NOT outputOK = True Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: ERROR: VideoReDo failed to create QSF file: """ & riqowv_QSF_AbsolutePathName & """ using profile:""" & riqowv_vrd6_profile_name & """")
        closeflag = VideoReDo.FileClose()
        VideoReDo.ProgramExit()
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: Exiting with errorlevel code 5")
        Wscript.Quit 5
    End If
    Wscript.StdOut.Write("vrdtvsp_run_inlineQSF_only_with_vrd6: QSF working: ")
    '********************************************************************************
    i = 0
    OutputGetState = VideoRedo.OutputGetState()
    While( OutputGetState <> 0 )
        i = i + 1
        If ((i MOD dot_count_linebreak_interval) = 0) Then Wscript.StdOut.WriteLine(" " & ((i * wait_ms)/1000) & " Seconds")
        If i > giveup_interval_count Then
            Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: ERROR: VideoReDo timeout after " & ((i * wait_ms)/1000) & " seconds waiting for QSF to complete ... Aborting ...")
            closeflag = VideoReDo.FileClose()
            VideoReDo.ProgramExit()
            Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: Exiting with errorlevel code 5")
            Wscript.Quit 5
        End If
        Wscript.StdOut.Write( "." & OutputGetState)
        Wscript.Sleep wait_ms
        OutputGetState = VideoRedo.OutputGetState()
    Wend
    '********************************************************************************
    Wscript.StdOut.WriteLine( "." & OutputGetState & ".")
    ' Grab the *Actual* info about the "VRD latest save" and hope it is the QSF file)
    xml_string_completedfile = ""
    xml_string_completedfile = VideoReDo.OutputGetCompletedInfo() ' which is the most recently completed output file (hopefully the QSF file) https://www.videoredo.com/TVSuite_Application_Notes/output_complete_info_xml_forma.html"
    Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd6: QSF 100% Completed: " & vrdtvsp_current_datetime_string())
    closeflag = VideoReDo.FileClose()
Here's its output:
Code:
vrdtvsp_run_inlineQSF_only_with_vrd6: QSF working: .1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 120 Seconds
.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 240 Seconds
.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 360 Seconds
.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
(it never stops returning "1"). The "100%" shown by hovering over the icon in the system tray occurs after the first 30 or so "1" status values are returned but it keeps on looping.
Whereas other similar files return fine, like this:
Code:
vrdtvsp_run_inlineQSF_only_with_vrd6: Commencing: 2021.02.24-16.43.53.214
vrdtvsp_run_inlineQSF_only_with_vrd6: QSF working: .1.1.1.1.1.1.1.1.1.1.1.1.1.1.0.
vrdtvsp_run_inlineQSF_only_with_vrd6: QSF 100% Completed: 2021.02.24-16.44.21.699
I tried a non-scripted interactive QSF on the full file, and it stalls with the green progress bar sitting at 99%, never finishing, even though its icon in the taskbar shows "100%".

The end of the VeideoReDo v6log from a failed QSF (after "About Output was clicked") shows
Code:
2021-02-24 17:03:16 H264 decoder: Process thread complete.  Video frames, In: 0,  Out: 0
2021-02-24 17:03:16 Deinterlacer processing thread complete.  In: 25, Out: 25
2021-02-24 17:03:16 H264 decoder: Process thread complete.  Video frames, In: 25,  Out: 25
The Deinterlacer line is also of interest since I did not ask for deinterlacing in the QSF profile per "Interlacing: no change".

I wonder if you could please consider identifying and perhaps resolving the issue with QSF/.COM caused by this .TS file ?

Thank you.
 
Last edited:

hydra3333

Member
Hello. Just came across a second .TS file which does the same thing.
(I only recently started using QSF in v6, I have been using QSF in v5 for a long time).

Edit: the file works in QSF for VideoReDo version 5
 
Last edited:

tobyW

Member
Hello. Just came across a second .TS file which does the same thing.
(I only recently started using QSF in v6, I have been using QSF in v5 for a long time).

Edit: the file works in QSF for VideoReDo version 5
Hi folks,
After we all discussed the VRD6 QSF problem back in June/July 2020, I've mostly been working around it by directly saving to a .TS output file without QSF.

This workaround seems to get the job done, but I'm unsure of its validity. So sometimes I do try QSF (since I'm shaking the tree of a Beta after all), but even if it doesn't freeze I must check that the resulting output hasn't lost the end of the audio track.

FWIW Either way I now disallow Multiple Audio Streams in the TS profile, especially if the title is marked "AD" (Audio Described), in case that's contributing to the problem. (Maybe a red herring?)

I usually find that VRD5 will happily QSF the same files that break VRD6.

To the VRD guys, well done there's a lot to love about VRD6, but this QSF problem hasn't gone away (as of beta 828a). Any news yet?
Thanks,
TobyW
 

hydra3333

Member
I've mostly been working around it by directly saving to a .TS output file without QSF.
I've worked around it by doing a v6 QSF with a timeout, then aborting that and falling back to a v5 QSF.

Yes, VRD is wonderful, don't get me wrong there !
 

hydra3333

Member
I might give it a try.
OK, just as info, here's an inline function (1970's coding style :)) I use (there may be a hidden global variable or two, so Option Explicit may be a good thing)
Code:
Function vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 (byVAL riqowv_vrd_version, byVAL riqowv_FILE_AbsolutePathName, byVAL riqowv_QSF_AbsolutePathName, byVAL riqowv_vrd6_profile_name)
    ' This script should ALWAYS be reconciled with that created by function vrdtvsp_create_custom_QSF_vbscript_vrd_5_AND_6
    ' Parameters:
    '                riqowv_vrd_version                is the version of vrd to be used
    '                riqowv_FILE_AbsolutePathName    is path/name of output QSF'd file - a fully qualified path name
    '                riqowv_QSF_AbsolutePathName        is input video file path - a fully qualified path name, eg a .TS file
    '                riqowv_vrd6_profile_name        is name ofa valid  QSF Output Profile created in VRD v6
    ' Returns:
    '                a dictionary object populated with key/item pairs of data about the resulting QSF file (see xml from VideoReDo.OutputGetCompletedInfo() below ; xml attributes are also added as well as xml items)
    '
    ' Example xml string: from VideoReDo.FileGetOpenedFileProgramInfo()
    ' This is a well-formed single-item XML string, which make it really easy to find things.
    '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    '<VRDProgramInfo>
    '  <FileName d="Name">somefilename.qsf.vrd6.mp4</FileName>
    '  <FileSize f="0.029 GB" d="Size">28519136</FileSize>
    '  <ProgramDuration f="00:01:04.84" d="Duration" total_frames="1622">5835601</ProgramDuration>
    '  <FileType d="Mux type">MP4</FileType>
    '  <Video>
    '    <Encoding>H.264</Encoding>
    '    <VideoStreamID>x201</VideoStreamID>
    '    <FrameRate f="25.00 fps" d="Frame rate">25.000000</FrameRate>
    '    <constant_frame_rate_flag d="Frame rate flag">Constant</constant_frame_rate_flag>
    '    <EncodingDimensions d="Encoding size" width="1920" height="1080">1920 x 1080</EncodingDimensions>
    '    <AspectRatio d="Aspect ratio">16:9</AspectRatio>
    '    <HeaderBitRate f="25.000 Mbps" d="Header bit rate">25000000</HeaderBitRate>
    '    <VBVBufferSize f="572 KBytes" d="VBV buffer">572</VBVBufferSize>
    '    <Profile>High/4.0</Profile>
    '    <Progressive f="Interlaced">False</Progressive>
    '    <Chroma chroma_value="1">4:2:0</Chroma>
    '    <EntropyCodingMode d="Entropy mode">CABAC</EntropyCodingMode>
    '    <EstimatedVideoBitrate f="2.992 Mbps" d="Bit rate">2992213</EstimatedVideoBitrate>
    '  </Video>
    '  <AudioStreams>
    '    <AudioStream StreamNumber="1" Primary="true">
    '    <AudioCodec d="Codec">AC3</AudioCodec>
    '    <Format>AC3 stream</Format>
    '    <AudioChannels d="Channels">5.1</AudioChannels>
    '    <Language>eng</Language>
    '    <PID>x202</PID>
    '    <PESStreamId d="PES Stream Id">xBD</PESStreamId>
    '    <AudioBitRate f="448 Kbps" d="Bit rate">448000</AudioBitRate>
    '    <AudioSampleRate d="Sampling rate">48000</AudioSampleRate>
    '    <BitsPerSample d="Sample size" f="16 bits">16</BitsPerSample>
    '    </AudioStream>
    '    </AudioStreams>
    '  <SubtitleStreams/>
    '</VRDProgramInfo>
    '
    ' Example xml string: from VideoReDo.OutputGetCompletedInfo()
    ' VideoReDo.OutputGetCompletedInfo() MUST be called immediately AFTER a QSF FileSaveAs and BEFORE the .Close of the source file for the QSF
    ' This is a well-formed single-item XML string, which make it really easy to find things.
    '<VRDOutputInfo outputFile="G:\HDTV\000-TO-BE-PROCESSED\zzz-TEST\VRDTVSP-Source\News-National_Nine_News_Afternoon_Edition.2021-02-05.ts.QSF">
    '  <OutputType desc="Output format:" hidden="1">MP4</OutputType>
    '  <OutputDurationSecs desc="Video length:" val_type="int" hidden="1">65</OutputDurationSecs>
    '  <OutputDuration desc="Video length:">00:01:05</OutputDuration>
    '  <OutputSizeMB desc="Video size:" val_type="int" val_format="%dMB">27</OutputSizeMB>
    '  <OutputSceneCount desc="Output scenes:" val_type="int">1</OutputSceneCount>
    '  <VideoOutputFrameCount desc="Video output frames:" val_type="int">1625</VideoOutputFrameCount>
    '  <AudioOutputFrameCount desc="Audio output frames:" val_type="int">2033</AudioOutputFrameCount>
    '  <ProcessingTimeSecs desc="Processing time (secs):" val_type="int">1</ProcessingTimeSecs>
    '  <ProcessedFramePerSec desc="Processed frames/sec:" val_type="float" val_format="%.2f">1625.000000</ProcessedFramePerSec>
    '  <ActualVideoBitrate desc="Actual Video Bitrate:" desc_format="%24s" val_type="float" val_format="%0.2f Mbps">2.912357</ActualVideoBitrate>
    '  <lkfs_values hidden="1"/>
    '  <audio_level_changes hidden="1"/>
    '</VRDOutputInfo>
    '
    Const wait_ms = 2000 ' in milliseconds
    Dim dot_count_linebreak_interval, two_hours_in_ms, one_hour_in_ms, half_hour_in_ms, quarter_hour_in_ms, ten_minutes_in_ms, giveup_interval_count
    Dim xmlDict    ' this is a dictionary object returned with Set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = xmlDict
    Dim VideoReDoSilent
    Dim VideoReDo
    Dim openflag, closeflag, outputOK, OutputGetState, percentComplete
    Dim percent
    Dim i, profile_count, QSF_profile_count, matching_QSF_profile, a_profile_name, is_QSF
    Dim QSF_Profile_Names()
    Dim xml_string, xml_string_openedfile, xml_string_completedfile
    Dim xmlDoc,    xml_status, xml_objErr, xml_errorCode, xml_reason
    '
    Dim actual_outputFile, actual_VideoOutputFrameCount, actual_ActualVideoBitrate
    Dim estimated_outputFile, estimated_VideoOutputFrameCount, estimated_ActualVideoBitrate
    '
    two_hours_in_ms = CLng( 2 * 60 * 60 * 1000 )
    one_hour_in_ms = ROUND(two_hours_in_ms / 2)
    half_hour_in_ms = ROUND(one_hour_in_ms / 2)
    quarter_hour_in_ms = ROUND(half_hour_in_ms / 2)
    ten_minutes_in_ms = ROUND(two_hours_in_ms / 6)
    dot_count_linebreak_interval = CLng(CLng(120) * CLng(1000) / CLng(wait_ms))        ' for 2000 ms, this is 120 seconds worth of intervals
    giveup_interval_count = CLng( CLng(quarter_hour_in_ms) / CLng( wait_ms ) )    ' two hours worth of intervals
    '
    riqowv_FILE_AbsolutePathName = fso.GetAbsolutePathName(riqowv_FILE_AbsolutePathName)        ' was passed byVal
    riqowv_QSF_AbsolutePathName = fso.GetAbsolutePathName(riqowv_QSF_AbsolutePathName)            ' was passed byVal
    '
    WScript.StdOut.WriteLine("======================================================================================================================================================")
    WScript.StdOut.WriteLine("" & vrdtvsp_current_datetime_string())
    WScript.StdOut.WriteLine("START vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 - QSF VRD VERSION SPECIFIED TO BE USED IS: """ & riqowv_vrd_version & """")
    '
    If riqowv_vrd_version = 5 Then
        Set VideoReDoSilent = WScript.CreateObject("VideoReDo5.VideoReDoSilent")
    ElseIf riqowv_vrd_version = 6 Then
        Set VideoReDoSilent = WScript.CreateObject("VideoReDo6.VideoReDoSilent")
    Else
        WScript.StdOut.WriteLine("VRDTVSP vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 - Error - VRD version must be 5 or 6, not """ & riqowv_vrd_version & """... Aborting ...")
        Wscript.Echo "Error 17 = cannot perform the requested operation"
        On Error goto 0
        WScript.Quit 17 ' Error 17 = cannot perform the requested operation
    End If
    Set VideoReDo = VideoReDoSilent.VRDInterface
    VideoReDo.ProgramSetAudioAlert(False)
    '
    ' Validate the specified VRD QSF profile exists
    '
    QSF_profile_count = 0
    profile_count = VideoReDo.ProfilesGetCount()
    For i = 0 to profile_count-1
        a_profile_name = VideoReDo.ProfilesGetProfileName( i )
        If riqowv_vrd_version = 5 Then
            is_QSF = True
        ElseIf riqowv_vrd_version = 6 Then
            is_QSF = NOT VideoReDo.ProfilesGetProfileIsAdScan( i )
        End If
        If ( is_QSF ) Then
            QSF_profile_count = QSF_profile_count + 1
            ReDim Preserve QSF_Profile_Names(QSF_profile_count-1) ' base 0, remember
            QSF_Profile_Names(QSF_profile_count-1) = a_profile_name
        End If
    Next
    If QSF_profile_count < 1 Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ERROR: no VRD QSF profiles were returned by VRD")
        'on error resume next
        on error goto 0
        VideoReDo.ProgramExit()
        on error goto 0
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
        Wscript.Quit 5
    End If
    matching_QSF_profile = False
    For i = 0 to (QSF_profile_count-1)
        If riqowv_vrd6_profile_name = QSF_Profile_Names(i) Then
            matching_QSF_profile = True
            Exit For
        End If
    Next
    If NOT matching_QSF_profile Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ERROR: no VRD6 QSF profile was located matching your specified profile: """ & riqowv_vrd6_profile_name & """")
        For i = 0 to profile_count-1
            a_profile_name = VideoReDo.ProfilesGetProfileName( i )
            is_QSF = NOT VideoReDo.ProfilesGetProfileIsAdScan( i )
            If ( is_QSF ) Then
                QSF_profile_count = QSF_profile_count + 1
                Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6F: Profile (" & i & ")=""" & a_profile_name & """ is an QSF profile")
            End If
        Next
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: QSF Profile count: " & QSF_profile_count )
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
        'on error resume next
        on error goto 0
        VideoReDo.ProgramExit()
        on error goto 0
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
        Wscript.Quit 5
    End If
    '
    ' Open the Input file and QSF SaveAs to the output file
    '
    Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Commencing WITH SPECIFIED VRD VERSION : " & riqowv_vrd_version & " at: " & vrdtvsp_current_datetime_string())
    openflag = VideoReDo.FileOpen(riqowv_FILE_AbsolutePathName, True) ' True means QSF mode
    If openflag = False Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ERROR: VideoReDo failed to open file: """ & riqowv_FILE_AbsolutePathName & """")
        'on error resume next
        on error goto 0
        VideoReDo.ProgramExit()
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
        exit function
        'Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
        'Wscript.Quit 5
    End If
    outputOK = VideoReDo.FileSaveAs(riqowv_QSF_AbsolutePathName, riqowv_vrd6_profile_name) ' save the QSF file using the specified QSF profile
    If NOT outputOK = True Then
        Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ERROR: VideoReDo failed to create QSF file: """ & riqowv_QSF_AbsolutePathName & """ using profile:""" & riqowv_vrd6_profile_name & """")
        'on error resume next
        on error goto 0
        closeflag = VideoReDo.FileClose()
        VideoReDo.ProgramExit()
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
        exit function
        'Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
        'Wscript.Quit 5
    End If
    Wscript.StdOut.WriteLine("QSF working: ")
    'Wscript.StdOut.Write("VRDTVS_VRD_QSF: Percent Complete: ")
    i = 0
    OutputGetState = VideoRedo.OutputGetState()
    While( OutputGetState <> 0 )
        i = i + 1
        If ((i MOD dot_count_linebreak_interval) = 0) Then Wscript.StdOut.WriteLine(" " & ((i * wait_ms)/1000) & " Seconds")
        If i > giveup_interval_count Then
            Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ERROR: VideoReDo timeout after " & ((i * wait_ms)/1000) & " seconds waiting for QSF to complete ... Exiting ...")
            'on error resume next
            on error goto 0
            closeflag = VideoReDo.FileClose()
            VideoReDo.ProgramExit()
            ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
            on error goto 0
            set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
            exit function
            'Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 5")
            'Wscript.Quit 5
        End If
        'on error resume next
        on error goto 0
        percentComplete = CLng(VideoReDo.OutputGetPercentComplete())
        'if NOT err.number = 0 then
        '    percentComplete = 0
        'end if
        'Wscript.StdOut.Write(" " & percent & "% ")
        Wscript.StdOut.Write( "." & OutputGetState)
        on error goto 0
        Wscript.Sleep wait_ms
        OutputGetState = VideoRedo.OutputGetState()
    Wend
    Wscript.StdOut.WriteLine( "." & OutputGetState & ".")
    '
    ' Grab the *Actual* info about the "VRD latest save" and hope it is the QSF file)
    '  
    'on error resume next
    on error goto 0
    xml_string_completedfile = ""
    xml_string_completedfile = VideoReDo.OutputGetCompletedInfo() ' which is the most recently completed output file (hopefully the QSF file) https://www.videoredo.com/TVSuite_Application_Notes/output_complete_info_xml_forma.html"
    on error goto 0
    Wscript.StdOut.WriteLine("QSF 100% Completed: " & vrdtvsp_current_datetime_string())
    closeflag = VideoReDo.FileClose()
    'on error resume next
    on error goto 0
    VideoReDo.ProgramExit()
    on error goto 0
    Set VideoReDo = Nothing
     Set VideoReDoSilent = Nothing
    Wscript.StdOut.WriteLine("QSF xml_string_completedfile=")
    Wscript.StdOut.WriteLine(xml_string_completedfile)
    '
    ' Get some of the data obtained during the QSF process and populate a Dict object to return
    '
    Set xmlDict = CreateObject("Scripting.Dictionary")
    xmlDict.CompareMode = vbTextCompare ' set case insensitive key lookups. You can set the CompareMode property only when the dictionary is empty.
    Set xmlDoc = WScript.CreateObject("Msxml2.DOMDocument.6.0")
    xmlDoc.async = False
    'on error resume next
    on error goto 0
    xml_status = xmlDoc.loadXML(xml_string_completedfile)
    Set xml_objErr = xmlDoc.parseError
    xml_errorCode = xml_objErr.errorCode
    xml_reason = xml_objErr.reason
    Set xml_objErr = Nothing
    Err.clear
    on error goto 0
    If NOT xml_status Then
        Set xmlDoc = Nothing
        WScript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ABORTING: Failed to load string from VideoReDo.OutputGetCompletedInfo() xml_string_completedfile=" & xml_string_completedfile)
        WScript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ABORTING: xml_status: " & xml_status & " XML error: " & xml_errorCode & " : " & xml_reason)
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
        exit function
        'Wscript.Echo "Error 17 = cannot perform the requested operation"
        'WScript.Quit 17 ' Error 17 = cannot perform the requested operation
    End If
    '
    'Call vrdtvs_DumpNodes_from_xml(xmlDoc.childNodes, 0)    ' PRINT INTERESTING INFORMATION FORM WITH THE XML DOCUMENT
    '
    xmlDict.Add "outputFile", gimme_xml_named_attribute(xmlDoc, "//VRDOutputInfo", "outputFile")
    xmlDict.Add "OutputType", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/OutputType")
    xmlDict.Add "OutputDurationSecs", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/OutputDurationSecs")
    xmlDict.Add "OutputDuration", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/OutputDuration")
    xmlDict.Add "OutputSizeMB", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/OutputSizeMB")
    xmlDict.Add "OutputSceneCount", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/OutputSceneCount")
    xmlDict.Add "VideoOutputFrameCount", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/VideoOutputFrameCount")
    xmlDict.Add "AudioOutputFrameCount", gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/AudioOutputFrameCount")
    xmlDict.Add "ActualVideoBitrate", CLng(CDbl(gimme_xml_named_value(xmlDoc, "//VRDOutputInfo/ActualVideoBitrate")) * CDbl(1000000.0)) ' convert from dedcimal Mpbs to bps
    If NOT xmlDict.Exists("outputFile") Then
        Set xmlDoc = Nothing
        WScript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ABORTING: outputFile string from VideoReDo.OutputGetCompletedInfo() not in Dict, xml_string_completedfile=" & xml_string_completedfile)
        Wscript.Echo "Error 17 = cannot perform the requested operation"
        On Error goto 0
        Set xmlDoc = Nothing
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
        exit function
        'Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 17")
        'WScript.Quit 17 ' Error 17 = cannot perform the requested operation
    ElseIf NOT ( Ucase(xmlDict.Item("outputFile")) =  Ucase(riqowv_QSF_AbsolutePathName) ) Then
        Set xmlDoc = Nothing
        WScript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: ABORTING: outputFile from VideoReDo.OutputGetCompletedInfo() not equal QSFfilename: xml_string_completedfile=" & xml_string_completedfile & " riqowv_QSF_AbsolutePathName=" & riqowv_QSF_AbsolutePathName)
        Wscript.Echo "Error 17 = cannot perform the requested operation"
        On Error goto 0
        Set xmlDoc = Nothing
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = Nothing
        exit function
        'Wscript.StdOut.WriteLine("vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6: Exiting with errorlevel code 17")
        'WScript.Quit 17 ' Error 17 = cannot perform the requested operation
    End If
    on error goto 0
    Set xmlDoc = Nothing
    WScript.StdOut.WriteLine("END vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 - QSF VRD VERSION SPECIFIED TO BE USED WAS: """ & riqowv_vrd_version & """")
    WScript.StdOut.WriteLine("" & vrdtvsp_current_datetime_string())
    WScript.StdOut.WriteLine("======================================================================================================================================================")
    Set vrdtvsp_run_inlineQSF_only_with_vrd_5_and_6 = xmlDict
    ' Can use the returned Dict like this:
    '    Dim vrdtvs_dict
    '    Set vrdtvs_dict = CreateObject("Scripting.Dictionary")
    '    vrdtvs_dict.CompareMode = vbTextCompare ' case insensitive key lookups. You can set the CompareMode property only when the dictionary is empty.
    '    vrdtvs_dict.Add key, item
    '    vrdtvs_dict.Remove (key)
    '    vrdtvs_dict.RemoveAll
    '    If vrdtvs_dict.Exists(key) Then temp = vrdtvs_dict.Item(key) Else temp = ""
    '    End If
    '    For Each key In vrdtvs_dict
    '        wscript.echo "Dict key=" & key & " value= " & vrdtvs_dict.Item(key)
    '    Next
    '    vrdtvs_dict.Items().Count ' count of items in the dictionary
    '    vrdtvs_dict.Keys().(i)    ' the value, say in a for/next loop, base 0 (0 to Count-1)
    '    vrdtvs_dict.Items().(i)    ' the value, say in a for/next loop, base 0 (0 to Count-1)
    '    vrdtvs_dict.Remove vrdtvs_dict.Keys()(i)
    '    vrdtvs_dict.Key(key) = newkey ' but You can't change a value in a key-value pair.  If you want a different value, you need to delete the item, then add a new one.
End Function
Function gimme_xml_named_value (xmlDoc_object, byVAL xml_item_name) ' assumes the xml doc is already loaded in xmlDoc_object
    '    Parameters:
    '        xmlDoc_object     the DOM xml object with the xml string already loaded
    '        xml_item_name     a CASE-SENSITIVE string like //VRDProgramInfo/Video/EstimatedVideoBitrate
    Dim item_nNode, item_text
    Set item_nNode = xmlDoc_object.selectsinglenode(xml_item_name) ' eg '//VRDProgramInfo/Video/EstimatedVideoBitrate' CAREFUL, this is case sensitive
    If item_nNode is Nothing Then
        WScript.StdOut.WriteLine("VRDTVS gimme_xml_named_value ABORTING : Could not find XML node " & xml_item_name & " in xmlDoc_object")
        Wscript.Echo "Error 17 = cannot perform the requested operation"
        Set xmlDoc_object = Nothing
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        gimme_xml_named_value = "no xml node to get data from"
        exit function
        'Wscript.StdOut.WriteLine("gimme_xml_named_value: Exiting with errorlevel code 17")
        'WScript.Quit 17 ' Error 17 = cannot perform the requested operation exit with an error ... soft or hard ?
    End If
    gimme_xml_named_value = item_nNode.text ' eg the text for that item //VideoReDoProject/EstimatedVideoBitrate
    End Function
Function gimme_xml_named_attribute (xmlDoc_object, byVAL xml_item_name, byVAL xml_item_attribute_name)
    '    Parameters:
    '        xmlDoc_object                 the DOM xml object with the xml string already loaded
    '        xml_item_name                 a CASE-SENSITIVE string like //VideoReDoProject/EncodingDimensions
    '        xml_item_attribute_name        a CASE-SENSITIVE string like "width"
    Dim item_nNode, item_text
    Set item_nNode = xmlDoc_object.selectsinglenode(xml_item_name) ' eg '//VideoReDoProject/EncodingDimensions' CAREFUL, this is case sensitive
    If item_nNode is Nothing Then
        WScript.StdOut.WriteLine("VRDTVS gimme_xml_named_attribute ABORTING: Could not find XML node " & xml_item_name & " in xmlDoc_object")
        Wscript.Echo "Error 17 = cannot perform the requested operation"
        Set xmlDoc_object = Nothing
        ' change hard fail to a soft fail so this source file can be ignored and moved and the process continue with the next source file
        on error goto 0
        gimme_xml_named_attribute = "no xml node to get data from"
        exit function
        'Wscript.StdOut.WriteLine("gimme_xml_named_attribute: Exiting with errorlevel code 17")
        'WScript.Quit 17 ' Error 17 = cannot perform the requested operation exit with an error ... soft or hard ?
    End If
    item_text = item_nNode.text ' eg the text for that item //VideoReDoProject/EncodingDimensions
    gimme_xml_named_attribute = item_nNode.getAttribute(xml_item_attribute_name)
End Function
 

Dan203

Senior Developer
Staff member
Yes, I just tried it and same behaviour.

That is to say, it stalls at 99% after going very slowly in the latter 1/3.
If it also stalls in the UI then there is something wrong with the file, or VRD, not your script. Upload the smallest clip you have that reproduces the issue and shoot us an email and we'll check it out.
 

tobyW

Member
OK, just as info, here's an inline function (1970's coding style :)) I use (there may be a hidden global variable or two, so Option Explicit may be a good thing)
Many thanks. It's been a few years since I last programmed around VRD's COM object, so this will be a good refresher to keep my grey hairs at bay!:)
 

tobyW

Member
A possible clue:
Last year I had noticed both QSF and the UI were upset when there was a disturbance in the received signal. (The subject of an earlier thread)

Recently I've saved a small collection of problem input files. I've just noticed that in all of them the audio track seems to terminate some seconds before the video track, and QSF begins its go-slow where the audio track terminates. It's repeatable with a 100MB clip of the end of an input file.
 
Top Bottom