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

Strahinja Radman dr.strashni at gmail.com
Wed Jan 1 11:49:26 EET 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200101/880af464/attachment.html>


More information about the Libav-user mailing list