Announcement

Collapse
No announcement yet.

playing random movie clips

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

  • kapsreiter
    replied
    Hi Paul

    First, thank you for your help

    i will order here some
    gen4-uLCD-24D displays
    and the gen4-PA Programmer also



    thanks
    tom
    Last edited by kapsreiter; 26 February 2018, 03:02 AM.

    Leave a comment:


  • pauleilio
    replied
    Hello,

    Could you please let me know which programming environment you are using and I will prepare an example for you

    Best regards

    Paul

    Leave a comment:


  • kapsreiter
    replied
    hi

    could you upload your code with a manual how to use it?

    i am total new and want the same

    ramdom videoplay at power on

    Leave a comment:


  • jmratkos
    replied
    hi paul & mark,
    I just wanted to say "thanks" again. we got everything working perfectly. I'm using one unique animation at the start-up, and then I'm randomly cycling through [x] number of clips (which fall into one category and alternating between [y] number of shorter clips in between

    start-up animation

    animation clip (one random clip from the number of [x] type ones on the microSD card
    animation clip (one random clip from the number of [y] type ones on the microSD card
    animation clip (one random clip from the number of [x] type ones on the microSD card
    animation clip (one random clip from the number of [y] type ones on the microSD card
    repeat...
    for the next project, I would like to tap into the GPIO pins and trigger different things based on a pin signal. I may reach out again if I run into any issues
    Last edited by jmratkos; 17 June 2017, 03:57 AM.

    Leave a comment:


  • jmratkos
    replied
    thanks mark

    I'll give that a try tonight

    Leave a comment:


  • ESPsupport
    replied
    String concatenation is, most simply, done like this Untested and useful as a sample only.
    Code:
        var gciname[7] ; // enough for an 8.3 filename and trailing null
        to(gciname) ;
        print("clip", clip_no, ".gci") ;
    Then you need to use a string pointer when opening the file
    Code:
        hndl := file_LoadImageControl( str_Ptr(datname), str_Ptr(gciname), 1);

    Leave a comment:


  • jmratkos
    replied
    I have most everything working now, however there simply has to be a cleaner way of playing the random video files rather than checking the value of clip_no and playing a hard-coded .dat / .gci file combination

    I'd like to put the delay time in an external file (so that it can be altered without having to recompile the code) but I think I'll wait until I get all of the clips converted and running before taking another stab at that

    ps
    ViSi - widgets - system/media - video worked fine for the .wmv files, but threw an error for the .mpg files. it also took my .mkv but make a mess of it (video-wise) after converting it to the .gci/.dat files



    here's my code:

    #platform "uLCD-32PTU"

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "random_movieConst.inc"

    func main()

    var disk;
    var clip_no;
    var counter;
    var frame;
    var frames;
    var hndl;
    var MovieCount;


    counter := 0;

    // initialize the SEED function to help randomize the RAND function used below
    SEED(sys_T());

    gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change

    putstr("Mounting microSD card...\n");

    pause(500);

    if (!(disk:=file_Mount()))
    while (!(disk:=file_Mount()))
    putstr("microSD card not mounted...\n");
    pause(500);
    gfx_Cls();
    pause(500);
    wend
    endif

    gfx_Cls();

    // read in the number of movie clips to randomize
    MovieCount := file_Count ( "clip*.gci" );

    gfx_Cls ();

    while ( MovieCount > 0 )
    // display splash animation
    hndl:=file_LoadImageControl( "splash.dat", "splash.gci", 1);

    frames := img_GetWord ( hndl, 0, IMAGE_FRAMES );

    for ( frame:=0; frame < frames; frame++ )
    img_SetWord ( hndl, iVideo1, IMAGE_INDEX, frame );
    img_Show ( hndl,iVideo1 );
    next

    pause(2500);

    mem_Free ( hndl );


    label:

    counter++;

    // the following gives us a random value between 1 and the value found in the 'clipcnt.txt' file
    clip_no := ABS ( RAND () % MovieCount ) + 1;

    if ( clip_no == 1 )
    hndl:=file_LoadImageControl( "clip1.dat", "clip1.gci", 1);
    endif

    if ( clip_no == 2 )
    hndl:=file_LoadImageControl( "clip2.dat", "clip2.gci", 1);
    endif

    if ( clip_no == 3 )
    hndl:=file_LoadImageControl( "clip3.dat", "clip3.gci", 1);
    endif

    if ( clip_no == 4 )
    hndl:=file_LoadImageControl( "clip4.dat", "clip4.gci", 1);
    endif

    if ( clip_no == 5 )
    hndl:=file_LoadImageControl( "clip5.dat", "clip5.gci", 1);
    endif

    if ( clip_no == 6 )
    hndl:=file_LoadImageControl( "clip6.dat", "clip6.gci", 1);
    endif

    if ( clip_no == 7 )
    hndl:=file_LoadImageControl( "clip7.dat", "clip7.gci", 1);
    endif

    if ( clip_no == 8 )
    hndl:=file_LoadImageControl( "clip8.dat", "clip8.gci", 1);
    endif

    if ( clip_no == 9 )
    hndl:=file_LoadImageControl( "clip9.dat", "clip9.gci", 1);
    endif

    if ( clip_no == 10 )
    hndl:=file_LoadImageControl( "clip10.dat", "clip10.gci", 1);
    endif

    // determine the number of frames for the selected movie clip to loop through
    frames := img_GetWord ( hndl, 0, IMAGE_FRAMES );

    // loop through the movie clip frames
    for ( frame:=0; frame < frames; frame++ )
    img_SetWord ( hndl, iVideo1, IMAGE_INDEX, frame );
    img_Show ( hndl,iVideo1 );
    next

    gfx_Cls();
    pause(5000);

    mem_Free ( hndl );

    // display the splash file after every 10th movie clip
    if ( counter > 9)
    hndl:=file_LoadImageControl( "splash.dat", "splash.gci", 1);

    frames := img_GetWord ( hndl, 0, IMAGE_FRAMES );

    for ( frame:=0; frame < frames; frame++ )
    img_SetWord ( hndl, iVideo1, IMAGE_INDEX, frame );
    img_Show ( hndl,iVideo1 );
    next

    pause(2500);

    mem_Free ( hndl );

    counter := 0;
    endif

    goto label;
    wend

    endfunc

    Leave a comment:


  • pauleilio
    replied
    Hi,

    You can do this in Workshop 4 which will support most windows video's formats, by starting a new project in ViSI and Clicking on Widgets then System/Media and then Video. Choose the video file in the open file dialog that appears. Place and resize if necessary then compile. It will ask you for a filename to save it as and a location. After that the GCI and DAT file will be available in the folder where the project is saved.

    MovieCount := file_Count ( "*.gci" ); that was good find, thank you for sharing that with me.

    Best regards

    Paul

    Leave a comment:


  • jmratkos
    replied
    I did find this in the picaso internal functions .pdf which I believe will work better than having the moviecnt.txt file on the microSD

    by using this:
    MovieCount := file_Count ( "*.gci" );

    I can eliminate this section from my code:
    // sdFileHandle:=file_Open("moviecnt.txt",'r');

    //read the number of movie clips to randomize from "moviecnt.txt" file
    // for (counter:=0;counter<1;counter++)
    // file_Read(MovieCount,1,sdFileHandle);
    // putstr(MovieCount);
    // next
    // file_Close(sdFileHandle);

    this should also allow me to just [dump] any newly converted files onto the microSD card without any further changes to the code (and no need to recompile and download to the flash memory)


    one more question while I've got your ear
    do you know if there are any plans to update the graphics composer software and allow for more file types to be read in to convert to .gci/.dat?
    .mp4 and .mkv would be nice additions

    currently, I'm getting error messages when attempting to open .wmv's and/or .mpg's and am having to convert the .wmv's to .gif files in photoshop in order to get the clips to be successfully converted

    Leave a comment:


  • pauleilio
    replied
    Hi,

    I understand what you are saying and it can be a bit hard to get your head around, but I think at the end of the day we all become better programmers by acheiving this without a string object as such. In the Arduino world strings are very much frowned upon and we are told to use char arrays instead of strings eventhough there is nothing more convenient than string manipulation eg. clipname := "1" + ".DAT", but string handling is not good on memory usage and not very efficient, as it is, compiled 4DGL code is very compact and efficient.

    In the case of what we were trying to achieve. I suppose we could use if, endif, for the amount of expected videos you may load onto your SD card e.g


    If(clipname == 1)
    hndl:=file_LoadImageControl("1.dat", "1.gci", 1);
    endif

    If(clipname == 2)
    hndl:=file_LoadImageControl("2.dat", "2.gci", 1);
    endif

    I should imagine after being compiled the code size for the above is that not much bigger.

    I will look into your #inherit findings.

    I hope this helps

    Best regards

    Paul

    Leave a comment:


  • jmratkos
    replied
    I guess the thing that I've having a hard time of wrapping my head around is the fact that their are no string vs. numeric variable types in the 4DGL language

    I've been a programmer for almost 30 years now, and in every language that I've coded, if I want to declare a string or an integer variable, I can just do that
    eg.
    string ls_var1
    integer li_var1

    whereas 4DGL identifies all variables as simply type 'var' with no distinction of what type of variable it is

    how does the 4DGL know what the types the variables are?

    the other thing that I've had issues with is the #inherit statements at the top of the programs. for instance the 3 listed above in my source:
    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "random_movieConst.inc"


    I just copied the first two from another program listing, but I until I took a [x]Const.inc file from another program and renamed it the same as what I was naming this project, the script would not compile. exactly where is this constants include supposed to come from and how is it supposed to get created?

    I really like the 4D displays, but I feel like we have to pester you guys (which are awesome) for things that should be easier to figure out than what they are

    Leave a comment:


  • pauleilio
    replied
    Hi,

    Yes this should be possible to do. I am trying a couple of things at the moment.

    As it is we are trying to add an integer to a string ".DAT" which won't work. It wiil need to be converted to text.

    Also take a look through this appnote http://www.4dsystems.com.au/download...0056_R_1_0.pdf

    Paul

    Leave a comment:


  • jmratkos
    replied
    paul,
    I modified the code and found that if I comment out the reading of my .txt file and hard code the file_LoadImageControl command (using double quotes around both the .dat and .gci filename, that I'm able to get a single file to play, so I know that the video files are good. I thought that I could use variables for fname1 and fname2 in the file_LoadImageControl command

    #platform "uLCD-32PTU"

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "random_movieConst.inc"

    func main()

    var disk;
    var clip_no;
    var counter;
    var datname;
    var frame;
    var frames;
    var gciname;
    var hndl;
    var MovieCount;
    var sdFileHandle;


    gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change

    putstr("Mounting...\n");
    if (!(disk:=file_Mount()))
    while (!(disk:=file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif

    gfx_Cls();

    // sdFileHandle:=file_Open("moviecnt.txt",'r');

    //read the number of movie clips to randomize from "moviecnt.txt" file
    // for (counter:=0;counter<1;counter++)
    // file_Read(MovieCount,1,sdFileHandle);
    // putstr(MovieCount);
    // next
    // file_Close(sdFileHandle);

    label:

    gfx_Cls();

    // the following gives us a random value between 1 and the value found in the 'clipcnt.txt' file
    clip_no := ABS(RAND()%MovieCount)+1;

    datname := clip_no + ".dat";
    gciname := clip_no + ".gci";

    // hndl:=file_LoadImageControl(datname, gciname, 1);
    hndl:=file_LoadImageControl("1.dat", "1.gci", 1);

    frames := img_GetWord (hndl, 0, IMAGE_FRAMES);

    for(frame:=0; frame < frames; frame++)
    img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame);
    img_Show(hndl,iVideo1);
    next

    mem_Free(hndl);

    goto label;

    endfunc

    Leave a comment:


  • jmratkos
    replied
    hi again paul,

    I've written the following and it compiles without any errors. I've downloaded it to the display but I cannot get any of the converted movies to play.
    I currently have following files on the 2GB microSD card that is inserted into the display:

    moviecnt.txt file (containing the single value "3" (quotes are not present in the file, just the value 3)
    1.GCI
    1.DAT
    2.GCI
    2.DAT
    3.GCI
    3.DAT
    4.GCI
    4.DAT

    the code is as follows:

    #platform "uLCD-32PTU"

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    #inherit "random_movieConst.inc"

    func main()

    var disk;
    var clipname;
    var counter;
    var frame;
    var hndl;
    var MovieCount;
    var sdFileHandle;


    gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change

    putstr("Mounting...\n");
    if (!(disk:=file_Mount()))
    while (!(disk:=file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif

    gfx_Cls();

    sdFileHandle:=file_Open("moviecnt.txt",'r');

    //read the number of movie clips to randomize from "moviecnt.txt" file
    for (counter:=0;counter<1;counter++)
    file_Read(MovieCount,1,sdFileHandle);
    putstr(MovieCount);
    next
    file_Close(sdFileHandle);

    label:

    gfx_Cls();

    // the following gives us a random value between 1 and the value found in the 'clipcnt.txt' file
    clipname:=ABS(RAND()%MovieCount)+1;

    hndl:=file_LoadImageControl(clipname+".DAT",clipname+".GCI",1);

    for(frame:=0;frame<500;frame++)
    img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame);
    img_Show(hndl,iVideo1);
    next

    mem_Free(hndl);

    goto label;

    repeat
    forever

    endfunc

    Leave a comment:


  • jmratkos
    replied
    thank you paul for your speedy and informative replies. I'll let you know how it works out for us

    Leave a comment:

Working...
X