Announcement

Collapse
No announcement yet.

Video problem

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

  • Video problem

    Hi All,


    I'm kind of stuck on getting a video on my ULCD-220RD. The video is actually an animation (wmv) which should play forever. It's pretty large (+/- 9964 frames, 25 fps) To achieve this I wrote a loop for continously playing the animation. I started to notice that after a few cycles through the loop, the animation is playing slower than it should. After every loop it gets a little slower so my timed animation doesn't look right anymore. Can anybody please give me some advice? I really need some help with this. Could it have to do something with my code? Below is my code example:


    #platform "uLCD-220RD"

    #inherit "4DGL_16bitColours.fnc"
    #inherit "VisualConst.inc"
    #inherit "TEST1Const.inc"

    func main()
    // Uncomment the following if uSD images used.
    putstr("Mounting...\n");
    if (!(file_Mount()))
    while(!(file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif
    //gfx_TransparentColour(0x0020);
    //gfx_Transparency(ON);

    hndl := file_LoadImageControl("TEST1.dat", "TEST1.gci", 1);

    repeat


    // Video1 1.0 generated 3-6-2015 13:59:29
    var frame ;
    for(frame := 0; frame<=9964; frame++)
    img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame) ; // where frame is 0 to 9964
    img_Show(hndl,iVideo1) ;
    next

    forever
    endfunc


    Thanks in advance!

  • #2
    Your program looks fine.

    What brand of uSD card are you using?
    Mark

    Comment


    • #3
      I'm using the uSD card supplied with the ULCD-220RD kit. Can it have anything to do with my uSD card?

      Yesterday I added a timer to the animation. When I compare the time with the stopwatch of my phone it turns out that the video plays slower when it's closer to the end. The 5 min animation uses approximately 9:50 to complete. Especially the last half minute is plawing way slower than it should.

      Thanks!

      Comment


      • #4
        Check that the file is not fragmented, use

        chkdsk *.*

        From the DOS prompt

        So it always plays at the same speed, it's just that it's slower at the end than the start?

        Can you send the original wmv to mark at 4dsystems dot com dot au?
        Mark

        Comment


        • #5
          Hi Mark,

          Is sent you an email with two wmv's. Here is a screenshot. This is what you mean right? It's in dutch but I assume you can read the data. The uSD now contains a smaller version of the animation. Nevertheless it's still playing slower when it's close to the end.
          Attached Files

          Comment


          • #6
            You need to specify the *.* otherwise it doesn't check the files to see if they are contiguous, eg. CHKDSK I:*.*

            This will add more output, eg
            All specified files are contiguous.
            if everything is contiguous, or
            \vt1.gci contains 2 non-contiguous blocks.
            to indicate non-contiguous files.

            The problem is that access to the FAT is required to find each frame the uSD. Because of the large file size this becomes noticeable. The Diablo processor does avoid the use of the FAT during the display of each frame, but, unfortunately it doesn't when it goes to locate the frame on uSD. This is why our RMpet utility forces 64KB cluster sizes, to try and cut down on the FAT access required (your uSD is formatted with a 32KB cluster size).

            There is something else that can be done. The example below checks if the file is contiguous and then uses RAW access to the file if it is, it reads part of your TestAnimation_20FPS_04.58_HQ_Timer.wmv file and writes stats to the com port.

            Here's the results I got with an unfragmented GCI file
            Code:
            First 100 Img: 4144ms
            Last 100 Img:14939ms
            First 100 RAW: 4091ms
            Last 100 RAW: 4085ms
            Here's the results with a fragmented file
            GCI is not contiguous, cannot use RAW access!
            First 100 Img: 4555ms
            Last 100 Img:15546ms
            Here's the code

            Code:
            func main()
                var frame, i, iflags, icluster, disk, secloc[2], raw ;
            
                putstr("Mounting...\n");
                if (!(disk := file_Mount()))
                    while(!(disk := file_Mount()))
                        putstr("Drive not mounted...");
                        pause(200);
                        gfx_Cls();
                        pause(200);
                    wend
                endif
            
                hndl := file_LoadImageControl("vt1.dat", "vt1.gci", 1);
            
                iflags := img_GetWord(hndl, iVideo1, IMAGE_FLAGS);
                icluster := img_GetWord(hndl, iVideo1, IMAGE_CLUSTER) ;
                if (!(iflags & 0x0008))
                    gfx_MoveTo(20,100) ;
                    print("GCI is not contiguous,\ncannot use RAW access!") ;
                    pause(5000) ;
                    to(COM0) ;
                    print("GCI is not contiguous, cannot use RAW access!\n") ;
                    raw := 0 ;
                else
                    raw := 1 ;
                endif
                umul_1616(secloc, icluster-2, disk[DISK_SECT_PER_CLUS]) ;   // calc starting sector
                secloc[0] += disk[DISK_DATA_LO] ;                           // offset for disk data start (low word)
                secloc[1] += OVF() ;                                        // adjust in case of overflow
                secloc[1] += disk[DISK_DATA_HI] ;                           // offset for disk data start (high word)
            
                repeat
                    // use img access routines
                    sys_SetTimer(TIMER0,30000) ;
                    for(frame := 0; frame <= 99; frame++)
                        img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame) ;
                        img_Show(hndl,iVideo1) ;
                    next
                    i := sys_GetTimer(TIMER0) ;
                    to (COM0) ;
                    print("First 100 Img: ", 30000-i, "ms\n") ;
                    sys_SetTimer(TIMER0,30000) ;
                    for(frame := 5871; frame<=5970; frame++)    // frame := 9465; frame<=9964; frame++)
                        img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame) ; // where frame is 0 to 9964
                        img_Show(hndl,iVideo1) ;
                    next
                    i := sys_GetTimer(TIMER0) ;
                    to (COM0) ;
                    print("Last 100 Img:", 30000-i, "ms\n") ;
            
                    // use RAW access routines
                    if (raw)
                        media_SetSector(secloc[1], secloc[0]);
                        sys_SetTimer(TIMER0,30000) ;
                        for(frame := 0; frame <= 99; frame++)       // 9964 frames   5970
                            media_VideoFrame(0, 0, frame);
                        next
                        i := sys_GetTimer(TIMER0) ;
                        to (COM0) ;
                        print("First 100 RAW: ", 30000-i, "ms\n") ;
            
                        sys_SetTimer(TIMER0,30000) ;
                        for(frame := 5871; frame<=5970; frame++)    // frame := 9465; frame<=9964; frame++)
                            media_VideoFrame(0, 0, frame);
                        next
                        i := sys_GetTimer(TIMER0) ;
                        to (COM0) ;
                        print("Last 100 RAW: ", 30000-i, "ms\n") ;
                    endif
            
                forever
            endfunc
            You should be able to extract the relevant 'magic' and incorporate it into your program and get the results you are looking for.
            Mark

            Comment

            Working...
            X