[Libav-user] Preview video and start recording with exact same stream settings

Audric Ackermann audric.ackermann at gmail.com
Wed Jan 1 12:44:30 EET 2020


And so, how can I copy all the input parameters? To get the same parameters
in the recorded file?

Le mer. 1 janv. 2020 à 21:36, Việt Hùng Nguyễn <hungtrodt5 at gmail.com> a
écrit :

> Yes, exactly!
>
> On Wed, Jan 1, 2020, 17:10 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".
>
> _______________________________________________
> 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".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200101/2b72bc32/attachment.html>


More information about the Libav-user mailing list