Dear all I find ffmpeg a wonderful tool for working with video.
Now, I want to step into the code and write some programs my self as a
learning process.
My first idea is to have a number of modified ffplay programs running
and depending on what instance of the program I select that programs
input should be copied to an output file that is shared by all instances.
If I have two instances running, both feed from a live video stream,
camera 1 and camera 2, I will have the option to capture either camera 1
or camera 2.
I start out with just one instance of ffplay and even with that I am not
able to pass the input to an output file! When I look at ffplay there is a line where packages are read: ret = av_read_frame(ic, pkt); Now, right after that line I insert my own function, so now I have:
   ret = av_read_frame(ic, pkt);
write_frame(ic, is, pkt); // tps - new function
I want to write my function, write_frame(), so that first time it is called
an AVFormatContext for the output is set up and then for each call the
package is copied to the output file. If I can set it up so that no
conversion is performed I will do that - just copy.
The problem I have is that I am not even able to set up the
AVFormatContext for the output - I keep getting errors when I open the
codec for the output. I already have an AVFormatContext for the input - that is set up by ffplay. I think (!) the data structures I have to concentrate on in order to create an AVFormatContext for the output file are: AVFormatContext *oc AVFormatFormat * oformat char filename [1024] AVStream * streams[MAX_STREAMS] AVCodecContext * codec AVCodec * codec 1. Allocate space for the output AVFormatContext - I use avformat_alloc_context();
2.      Set the oformat. I use guess_format(NULL, "outputtest.mpg", NULL);
3. Set for output filename. I use snprintf(oc->filename, sizeof(oc->filename), "%s", "outputtest.mpg"); 4. For each stream in the input AVFormatContext I create a corresponding stream in the output AVFormatContext 5. Open each codec in each stream in the output AVFormatContext Once the AVFormatContext for the output file has been created I guess I have to call av_interleaved_write_frame() with the output AVFormatContext and the packet read from the input file. Am I on the right track? Can anybody give hints on how to set up the output AVFormatContext? Any help would be appreciated. Thanks
Thomas S
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to