I wish to write a simple program to join two, identical format, movie
filed together (end to end). In order to do this, I started by creating
a simple piece of code to read in a movie file and simply copy
everything in it into a new output file. I really wanted to avoid
decoding the data and re-encoding it and thought I could simply run
through all the streams identified in the file, copying their configs to
the output configs. Then, read all the packets from all streams, simply
copying them into the output streams.
My file contains the following few lines in its core:
// write the stream header
av_write_header(opFormatCtx);
AVPacket ipPacket;
int64_t ipLastPts = 0;
while(av_read_frame(ipFormatCtx, &ipPacket)>=0)
{
// Write any packet found, straight to the output file
opFormatCtx->oformat->write_packet(opFormatCtx, &ipPacket);
// Free the ipPacket that was allocated by av_read_frame
av_free_packet(&ipPacket);
} // end while reading frames
// write the output file trailer, if any
av_write_trailer(opFormatCtx);
Is this a sensible thing to do (bearing in mind that input and output
formats are intended to be identical)? The output file seems OK when
played in ffplay from the beginning. However, various things behave
differently to the original file. E.g. seeking seems even more
unreliable than normal, and KLV data appears to be grouped differently
in the output file. I thought that simply doing a 1:1 copy of packets
from input to output would result in an identical file?
Gary
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user