Thread: problem in file merger program

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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.

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, 01: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, 04:49 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM