I'm using libavdevices for output, and it consistently truncates the last second or so of output. When using other output libraries it doesn't get truncated, so it's definitely my avdevice code, not something upstream.

I assume this means I should be doing something more to ensure things are fully flushed before I close the device. The close code I have is:

    AvDeviceOutput::~AvDeviceOutput () {
        int status = av_write_trailer (context);
        if (status != 0) {
            flogav ("av_write_trailer", status);
        avcodec_close (codec_context.get());
        avformat_free_context (context);

What more should I be doing?

* av_write_trailer is returning 0 (success).
* I think the amount that's cut off is variable, from a fraction of a second to maybe about 1 second, maybe two. * If I add a sleep() before av_write_trailer, the problem goes away--but this doesn't seem like a good solution, and leaves the dilemma of how much. To little, there's audio truncated. To much, I get gaps between tracks.

Platform is Linux, output to ALSA:
Output #0, alsa, to 'Default audio output driver':
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Other than the chopped ending, everything else is working beautifully.

Thanks in advance,


Libav-user mailing list

Reply via email to