Like Tree8Likes

I am a very new C student; I want to your help in creating "random video sequence sw"

This is a discussion on I am a very new C student; I want to your help in creating "random video sequence sw" within the C Programming forums, part of the General Programming Boards category; I want to take these clips, have clip one as the beginning and clip 27 as the ending, but the ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    229

    I am a very new C student; I want to your help in creating "random video sequence sw"

    I want to take these clips, have clip one as the beginning and clip 27 as the ending, but the clips inbetween varied.
    I want to vary the clips 2 to 26 so they play in a special random order.

    That special random order is based on boolean true false statement, like this;

    Code:
    int main()
    { int one, two, three;
    one=1;
    two=2;
    three=3;
    if((two<=three)&&(three>=1));
    play clip two;
    else play clip 3;
    variable name is one.
    variable name value is 1.
    How do I add the number of frames in the clip to variable name value?
    The clips would have to have these numbers from the number of frames to make the clips have the values; greater than, equal to, or less than.
    What gives the clips special values is total frame numbers in the clips, but I don't know how to add that to the variable name value.

    So I want you to do two things for me:
    1.) add frame number values to the variable name's number. Right now I have one=1, two=2, but it could be, one=("clip has this many frames:")
    2.) make the clips play in the order I specified: one is the beginning of the video sequence, two is the last clip in the video sequence, join these beginning and ending clips is clips 2 to 26.
    3.) Could you do write your answer in C not C++? I'm learning C and this would help me more than you can imagine.


    Here is the code I have so far:

    Code:
    loadplugin("C:\Program Files\AviSynth 2.5\plugins\DirectShowSource.dll")
    
    one=directshowsource("C:\clips\1.mp4", audio=false, 23.976)
    two=directshowsource("C:\clips\2.mp4", audio=false, 23.976)
    three=directshowsource("C:\clips\3.mp4", audio=false, 23.976)
    four=directshowsource("C:\clips\4.mp4", audio=false, 23.976)
    five=directshowsource("C:\clips\5.mp4", audio=false, 23.976)
    six=directshowsource("C:\clips\6.mp4", audio=false, 23.976)
    seven=directshowsource("C:\clips\7.mp4", audio=false, 23.976)
    eight=directshowsource("C:\clips\8.mp4", audio=false, 23.976)
    nine=directshowsource("C:\clips\9.mp4", audio=false, 23.976)
    ten=directshowsource("C:\clips\10.mp4", audio=false, 23.976)
    eleven=directshowsource("C:\clips\11.mp4", audio=false, 23.976)
    twelve=directshowsource("C:\clips\12.mp4", audio=false, 23.976)
    thirteen=directshowsource("C:\clips\13.mp4", audio=false, 23.976)
    fourteen=directshowsource("C:\clips\14.mp4", audio=false, 23.976)
    fifteen=directshowsource("C:\clips\15.mp4", audio=false, 23.976)
    sixteen=directshowsource("C:\clips\16.mp4", audio=false, 23.976)
    seventeen=directshowsource("C:\clips\17.mp4", audio=false, 23.976)
    eighteen=directshowsource("C:\clips\18.mp4", audio=false, 23.976)
    nineteen=directshowsource("C:\clips\19.mp4", audio=false, 23.976)
    twenty=directshowsource("C:\clips\20.mp4", audio=false, 23.976)
    twenty_one=directshowsource("C:\clips\21.mp4", audio=false, 23.976)
    twenty_two=directshowsource("C:\clips\22.mp4", audio=false, 23.976)
    twenty_three=directshowsource("C:\clips\23.mp4", audio=false, 23.976)
    twenty_four=directshowsource("C:\clips\24.mp4", audio=false, 23.976)
    twenty_five=directshowsource("C:\clips\25.mp4", audio=false, 23.976)
    twenty_six=directshowsource("C:\clips\26.mp4", audio=false, 23.976)
    twenty_seven=directshowsource("C:\clips\27.mp4", audio=false, 23.976)
    
    #include <stdio.h>
    
    int main()
    {   int one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eigthteen, nineteen, twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five, twenty_six, twenty_seven;
    one=1;
    two=2;
    three=3;
    four=4;
    five=5;
    six=6;
    seven=7;
    eight=8;
    nine=9;
    ten=10;
    eleven=11;
    twelve=12;
    thirteen=13;
    fourteen=14;
    fifteen=15;
    sixteen=16;
    seventeen=17;
    eighteen=18;
    nineteen=19;
    twenty=20;
    twenty_one=21;
    twenty_two=22;
    twenty_three=23;
    twenty_four=24;
    twenty_five=25;
    twenty_six=26;
    twenty_seven=27;
    }
    
    converttoyv12()
    I need to know what C code to put into my program to do what I want. I know I want the clips to have values, but that question on how to put the frame number into the code is not what I came to this forum for. I only want to know what the code would look like on a most basic level then I can take that and build it up into a functioning program. I want to know what the code uses to do this: pointers, or loops, or printf or scanf, or rand; something to poin me in the direction of how to build what I want.

    The video source is from youtube videos. I dl them using realplayer and then I use megui to chop up the clips into chunks at scene changes. This source is then fed into the program as variables with the number of the variable matching the number of the chunk. So it's all legal.

  2. #2
    Registered User
    Join Date
    Apr 2011
    Location
    Las Vegas
    Posts
    66
    I'm not completely sure what you're trying to do, but it seems like using an array of structures might accommodate your needs given your naming convention. Perhaps something like:
    Code:
    #include <stdio.h>
    
    typedef struct movie {
        int audio;
        double fps;
    } Movie;
    
    int main( void )
    {
        Movie movies[28];
        int   i;
    
        /* initialize all the movies in the array */
        for ( i = 1; i < 28; ++i ) {
            /* the name of the movie file corresponds to the array element 
             * e.g. movie "5.mp4" is movies[5], movie "6.mp4" is movies[6]...
             */
            movies[i].audio = 0;
            movies[i].fps   = 23.976;
        }
    
        return 0;
    }

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Thank you for the quick reply. I edited your code and made this:

    Code:
    #include <stdio.h>
    
    typedef struct movie {
        int audio;
        double fps;
    } Movie;
    
    int main( void )
    {
        Movie movies[27];
        int one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five, twenty_six, twenty_seven;
    
    one=1;
    two=2;
    three=3;
    four=4;
    five=5;
    six=6;
    seven=7;
    eight=8;
    nine=9;
    ten=10;
    eleven=11;
    twelve=12;
    thirteen=13;
    fourteen=14;
    fifteen=15;
    sixteen=16;
    seventeen=17;
    eighteen=18;
    nineteen=19;
    twenty=20;
    twenty_one=21;
    twenty_two=22;
    twenty_three=23;
    twenty_four=24;
    twenty_five=25;
    twenty_six=26;
    twenty_seven=27;
    
        /* initialize all the movies in the array */
        for ( one = 1; one <= twenty_seven; ++one ) {
            /* the name of the movie file corresponds to the array element 
             * e.g. movie "5.mp4" is movies[5], movie "6.mp4" is movies[6]...
             */
            movies[one].audio = 0;
            movies[one].fps   = 23.976;
        }
    
        return 0;
    }
    However I don't know how to load the video clips into the exe I compile? Can you show me how to load the mp4 video clips into the code so when I run the exe the video clips start to play in wmp?

  4. #4
    Registered User
    Join Date
    Apr 2011
    Location
    Las Vegas
    Posts
    66
    Sorry, you'll need to get someone who works with Windows to help you beyond this stage. I'm a *nix guy...

    Good luck!

    Kevin

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    You might consider actually learning the language before jumping into something like this. This code
    Code:
    int one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eigthteen, nineteen, twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five, twenty_six, twenty_seven;
    one=1;
    two=2;
    three=3;
    four=4;
    five=5;
    six=6;
    seven=7;
    eight=8;
    nine=9;
    ten=10;
    eleven=11;
    twelve=12;
    thirteen=13;
    fourteen=14;
    fifteen=15;
    sixteen=16;
    seventeen=17;
    eighteen=18;
    nineteen=19;
    twenty=20;
    twenty_one=21;
    twenty_two=22;
    twenty_three=23;
    twenty_four=24;
    twenty_five=25;
    twenty_six=26;
    twenty_seven=27;
    makes my eyes bleed.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Jeremy... being a new C student you need to settle down and do the course books page by page and work with the examples as given.

    I see this here all the time... somebody gets "hello world" to work and they figure they're ready to write network applications or rock the world with the latest multimedia wondertoy or pull some wild hacker thing... Most often they end up "bug on windshield" as their exuberance trips them up time and again.

    With diligence --and a little patience-- you might be able to successfully write a program like this in 3 to 6 months.

  7. #7
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Could you please check this code I made? It uses the help of kmess's template, from his previous answer.

    Code:
    #include <stdio.h>
    
    typedef struct movie {
        int audio;
        double fps;
    } Movie;
    
    int main( void )
    {
        Movie movies[27];
        int one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five, twenty_six, twenty_seven;
    
    one=1;
    two=2;
    three=3;
    four=4;
    five=5;
    six=6;
    seven=7;
    eight=8;
    nine=9;
    ten=10;
    eleven=11;
    twelve=12;
    thirteen=13;
    fourteen=14;
    fifteen=15;
    sixteen=16;
    seventeen=17;
    eighteen=18;
    nineteen=19;
    twenty=20;
    twenty_one=21;
    twenty_two=22;
    twenty_three=23;
    twenty_four=24;
    twenty_five=25;
    twenty_six=26;
    twenty_seven=27;
    
    for ( one = 1; one <= twenty_seven; ++one ) if((two<=three)&&(three>=one)) movies[two]=movies[one]; else movies[two]=movies[two];
    for ( one = 1; one <= twenty_seven; ++one ) if((three<=four)&&(four>=two)) movies[three]=movies[two]; else movies[three]=movies[three];
    for ( one = 1; one <= twenty_seven; ++one ) if((four<=five)&&(five>=three)) movies[four]=movies[three]; else movies[four]=movies[four];
    for ( one = 1; one <= twenty_seven; ++one ) if((five<=six)&&(six>=four)) movies[five]=movies[four]; else movies[five]=movies[five];
    for ( one = 1; one <= twenty_seven; ++one ) if((six<=seven)&&(seven>=five)) movies[six]=movies[five]; else movies[six]=movies[six];
    for ( one = 1; one <= twenty_seven; ++one ) if((seven<=eight)&&(eight>=six)) movies[seven]=movies[six]; else movies[seven]=movies[seven];
    for ( one = 1; one <= twenty_seven; ++one ) if((eight<=nine)&&(nine>=seven)) movies[eight]=movies[seven]; else movies[eight]=movies[eight];
    for ( one = 1; one <= twenty_seven; ++one ) if((nine<=ten)&&(ten>=eight)) movies[nine]=movies[eight]; else movies[nine]=movies[nine];
    for ( one = 1; one <= twenty_seven; ++one ) if((ten<=eleven)&&(eleven>=nine)) movies[ten]=movies[nine]; else movies[ten]=movies[ten];
    for ( one = 1; one <= twenty_seven; ++one ) if((eleven<=twelve)&&(twelve>=ten)) movies[eleven]=movies[ten]; else movies[eleven]=movies[eleven];
    for ( one = 1; one <= twenty_seven; ++one ) if((twelve<=thirteen)&&(thirteen>=eleven)) movies[twelve]=movies[eleven]; else movies[twelve]=movies[twelve];
    for ( one = 1; one <= twenty_seven; ++one ) if((thirteen<=fourteen)&&(fourteen>=twelve)) movies[thirteen]=movies[twelve]; else movies[thirteen]=movies[thirteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((fourteen<=fifteen)&&(fifteen>=thirteen)) movies[fourteen]=movies[thirteen]; else movies[fourteen]=movies[fourteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((fifteen<=sixteen)&&(sixteen>=fourteen)) movies[fifteen]=movies[fourteen]; else movies[fifteen]=movies[fifteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((sixteen<=seventeen)&&(seventeen>=fifteen)) movies[sixteen]=movies[fifteen]; else movies[sixteen]=movies[sixteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((seventeen<=eighteen)&&(eighteen>=sixteen)) movies[seventeen]=movies[sixteen]; else movies[seventeen]=movies[seventeen];
    for ( one = 1; one <= twenty_seven; ++one ) if((eighteen<=nineteen)&&(nineteen>=seventeen)) movies[eighteen]=movies[seventeen]; else movies[eighteen]=movies[eighteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((nineteen<=twenty)&&(twenty>=eighteen)) movies[nineteen]=movies[eighteen]; else movies[nineteen]=movies[nineteen];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty<=twenty_one)&&(twenty_one>=nineteen)) movies[twenty]=movies[nineteen]; else movies[twenty]=movies[twenty];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_one<=twenty_two)&&(twenty_two>=twenty)) movies[twenty_one]=movies[twenty]; else movies[twenty_one]=movies[twenty_one];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_two<=twenty_three)&&(twenty_three>=twenty_one)) movies[twenty_two]=movies[twenty_one]; else movies[twenty_two]=movies[twenty_two];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_three<=twenty_four)&&(twenty_four>=twenty_two)) movies[twenty_three]=movies[twenty_two]; else movies[twenty_three]=movies[twenty_three];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_four<=twenty_five)&&(twenty_five>=twenty_three)) movies[twenty_four]=movies[twenty_three]; else movies[twenty_four]=movies[twenty_four];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_five<=twenty_six)&&(twenty_six>=twenty_four)) movies[twenty_five]=movies[twenty_four]; else movies[twenty_five]=movies[twenty_five];
    for ( one = 1; one <= twenty_seven; ++one ) if((twenty_six<=twenty_seven)&&(twenty_seven>=twenty_five)) movies[twenty_six]=movies[twenty_five]; else movies[twenty_six]=movies[twenty_six];
    
    for ( one = 1; one <= twenty_seven; ++one ) {
            /* the name of the movie file corresponds to the array element 
             * e.g. movie "5.mp4" is movies[5], movie "6.mp4" is movies[6]...
             */
            movies[one].audio = 0;
            movies[one].fps   = 23.976;
        }
    
        return 0;
    }

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Nope. Still doesn't stand a chance of working.

    Learn now... play later.
    Last edited by CommonTater; 04-25-2011 at 12:25 PM.

  9. #9
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,438
    Really, no offense intended here, but your code is atrocious. Nobody wants to help with it because you're in over your head, and we don't want to spend the next 80 posts trying to teach you about arrays in C. You need to start at the very beginning and master the basics before you tackle this. Read your course notes and textbooks. Read the tutorials we have here and Google for some more. You're ambition is admirable and I really don't want to discourage you, but to do this right and to get anything out of it, you need to back up a bit.

    You will probably need to master the following topics before you can tackle this problem in any reasonable way:
    • Structures
    • Arrays
    • Loops
    • File handling


    You should learn to format your code better. For some reason, newbies seem to think that the fewer semicolons and new lines they use, the better their code is. This is not the case. Good code is first and foremost, clean and readable. That means decent style and indentation, obvious variable names, etc. Defining a variable like twenty_six, whose value is 26 and never changes is silly. Code like "if (five >= three)" is really confusing. Define one constant for the number of frames you have (27), and write code relative to that constant. You should probably read in a sequence of number from the user or a file, that dictate what order to play the frames in. Then, you can use those numbers as an index into your array of 27 frames. This could be done in one or two loops instead of 27.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by anduril462 View Post
    You will probably need to master the following topics before you can tackle this problem in any reasonable way:
    • Structures
    • Arrays
    • Loops
    • File handling
    • Multimedia playback(He's talking about mp4 files... movies)


    That's the one that's going to be his biggest problem... Playing multimedia files in Windows is NOT simple code and, from what I've seen, even more complex in linux...
    Last edited by CommonTater; 04-25-2011 at 12:50 PM.

  11. #11
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Somebody wrote how to do this in a different thread in a different forum. I'm not sure what it means so I'm going to read it during my time learning the C language. But for your benefit I will post this here so you can see how to do what I asked your help for. Tell me what you think about it Commontater. Remember this is within Avisynth, so some terms may be only used in that language library, but here you go:

    bad code removed.
    Last edited by jeremy duncan; 04-26-2011 at 03:27 PM.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Hate to break it to you Jeremy, but that's not C language source code...

    Seriously... nobody's yanking your chain here. You have been given some of the very best advice a programmer can get. As several of us have said, you need to set this aside, learn the C language properly by studying your books, doing the exercises and, yes, asking questions here when you run into problems... You need to take that advice seriously.

    Good luck in your studies...
    Last edited by CommonTater; 04-25-2011 at 04:59 PM.

  13. #13
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    CommonTater,

    Looks Like I'm going to have to learn C++ too then...But what about the code, what's your opinion on it is what interests me now.

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by jeremy duncan View Post
    CommonTater,

    Looks Like I'm going to have to learn C++ too then...But what about the code, what's your opinion on it is what interests me now.
    That's not C++ either... might be C# or some crossplatform variant... but it's not C or C++.

    The truth? I don't think I even understand what you are trying to do and I certainly don't understand why this is so important that you would give it so much priority in your learning experience. I don't care which language(s) you end up learning but putting yourself through so much over a short list of shuffle played movies doesn't make any sense at all.

    You should consider either a) Learning programming because you want to be a programmer or b) finding someone to write the code for you.
    As "first projects" go this one's a real stinker.

  15. #15
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Wow, that's not even C++ then?! I will take your advice and learn C before taking projects like this. Thank you. I have highlighted the;
    •Structures
    •Arrays
    •Loops
    part of my text, so I can learn that first before moving on to libraries and pointers. I don't have a multimedia part in my textbook, or filehandling. It's the guide over at "howstuffworks.com" C course.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 07:25 AM
  2. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 06:59 AM
  3. Replies: 3
    Last Post: 01-14-2002, 04:09 PM
  4. escape sequence "\ooo" and "\xhhh"
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2001, 08:30 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21