[libav-api] "Incorrect" End of file on RTMP Stream.

Roman Savchenko gmstima at gmail.com
Fri Apr 18 17:49:57 CEST 2014


Hi All,

I've very strange AVERROR_EOF while reading rtmp stream. My code is folowing

    static int av_interrapt(void *opaque)

    {

        VideoWorker* self = reinterpret_cast<VideoWorker*>(opaque);

        if (self->last != clock_t::time_point())

        {

            if ((VideoWorker::clock_t::now() - self->last) >=
std::chrono::milliseconds(200))

            {

                return 1;

            }

        }


        return self->_should_work ? 0 : 1;

    }



        AVPacket packet;

        for (int failed_pakets = 0; _should_work; )

        {

            av_init_packet(&packet);

            packet.data = nullptr;

            packet.size = 0;


            // read a frame

            last = clock_t::now();

            errnum = av_read_frame(av_format_ctx, &packet);

            last = clock_t::time_point();


            if (errnum == 0)

            {

                failed_pakets = 0;

                if (packet.stream_index == v_stream_idx)

                {

                    int got_picture_ptr = 0;

                    avcodec_decode_video2(av_codec_ctx, av_frame,
&got_picture_ptr, &packet);


                    // did we get a video frame?

                    if (got_picture_ptr)

                    {

                    ....

                    }

                }

            }


            av_free_packet(&packet);


            if (errnum != 0)

            {

                ++failed_pakets;

                if (failed_pakets > pimpl->max_failed_pakets)

                {

                ....

                }

            }

 }


After first timeout, all next calls to av_read_packet return AVERROR_EOF,
but stream is working.

Stream info:

Metadata:

Server NGINX RTMP (github.com/arut/nginx-rtmp-module)

width 1280.00

height 720.00

displayWidth 1280.00

displayHeight 720.00

duration 0.00

framerate 25.00

fps 25.00

videodatarate 0.00

videocodecid 7.00

audiodatarate 0.00

audiocodecid 16.00

profile

level


Input #0, flv, from '*':

Metadata:

Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)

displayWidth : 1280

displayHeight : 720

fps : 25

profile :

level :

Duration: 00:00:00.00 , start: 73560.671000 , bitrate: ] N/A

Stream #0.0: Video: h264 (Main), yuv420p, 1280x720, 1k tbn, 50 tbc

Stream #0.1: Audio: [0][0][0][0] / 0x0000, 0 channels



Can somebody help with it?


More information about the libav-api mailing list