[Libav-user] Transcoding mpegts (ts) file to mpegts

Hung Nguyen Hung.Nguyen at ambientdigitalgroup.com
Mon Oct 6 13:22:45 CEST 2014

Just update some information.

The error went away when I fix a bug in function that call encoding function, I forgot to free the pointer.
But the encoded video show up when noisy audio and black screen (no colour, no video frame).
Is there anything else I need to check?


On Oct 6, 2014, at 9:20 AM, Hung Nguyen <Hung.Nguyen at ambientdigitalgroup.com<mailto:Hung.Nguyen at ambientdigitalgroup.com>> wrote:

Dear all,

I’ve been working on a small C application using libav to  transcode mpegts file (change heigh, width, bitrate…).
Source file can be transcoding using ffmpeg command line without problem

But I would like to transcode this video using libav api library to integrate it to our application (nginx).
What I have until now is this source code:


I don’t want to write transcoded result into file, I I use a callback write function to write to output buffer and pass it to AVIOContext:

static int write_adbr_packet(void *opaque, unsigned char *buf, int buf_size) {
    int old_size;
    video_buffer *destination = (video_buffer *) opaque;

    if (destination->data == NULL) {
        destination->data = malloc(memory_pool, 9600 * sizeof (unsigned char));
    old_size = destination->len;
    destination->len += buf_size;
    ngx_memcpy(destination->data + old_size, buf, buf_size * sizeof (unsigned char));
    return buf_size;

When running, my application got coredump:

Back trace: fail at av_interleaved_write_frame

warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff40ffe000
Core was generated by `nginx: worker process                          '.
Program terminated with signal 11, Segmentation fault.
#0  malloc_consolidate (av=av at entry=0x7fa70e2d0740 <main_arena>) at malloc.c:4088
4088    malloc.c: No such file or directory.
(gdb) bt
#0  malloc_consolidate (av=av at entry=0x7fa70e2d0740 <main_arena>) at malloc.c:4088
#1  0x00007fa70df8f7e8 in _int_free (av=0x7fa70e2d0740 <main_arena>, p=0x1fd5e30, have_lock=0) at malloc.c:3994
#2  0x00007fa70eb16f3f in av_buffer_unref () from /usr/local/lib/libavutil.so.54
#3  0x00007fa70ee56124 in av_free_packet () from /usr/local/lib/libavcodec.so.56
#4  0x00007fa710049cea in av_interleaved_write_frame () from /usr/local/lib/libavformat.so.56

Info all register:


I know there must be something wrong with my implement, but I cannot find it for several days.
Could someone please dig in my source code and give me some suggestion, please!



Libav-user mailing list
Libav-user at ffmpeg.org<mailto:Libav-user at ffmpeg.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141006/5964776c/attachment.html>

More information about the Libav-user mailing list