Hi, I'm using mux.c example to write a file called a.mp4.
In order to do this I need to use the write_packet callback.
So, in the mux.c example file, after the line 566 I have added these lines of 
codes:

*566*
    /* allocate the output media context */
    avformat_alloc_output_context2(&oc, NULL, NULL, filename);
    if (!oc) {
        printf("Could not deduce output format from file extension: using 
MPEG.\n");
        avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
    }
    if (!oc)
        return 1;

*// my code*
pBuffer= (uint8_t*)av_malloc(BUFFERSIZE);
pAVIOContext= avio_alloc_context(pBuffer, BUFFERSIZE, 1, this, nullptr, 
*write_packet*, nullptr);

*// my code*
*oc->pb= pAVIOContext;*

After that I have removed the lines

*599*
    /* open the output file, if needed */
    if (!(fmt->flags & AVFMT_NOFILE)) {
        ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
        if (ret < 0) {
            fprintf(stderr, "Could not open '%s': %s\n", filename,
                    av_err2str(ret));
            return 1;
        }
    }

Now my callback is called but the file produced is different from the one 
produced by avio_open() (without using the callback).
Is my approach correct or have I to use another way in order to use 
write_packet callback?


-- 
+39.347.4070897
http://www.labcsp.com[1] 
http://www.denisgottardello.it[2] 
GMT+1
Skype: mrdebug

--------
[1] http://www.labcsp.com
[2] http://www.denisgottardello.it
_______________________________________________
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to