filter/ffmpeg: fill AVFrame::pts

Some libavfilter plugins don't produce any output if `pts` is never
set, e.g. the `lowpass` plugin.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/2114
This commit is contained in:
Max Kellermann
2024-11-02 22:23:25 +01:00
parent 8a5b5378e6
commit b7248f0333
3 changed files with 13 additions and 4 deletions

2
NEWS
View File

@@ -1,6 +1,8 @@
ver 0.23.16 (not yet released)
* database
- fix integer overflows with 64-bit inode numbers
* filter
- ffmpeg: fix for filters producing no output
* support libfmt 11
* support ICU 76

View File

@@ -66,6 +66,9 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
#endif
frame->nb_samples = src.size / in_audio_frame_size;
frame->pts = pts;
pts += frame->nb_samples;
frame.GetBuffer();
memcpy(frame.GetData(0), src.data, src.size);

View File

@@ -17,14 +17,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_FFMPEG_FILTER__HXX
#define MPD_FFMPEG_FILTER__HXX
#pragma once
#include "filter/Filter.hxx"
#include "lib/ffmpeg/Buffer.hxx"
#include "lib/ffmpeg/Filter.hxx"
#include "lib/ffmpeg/Frame.hxx"
#include <cstdint>
/**
* A #Filter implementation using FFmpeg's libavfilter.
*/
@@ -46,6 +47,11 @@ class FfmpegFilter final : public Filter {
const size_t in_audio_frame_size;
const size_t out_audio_frame_size;
/**
* Presentation timestamp. A counter for `AVFrame::pts`.
*/
int_least64_t pts = 0;
public:
/**
* @param _graph a checked and configured AVFilterGraph
@@ -63,5 +69,3 @@ public:
/* virtual methods from class Filter */
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
};
#endif