[Libav-user] How to foce h264 encoder to duplicate the same frame into the stream?
Gustav González
xtingray at gmail.com
Thu May 26 17:31:36 EEST 2022
Let's talk about the usual workflow of any video manipulation process:
1. Somehow, you get AVFrame objects either from a previous video file or
from a camera
2. Then you encode them, transcode them, or whatever you need to do
3. Finally you save those AVFrames into a new video file or you use a
stream to transmit them
In general terms, you start dealing with AVFrame records, but at the moment
of storing them, you need to use AVPacket structures.
My suggestion was: if you need to save a copy of the previous AVFrame item
because you have to save or transmit it again, why not save a copy of the
previous AVPacket directly?
Anyway, it would be great if you can share the context of your workflow to
have a better perspective of the problem. Good luck!
On Wed, May 25, 2022 at 2:26 AM Aleksei Komarov <abkomarov at gmail.com> wrote:
> Thanks, but the AVFrame is not encoded data. Maybe your idea was to copy
> the packet data? Than I`ll have to increment dts/pts counters manually in
> this case... I don't know how...
>
> ср, 11 мая 2022 г. в 15:03, Gustav González <xtingray at gmail.com>:
>
>> On Wed, May 11, 2022 at 6:24 AM Aleksei Komarov <abkomarov at gmail.com>
>> wrote:
>>
>>> Hi,
>>> I'm encoding VFR frame sequence to Constant Frame Rate output stream (in
>>> real-time)
>>> E.g. to maintain 60 fps I have to DUPLICATE frames from 30 fps stream
>>> (or any VFR video streams).
>>> To do this I`m copying the same frame binary data and feed it to
>>> avcodec_receive_packet() once again. (It works but is not optimal)
>>> What is the proper way to tell the encoder that the new frame is the
>>> same as the last one besides timestamp data (PTS/DTS). In other words how
>>> to duplicate last frame in the stream without reencoding the frame again?
>>> I've seen this type of video ( generated by OBS ) where MANY frames
>>> were really duplicated, where pkt_size=48 or lower!
>>>
>>
>> I'm just shooting in the dark, but what if you don't focus on the AVFrame
>> data but on saving a copy of the AVPacket of the previous frame after it is
>> encoded? In that way, you could avoid calling the whole encoding process
>> again. Just guessing.
>>
>> --
>> Gustav Gonzalez
>> xtingray at gmail.com
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>
>
>
> --
> С уважением Алексей Комаров.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
--
--
Gustav Gonzalez
xtingray at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220526/98055bb5/attachment.htm>
More information about the Libav-user
mailing list