I suggest you started with my code as a sample. That code assumes there's only one substream, namely video. You should make avformat_new_stream() in a loop (AVFormatContext*)input_ctx->nb_streams times. -- Andrey Utkin