[Libav-user] Preview video and start recording with exact same stream settings
Strahinja Radman
dr.strashni at gmail.com
Wed Jan 1 13:43:04 EET 2020
Well, you can do this. Keep last N number of packets in a buffer, where N
is guaranteed to contain keyframe packet. When you encounter new keyframe
packet
you can free the packets that are not needed anymore. When someone starts
to record, you can mux from the last known key frame packet.
On Wed, Jan 1, 2020 at 11:10 AM Audric Ackermann <audric.ackermann at gmail.com>
wrote:
> But if I want to avoid missing the first few frames which are not a key
> frame, I have to reencode the data, so the first frame recorded is a key
> frame, right?
>
> Le mer. 1 janv. 2020 à 20:49, Strahinja Radman <dr.strashni at gmail.com> a
> écrit :
>
>> If you only want to copy the input, there is no need to transcode. You
>> can simply duplicate the input packets, one packet goes to the decoder so
>> it can be shown, the other
>> goes to the muxer for the recorder when someone presses the record
>> button. You can save to whatever format you want but input may not be
>> playable from the start until
>> it reaches the key frame. Deep packet copy can be achieved with the
>> following code:
>>
>> AVPacket packet;
>> av_init_packet(&packet);
>> av_packet_ref(packet, src);
>> av_packet_make_writable(&packet);
>>
>> You can based on the decoded frames, mark a key frame packet and start
>> saving from there.
>>
>> On Wed, Jan 1, 2020 at 10:06 AM Audric Ackermann <
>> audric.ackermann at gmail.com> wrote:
>>
>>> Ok thank you.
>>> As I do not control the input parameters I will go for the transcode
>>> option. Is there an easy way to duplicate all required decoder parameters
>>> to the encoder?
>>>
>>> Like doing this, but with all important params in one step:
>>>
>>> Thanks
>>>
>>> outst->codec->width = this->codec_ctx->width;
>>> outst->codec->height = this->codec_ctx->height;
>>> outst->codec->pix_fmt = this->codec_ctx->pix_fmt;
>>> outst->codec->time_base = this->codec_ctx->time_base;
>>> _______________________________________________
>>> 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".
>>
>>
>>
>> --
>>
>> Regards
>> Strahinja Radman
>> _______________________________________________
>> 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".
--
Regards
Strahinja Radman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200101/6359f242/attachment.html>
More information about the Libav-user
mailing list