[FFmpeg-trac] #10888(avfilter:new): av_buffersink_set_frame_size does not pad final frame at EOF
FFmpeg
trac at avcodec.org
Fri Mar 1 00:36:57 EET 2024
#10888: av_buffersink_set_frame_size does not pad final frame at EOF
-------------------------------------+-------------------------------------
Reporter: Andrew | Type: defect
Wason |
Status: new | Priority: normal
Component: avfilter | Version: git-
| master
Keywords: buffersink | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
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
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10888>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list