Convert rtmp to flv – Stack Overflow

I try to convert rtmp into flv, and i use obs to send rtmp packet. After i decode the rtmp packet and write into a file, i found the video was longer than it should be. It is a 2 minutes video, but after push stream and pull stream, it becomes 2.5 minutes. I guess it’s something wrong with the timestamp, but i can’t solve it.

private void decodeTimeStamp(ByteBuf in, RawMessage last, boolean absolute) {
    int timeStamp = 0;
    if (absolute) {
        last.setTimeDelta(0);
        last.setTimeStamp(timeStamp | (in.readUnsignedByte() << 16) | (in.readUnsignedByte() << 8) | (in.readUnsignedByte()));
    } else {
        last.setTimeDelta(timeStamp | (in.readUnsignedByte() << 16) | (in.readUnsignedByte() << 8) | (in.readUnsignedByte()));
        last.setTimeStamp(last.getTimeStamp() + last.getTimeDelta());
    }
}

Read more here: Source link