problem in file merger program

This is a discussion on problem in file merger program within the C Programming forums, part of the General Programming Boards category; hi friends, I've coded a file merging program in C. though, the program seems to work far upto as how ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    37

    problem in file merger program

    hi friends,

    I've coded a file merging program in C. though, the program seems to work far upto as how it supposed to but there is a problem.
    when i tried to merge few media files to make it a whole in one then i got its size desirable equal to the sum of all ones though but I didn't get it played anyway.

    Code:
     #include<stdio.h>
    #include<string.h>
    
    char buffer[BUFSIZ];
    main()
     {
          FILE *fsource,*fdest; char dirpath[30],sourcepath[40],destpath[40];
          int files=0,count;
          clrscr();
    
          printf("enter the full path of directory the content of which is to merge\n");
          gets(dirpath);
    
          printf("\nenter the number of files stored in this directory");
          scanf("\n&#37;d",&files);
          strcpy(destpath,dirpath);
          strncat(destpath,"movie.flv",9);
    
          fdest=fopen(destpath,"wb+");
          setvbuf(fdest,buffer,_IOFBF,BUFSIZ);
          fseek(fdest,0L,1);
          
    
          for(count=1;count<=files;count++)
    	{
    	  sprintf(sourcepath,"%s%d%s",dirpath,count,".flv");
    
    	  fsource=fopen(sourcepath,"rb+");
    	  fseek(fsource,0L,1);
    	  setvbuf(fsource,buffer,_IOFBF,BUFSIZ);
    	  printf("\npart %d is being processed",count);
    
    	  while(fread(buffer,BUFSIZ,1,fsource))
    	    {
    	       fseek(fsource,BUFSIZ,1);
    	       fwrite(buffer,BUFSIZ,1,fdest) ;	       
    
    	       fseek(fdest,BUFSIZ,1);
    	    }
    	   printf("\npart %d is processed",count);
    	}
    
    
     }
    please someone nail out the problem

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Maybe the media files have some header. So merging everything with the headers wouldn't make you a valid media file, since you would need one header and only the data for the rest

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    37
    how can i fix this?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by san_crazy View Post
    how can i fix this?
    By understanding the underlaying meta-data (file-headers, key-frames, sub-frames, etc, etc) and then processing the input files accordingly. That's in a single sentence saying something that can easily reach 1000s of lines of code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    37
    hey friends, I googled a lot to know how to set the headers but couldn't found the exact match. how can i know how many bytes long the header informations is upto?

    please suggest me how can i go up on this header problem.
    Last edited by san_crazy; 07-09-2008 at 07:30 AM.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I have no idea how to merge flash video's. I presume the flv file contains a flash proprietary header, then subheaders within the packet. This page gives an (incomplete) simple description:
    http://discount77.com/blog/ospace/at...1101432517.pdf

    Note, it's easy to say in overview how to do this, but unless you have LOTS of experience in programming, you will probably struggle to perform this task.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Don't know what the flash header contains, but note that you may have to change the main header, since the body will be changed by adding more information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Creating File for File Processing
    By Dampecram in forum C Programming
    Replies: 2
    Last Post: 12-07-2008, 12:26 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Straight Insertion Sort function problem
    By StaticKyle in forum C++ Programming
    Replies: 6
    Last Post: 05-12-2008, 04:03 AM
  4. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 03:49 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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