[Libav-user] avcodec_send_packet speed

Ivan Lobanov iokunversion0 at gmail.com
Thu Mar 14 15:26:53 EET 2019


I'm using libavcodec libreries for my android app.
To recive/decode/save/play RTSP video stream from cameras.
Everything work well but avcodec_send_packet() working a little bit slow
and cause video delay while try to play 1080p video stream.(no problem when
playing smaller video streams)
is there any way to speed up avcodec_send_packet() execution?
Mayby multithread usage sample? Or something else.
Here is my usage code:

# # # # # #

void * CameraConnection::DecodeVideoStream() {
    AVPacket packet;
    while(av_read_frame(streamFormatContext, &packet) >= 0 || isConnected) {
        //check if frame from video stream
        if(packet.stream_index==videoStreamIdx) { // frame is video
            int errorCode;
            errorCode = avcodec_send_packet(streamVideoCodecContext, &packet);
            if (errorCode < 0) {
                LOGE("Error sending a packet for decoding %s", stderr);
                exit(1);
            }
            while (errorCode >= 0) {
                errorCode =
avcodec_receive_frame(streamVideoCodecContext, decodedFrame);
                if (errorCode == AVERROR(EAGAIN) || errorCode == AVERROR_EOF) {
                    continue;
                } else if (errorCode < 0) {
                    LOGE("Error during decoding %s", stderr);
                    exit(1);
                }
                if(cameraRecord) {
                    cameraRecord->AddPacket(packet);
                }
                if(cameraLiveVideo) {
                    cameraLiveVideo->RenderFrame(&packet, decodedFrame);
                }
            }
        }

        // Free the packet that was allocated by av_read_frame
        av_packet_unref(&packet);
    }
    Disconnect();
    return 0;
}

# # # # # #

Also will be happy if someone explane optimal value for:
reorder_queue_size and buffer_size

P.S. Decoding process running in own thread

-- 
Best regards,
Lobanov Ivan
GDG Perm Leader
Red Distribution
Тел.: +7 961 759 89 71
Skype: ningen-des
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190314/d3786f36/attachment.html>


More information about the Libav-user mailing list