On 04/24/2012 11:29 AM, Jake Alley wrote: >>> >>> Has anybody tried output-example.c lately? > >>I did, I'll try again soon. Exactly what are you doing with it? > > I believe the issue with output-example.c is that it assumes certain > codec format parameters. For instance vorbis needs AV_SAMPLE_FMT_FLT > instead of S16. That's one issue right away that will make it not work > with webm. > > // c->sample_fmt = AV_SAMPLE_FMT_S16; > c->sample_fmt = AV_SAMPLE_FMT_FLT; > c->bit_rate = 64000; > c->sample_rate = 44100; > c->channels = 2; > > That gets me past avcodec_open2, but there are still issues with writing > audio. The following returns 0 for no error, but never fills got_packet > with a true value. I'm wondering if there's an issue of returning > before incrementing the stream when got_packet is zero. If the codec > ignores the packet because of silent data, shouldn't it still increment > the stream? > > e = avcodec_encode_audio2(c, &pkt, frame, &got_packet); > if (!got_packet) > return; > pkt.stream_index = st->index;
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 _______________________________________________ libav-api mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-api
