OK thanks, that's a good idea. I don't know much but I can basically write the last keyframe to the file and then write the last packets received after pressing record? I mean, between two key frames, all frames are dependent on the key frame only?
How can I check if the keyframe I got is a keyframe? Audric Le mer. 1 janv. 2020 à 22:43, Strahinja Radman <[email protected]> a écrit : > 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 < > [email protected]> 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 <[email protected]> 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 < >>> [email protected]> 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 >>>> [email protected] >>>> https://ffmpeg.org/mailman/listinfo/libav-user >>>> >>>> To unsubscribe, visit link above, or email >>>> [email protected] with subject "unsubscribe". >>> >>> >>> >>> -- >>> >>> Regards >>> Strahinja Radman >>> _______________________________________________ >>> Libav-user mailing list >>> [email protected] >>> https://ffmpeg.org/mailman/listinfo/libav-user >>> >>> To unsubscribe, visit link above, or email >>> [email protected] with subject "unsubscribe". >> >> _______________________________________________ >> Libav-user mailing list >> [email protected] >> https://ffmpeg.org/mailman/listinfo/libav-user >> >> To unsubscribe, visit link above, or email >> [email protected] with subject "unsubscribe". > > > > -- > > Regards > Strahinja Radman > _______________________________________________ > Libav-user mailing list > [email protected] > https://ffmpeg.org/mailman/listinfo/libav-user > > To unsubscribe, visit link above, or email > [email protected] with subject "unsubscribe".
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
