Hi All,
I am trying to transcode a .WMV video file to .MP4 using libavcodec. I have
used the exporter.c code as a basis for my work. The code works and I get a
.MP4 file, but the problem is that when I try to play it back in VLC I get:
"MP4 plugin discarded (no moov box)".
If I use the same code to output to .AVI the video file plays back as
expected.
I am suspecting the following code to be wrong:
AVCodecContext * c = NULL;
AVStream *st = NULL;
st = av_new_stream(this->oc, 0);
if ( st != NULL )
{
c = st->codec;
c->codec_id = (CodecID)codec_id;
c->codec_type = CODEC_TYPE_VIDEO;
/* put sample parameters */
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = width;
c->height = height;
/* time base: this is the fundamental unit of time (in seconds) in
terms
of which frame timestamps are represented. for fixed-fps content,
timebase should be 1/framerate and timestamp increments should be
identically 1. */
c->time_base.den = STREAM_FRAME_RATE;
c->time_base.num = 1;
c->gop_size = 12; /* emit one intra frame every twelve frames at
most */
c->pix_fmt = STREAM_PIX_FMT;
if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
/* just for testing, we also add B frames */
c->max_b_frames = 2;
}
if (c->codec_id == CODEC_ID_MPEG1VIDEO){
/* Needed to avoid using macroblocks in which some coeffs
overflow.
This does not happen with normal video, it just happens here
as
the motion of the chroma plane does not match the luma plane.
*/
c->mb_decision=2;
}
// some formats want stream headers to be separate
if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name,
"mov") || !strcmp(oc->oformat->name, "3gp"))
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
Does anyone have any ideas?
Thanks in advance.
--
Andy Bell
J2K Video Limited
T: +44 (0)20 8133 2473
M: +34 685 130097
E: [email protected]
W: www.j2kvideo.com
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user