As a thank you to all of the free software posts, here is one.
There have been several requests to be able to display multiple mpeg files so I whipped this little utility together.
Documentation.
This is a simple filter that will permit concatenating several mpg files together for viewing. You simply list the ones you want on the command line. It turns out that the mpeg_play command released by berkeley will accept input form standard in so the output of this utility can be piped directly in. If your viewer won't work that way then you will need to send the output of mpg_cat to a file and then read it in separately. It works by stripping the trailer information from the files so that the viewer
will continue to read the file. It then adds a trailer at the end of the last file.
This program may be useful for adding a trailer to a file that is missing one. It could also be used to view a file that had a missing header so long as another file listed earlier had one that matched the width and height of the desired file.
There is very simple minded support for standard in as well so you could feed
this program from yet another filter.
Limitations:
Some mpg files have information ahead of the header line. This program will not work with these files except for the first one. It could be modified easily to remove this extra stuff but then it would require a header line for every file. Perhaps I could add this if needed, or since you have the source you can fix it yourself. This program will remove any extra data after the trailer data.
This program is smart enough to reject files that have different widths from the first file since these don't merge very well. It does not check the height of the file but could be modified to do so, of course. If the height of a file in the list is less than the first file then everything will probably be ok but if it is taller then you will have trouble.
There is no warranty, of course. Enjoy.
----Cut here for source-----------
/*
mpeg_cat.c
This program behaves like a cat commmand and concatenates input files
together. It removes the mpg trailer on all but the last entry. Output
goes to standard out. Try mpg_cat *.mpg | mpeg_play.
It will ignore mpg files that have a different width than the original file
since the berkely viewer doesn't permit changing the width of the picture in the middle of viewing it.
by Dale DePriest.
*/
#include <stdio.h>
main( argc, argv )
int argc;
char **argv;
{
register int c;
int i;
int width = 0;
FILE *fp;
for( i = 1; i < argc; i++ )
{
if ( ( fp = fopen( argv[i], "r" ) ) == NULL ) {
fprintf( stderr, "can't open: %s,\n", argv[i] );
continue;
}
top:
/* Look for header and trailer sequences. Use header to check
* for movie width and strip trailer from input file.
*/
while ( ( c = getc( fp ) ) != EOF ) {
putchar (c);
if ( c != 0x00 )
continue;
if ( ( c = getc( fp ) ) != 0x00 ) {
putchar (c);
continue;
}
while ((c = getc( fp )) == 0x00) putchar (c);
if ( c != 0x01 ) {
putchar (0x00) ; putchar (c);
continue;
}
/* 0xb3 starts the header sequence. width follows */