[Libav-user] ffmpeg read multiple packets and keep them in buffer.
Mohamed-Ismail Mejri
imejri at sabsystem.com
Wed Jan 25 12:30:31 EET 2017
Hi,
I think my problem isn't clear, I explain it in another way:
It's possible to use av_read_frame() to read some packets and after
finishing, I use av_read_frame() to have the same packets another time
(like as I reinsert those packets in the beginning of the buffer or I
didn't read it at all)?
Best regards,
Ismail MEJRI.
> Hi,
>
> I want to decode same packets before send it to the player, because
> avformat_find_stream_info() take long time to scan, I want to replace
> it by a simple function, but now I am losing the decoded packets after
> this function and this make the player take time to show the first
> picture. So, how I can read multiple packets in ffmpeg without
> deleting it after "av_packet_unref()"?
> In otherwise how I can repointing to the first packet decoded after
> terminate scanning with this function.
> Or if you have any another idea to speed up the scan process?
>
> my function:
>
> found=av_read_frame(m_pFormatContext,&pkt1);
> if (found == AVERROR(EAGAIN))
> {
> Close();
> return false;
> }
> pkt = &pkt1;
> str = m_pFormatContext->streams[pkt->stream_index];
> if (str->codec->codec_type == AVMEDIA_TYPE_VIDEO && testv < 2) {
> gotFrame = 0;
> frame = av_frame_alloc();
> m_codec=avcodec_find_decoder(str->codec->codec_id);
> str->codec=avcodec_alloc_context3(m_codec);
> if (avcodec_open2(str->codec, m_codec, NULL) >= 0) {
> fine = avcodec_decode_video2(str->codec, frame, &gotFrame,
> pkt);
> if (fine >= 0)
> {
> testv = testv + gotFrame + 1;
> }
> av_frame_free(&frame);
> }
> }
>
> Reply to me if you need more information.
> I hope what I have requested is possible.
> Best regards,
> Ismail MEJRI.
More information about the Libav-user
mailing list