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

Invalid NAL unit 0, skipping in VLC and ffplay can not play buf fixed #72

Open
fatalfeel opened this issue Jul 2, 2022 · 1 comment

Comments

@fatalfeel
Copy link

fatalfeel commented Jul 2, 2022

I fixed h264 h265 Invalid NAL unit 0, skipping buf fixed

  1. rtp.h
    //refer to live555 H264or5VideoRTPSink.cpp MultiFramedRTPSink.cpp
    //RTP hdr size is 12, ourMaxPacketSize()-12 = 1452 -12
    #define MAX_RTP_PAYLOAD_SIZE 1420
#define MAX_RTP_PAYLOAD_SIZE   1440

//#define RTP_TCP_HEAD_SIZE	   4 //when transport_mode_ = RTP_OVER_TCP
~~~change to
#define RTP_TCP_HEAD_SIZE      0 //when transport_mode_ = RTP_OVER_UDP

2. H264Source.cpp
if (frame_size <= MAX_RTP_PAYLOAD_SIZE)
{
    frame_buf  += 4; //shift to nalu position
    frame_size -= 4;
    RtpPacket rtp_pkt;
    rtp_pkt.type = frame.type;
    rtp_pkt.timestamp = frame.timestamp;
    rtp_pkt.size = frame_size + RTP_TCP_HEAD_SIZE + RTP_HEADER_SIZE;
    rtp_pkt.last = 1;
    ...
}
else
{
    frame_buf  += 4; //shift to nalu position
    frame_size -= 4;
    char FU_A[2] = {0};
    FU_A[0] = (frame_buf[0] & 0xE0) | 28;
    FU_A[1] = 0x80 | (frame_buf[0] & 0x1F);
}

3. H265Source.cpp
if (frame_size <= MAX_RTP_PAYLOAD_SIZE)
{
    frame_buf  += 4; //shift to nalu position
    frame_size -= 4;
    RtpPacket rtp_pkt;
    rtp_pkt.type = frame.type;
    rtp_pkt.timestamp = frame.timestamp;
    rtp_pkt.size = frame_size + RTP_TCP_HEAD_SIZE + RTP_HEADER_SIZE;
    rtp_pkt.last = 1;
    ...
}
else
{
    frame_buf  += 4; //shift to nalu position
    frame_size -= 4;
    uint8_t PL_FU[3] = {0};
    uint8_t nalUnitType = (frame_buf[0] & 0x7E) >> 1;
    PL_FU[0] = (frame_buf[0] & 0x81) | (49<<1);
    PL_FU[1] = frame_buf[1];
    PL_FU[2] = 0x80 | nalUnitType;
}




@fatalfeel fatalfeel changed the title Invalid NAL unit 0, skipping buf fixed Invalid NAL unit 0, skipping and ffplay can not play buf fixed Jul 2, 2022
@fatalfeel fatalfeel changed the title Invalid NAL unit 0, skipping and ffplay can not play buf fixed Invalid NAL unit 0, skipping in VLC and ffplay can not play buf fixed Jul 2, 2022
@fatalfeel
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant