Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About push the stream of time #16

Closed
flyminiboy opened this issue May 11, 2016 · 20 comments
Closed

About push the stream of time #16

flyminiboy opened this issue May 11, 2016 · 20 comments
Labels

Comments

@flyminiboy
Copy link

Now, Continue to push flow more than 4 hours and 30 minutes,It will stop.

@begeekmyfriend
Copy link
Owner

I have tested publishing overnight.

  • Does it happen each time?
  • What is the exception thrown?
  • Is your networking all right?

@flyminiboy
Copy link
Author

It happen each time
The network is normal
Sorry, I forget to see the exception

@begeekmyfriend
Copy link
Owner

Enough, if it happens each time, the exception might well be EPIPE. I have got it.

@flyminiboy
Copy link
Author

What I can do to avoid the this exception.
In other places I have seen this exception,and the most people say it's it's caused by and extend the timestamp。

@begeekmyfriend
Copy link
Owner

Nothing but re-connection since it is the Nginx-RTMP that closes the socket. Today I will verify it on Nginx-RTMP.

@begeekmyfriend
Copy link
Owner

Ah, I see. This article illustrates the reason.

ngx_rtmp_recv(ngx_event_t *rev)  
{  
    for( ;; ) {  
        /* parse headers */  
        if (b->pos == b->start) {  
            /* chunk basic header */  
            fmt  = (*p >> 6) & 0x03;  
            csid = *p++ & 0x3f;  
            if (fmt <= 2 ) {  
                /* timestamp: big-endian 3b -> little-endian 4b */  
                pp = (u_char*)timestamp;  
                ext = (timestamp == 0x00ffffff);  
                if (fmt <= 1) {  
                    /* size: big-endian 3b -> little-endian 4b type*/  
                    pp = (u_char*)&h->mlen;  
                    h->type = *(uint8_t*)p++;  
                    if (fmt == 0) {  
                        /* stream: little-endian 4b -> little-endian 4b */  
                        pp = (u_char*)&h->msid;  
                    }  
                }  
            }  
            /* extended header */  
            if (ext) {  
                pp = (u_char*)timestamp;  
                pp[3] = *p++;  
                pp[2] = *p++;  
                pp[1] = *p++;  
                pp[0] = *p++;  
            }

In ngx_rtmp_recv function, once Nginx-RTMP receives extended time stamp in chunk type less than 3, then it will always parses extended time stamp in the subsequent packets whatever the chunk type is.

@begeekmyfriend
Copy link
Owner

Try 9e35f22 please.

@flyminiboy
Copy link
Author

I get the latest code, find a new exception : java.net.UnknownHostException: Host is unresolved
It happened before.

@begeekmyfriend
Copy link
Owner

begeekmyfriend commented May 11, 2016

That is your URL or networking issue.

@flyminiboy
Copy link
Author

But I use the old code can push stream.

@begeekmyfriend
Copy link
Owner

Are you sure? I downloaded and tried just now you were saying.

@flyminiboy
Copy link
Author

Sorry, Should be a network problem. Just in time is a coincidence

@flyminiboy
Copy link
Author

It seem still have the same problem
And I will test again.

@flyminiboy
Copy link
Author

Maybe you can refer to this blog librtmp 时间戳

@begeekmyfriend
Copy link
Owner

A rapid reappearance approach is adding code in rtmp/io/WriteThread.java. It can help find the bug though no solution occurs to me currently.

                while (!writeQueue.isEmpty()) {
                    RtmpPacket rtmpPacket = writeQueue.poll();
                    ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(rtmpPacket.getHeader().getChunkStreamId());
                    chunkStreamInfo.setPrevHeaderTx(rtmpPacket.getHeader());
                    if (rtmpPacket instanceof Video || rtmpPacket instanceof Audio) {
                        rtmpPacket.getHeader().setAbsoluteTimestamp((int) chunkStreamInfo.markAbsoluteTimestampTx() + 0xffffff);
                    } else {
                        rtmpPacket.getHeader().setAbsoluteTimestamp((int) chunkStreamInfo.markAbsoluteTimestampTx());
                    }
                    rtmpPacket.writeTo(out, rtmpSessionInfo.getTxChunkSize(), chunkStreamInfo);
                    Log.d(TAG, "WriteThread: wrote packet: " + rtmpPacket + ", size: " + rtmpPacket.getHeader().getPacketLength());
                    if (rtmpPacket instanceof Command) {
                        rtmpSessionInfo.addInvokedCommand(((Command) rtmpPacket).getTransactionId(), ((Command) rtmpPacket).getCommandName());
                    }
                    if (rtmpPacket instanceof Video) {
                        publisher.getVideoFrameCacheNumber().getAndDecrement();
                        calcFps();
                    }
                }
                out.flush();

@begeekmyfriend
Copy link
Owner

Final patch on this issue: 5ee43c6

@flyminiboy
Copy link
Author

I did the test Yesterday night,and It seem still exist

@flyminiboy
Copy link
Author

Stream disconnect after 10 hours.

@flyminiboy
Copy link
Author

Can I catch the exception and reconnect.

@begeekmyfriend
Copy link
Owner

begeekmyfriend commented May 13, 2016

10 hours? That might not be extended time stamp. Maybe the video cache number is full and your network is weak? You may do it yourself.

penninghlhd referenced this issue in illuminoo/yasea Jun 28, 2017
- Optimized communication between LISA agent using H264 encoding instead of sending raw YUV frames.
penninghlhd referenced this issue in illuminoo/yasea Jun 29, 2017
- Removed ignore files
penninghlhd referenced this issue in illuminoo/yasea Jul 2, 2017
- Improved camera switching by setting encoder to produce i-frame every frame, and some other minor fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants