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
https://gist.github.com/whatvn/7e669d295238a009f9d4

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:

https://gist.github.com/whatvn/9ae5678cd5a4090ac469

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@entry=0x7fa70e2d0740 <main_arena>) at 
malloc.c:4088
4088    malloc.c: No such file or directory.
(gdb) bt
#0  malloc_consolidate (av=av@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:

https://gist.github.com/whatvn/6f9a58389a1d6f43848b

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!

Thanks,

Hung






_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to