Opened 2 months ago

#10888 new defect

av_buffersink_set_frame_size does not pad final frame at EOF

Reported by: Andrew Wason Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: buffersink
Cc: Andrew Wason Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
av_buffersink_set_frame_size should always return the specified nb_samples, and zero pad the final frame if needed.
It does not seem to.

Docs for av_buffersink_set_frame_size say:

All calls to av_buffersink_get_buffer_ref will return a buffer with exactly the specified number of samples, or AVERROR(EAGAIN) if there is not enough. The last buffer at EOF will be padded with 0.

(I assume av_buffersink_get_buffer_ref means av_buffersink_get_frame)

https://ffmpeg.org/doxygen/trunk/group__lavfi__buffersink.html#ga359d7d1e42c27ca14c07559d4e9adba7

How to reproduce:
I modified docs/examples/decode_filter_audio.c to use av_buffersink_set_frame_size and print the nb_samples of each frame.
I also had to change it to properly signal EOF to the decoder and filtergraph. It correctly returns 1469 samples for all but the final frame. And that frame contains nonzero data in the unset samples.

% ./decode_filter_audio_g https://streams.videolan.org/streams/wav/welcome.wav
...
frame->pts 104299 frame->nb_samples 1469
frame->pts 105768 frame->nb_samples 1469
frame->pts 107237 frame->nb_samples 1469
frame->pts 108706 frame->nb_samples 254
INCORRECT nb_samples

This is the patch to the example to reproduce (based on ffmpeg git master 194414f62d987ad831654c45fff6ee27898b832e):

https://github.com/rectalogic/FFmpeg/compare/master...rectalogic:FFmpeg:av_buffersink_set_frame_size

Change History (0)

Note: See TracTickets for help on using tickets.