[FFmpeg-devel] [PATCH] lavc/mfenc: set output packet duration

James Almer jamrial at gmail.com
Thu Aug 14 17:14:37 EEST 2025


On 8/13/2025 8:39 PM, Pavel Koshevoy wrote:
> On Tue, Aug 12, 2025 at 7:59 AM James Almer <jamrial at gmail.com> wrote:
> 
>> On 8/4/2025 4:50 PM, Pavel Koshevoy wrote:
>>> ---
>>>    libavcodec/mfenc.c | 10 ++++++++++
>>>    1 file changed, 10 insertions(+)
>>>
>>> diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
>>> index 30531fe3e8..942c75cb9d 100644
>>> --- a/libavcodec/mfenc.c
>>> +++ b/libavcodec/mfenc.c
>>> @@ -148,6 +148,15 @@ static int64_t mf_sample_get_pts(AVCodecContext
>> *avctx, IMFSample *sample)
>>>        return mf_from_mf_time(avctx, pts);
>>>    }
>>>
>>> +static int64_t mf_sample_get_duration(AVCodecContext *avctx, IMFSample
>> *sample)
>>> +{
>>> +    LONGLONG duration;
>>> +    HRESULT hr = IMFSample_GetSampleDuration(sample, &duration);
>>> +    if (FAILED(hr))
>>> +        return 0;
>>> +    return mf_from_mf_time(avctx, duration);
>>> +}
>>> +
>>>    static int mf_enca_output_type_get(AVCodecContext *avctx, IMFMediaType
>> *type)
>>>    {
>>>        MFContext *c = avctx->priv_data;
>>> @@ -275,6 +284,7 @@ static int mf_sample_to_avpacket(AVCodecContext
>> *avctx, IMFSample *sample, AVPac
>>>        IMFMediaBuffer_Release(buffer);
>>>
>>>        avpkt->pts = avpkt->dts = mf_sample_get_pts(avctx, sample);
>>> +    avpkt->duration = mf_sample_get_duration(avctx, sample);
>>>
>>>        hr = IMFAttributes_GetUINT32(sample,
>> &MFSampleExtension_CleanPoint, &t32);
>>>        if (c->is_audio || (!FAILED(hr) && t32 != 0))
>>
>> Will apply.
>>
> 
> 
> I just checked, and it's not applied.  Any idea when it will be applied?

Just pushed it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250814/150bbea7/attachment.sig>


More information about the ffmpeg-devel mailing list