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:
@@ -66,6 +66,9 @@ FfmpegFilter::FilterPCM(std::span<const std::byte> 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());
|
||||
|
@@ -1,14 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#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.
|
||||
*/
|
||||
@@ -30,6 +31,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;
|
||||
|
||||
bool flushed = false;
|
||||
|
||||
public:
|
||||
@@ -53,5 +59,3 @@ public:
|
||||
private:
|
||||
std::span<const std::byte> ReadOutput();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user