>Having got_packet set to 0 does not mean it's silent data or that the
>frame was ignored. It means that the encoder does not have a full packet
>to output yet. Vorbis uses a variable frame size. To achieve this, the
>libvorbis encoder takes small audio frames (c->frame_size) and decides
>how best to merge multiple small frames into larger duration packets. So
>each time you send the encoder a frame, you are not necessarily going to
>get a packet back.
>-Justin
Thanks Justin. I finally got webm and mp4 to work in output-example.c. For
anybody who's interested, this is what I did.
In the main interleave loop I had to set audio_pts by multiplying the time for
each audio frame by the frame #. This is for webm/vorbis audio to stream
correctly.
int afw = 0;
double spr = (double) audio_input_frame_size/STREAM_BLOCK_RATE;
for (;;) {
/* Compute current audio and video time. */
if (audio_st)
{
// audio_pts = (double)audio_st->pts.val * audio_st->time_base.num /
audio_st->time_base.den;
audio_pts = afw*spr;
}
else
audio_pts = 0.0;
if (video_st)
video_pts = (double)video_st->pts.val * video_st->time_base.num /
video_st->time_base.den;
else
video_pts = 0.0;
if ((!audio_st || audio_pts >= STREAM_DURATION) &&
(!video_st || video_pts >= STREAM_DURATION))
break;
/* write interleaved audio and video frames */
if (!video_st || (video_st && audio_st && audio_pts < video_pts))
{
write_audio_frame(oc, audio_st);
++afw;
}
else
{
write_video_frame(oc, video_st);
}
}
Before calling avcodec_encode_video I had to set picture->pts to the
frame_count. This is for mp4/libx264 video to write correctly. I have no
idea why this works and suspect it may not be entirely correct. Even avconv
has problems writing mp4. For instance I find that it won't convert webm to
mp4 correctly.
picture->pts = frame_count;
out_size = avcodec_encode_video(c, video_outbuf,
video_outbuf_size, picture);_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api