scottlamb / retina

High-level RTSP multimedia streaming library, in Rust
https://crates.io/crates/retina
Apache License 2.0
218 stars 46 forks source link

Fatal: Timestamp jumped #64

Open christopher-wilke opened 1 year ago

christopher-wilke commented 1 year ago

I am trying to run the mp4 sample: cargo run --package client mp4 --url rtsp://ip.address.goes.here/ --username admin --password test out.mp4

This is the output I get:

PS C:\Users\chriwil\source\repos\retina> cargo run --package client -- mp4 --url rtsp://localhost:8554/mystream out.mp4
    Finished dev [unoptimized + debuginfo] target(s) in 0.61s
     Running `target\debug\client.exe mp4 --url rtsp://localhost:8554/mystream out.mp4`
I20220810 14:36:31.369 main client::mp4] Using h264 video stream
I20220810 14:36:31.371 main client::mp4] Using mpeg4-generic audio stream (rfc 6381 codec mp4a.40.2)
1628175071 (mod-2^32: 1628175071), npt 0.140: 670-byte video frame
I20220810 14:36:31.537 main client::mp4] new video params: VideoParameters { rfc6381_codec: "avc1.4D401F", pixel_dimensions: (1280, 720), pixel_aspect_ratio: Some((1, 1)), frame_rate: Some((2, 50)), extra_data: Length: 43 (0x2b) bytes
0000:   01 4d 40 1f  ff e1 00 1c  67 4d 40 1f  e8 80 28 02   .M@.....gM@...(.
0010:   dd 80 b5 01  01 01 40 00  00 03 00 40  00 00 0c 83   ......@....@....
0020:   c6 0c 44 80  01 00 04 68  eb ef 20                   ..D....h..  }
E20220810 14:36:31.543 main client] Fatal: Timestamp jumped -2692 (-0.061 sec) from 2705800284 to 2705797592 (mod-2^32: 2705797592), npt -0.061; policy is to allow 0..10 sec only

conn: [::1]:52007(me)->[::1]:8554@2022-08-10T14:36:31
stream: TCP, interleaved channel ids 2-3
ssrc: 57185d5e
seq: 0000f0e9
pkt: 1762@2022-08-10T14:36:31
error: process didn't exit successfully: `target\debug\client.exe mp4 --url rtsp://localhost:8554/mystream out.mp4` (exit code: 1)
scottlamb commented 1 year ago

Sounds frustrating. A few questions:

christopher-wilke commented 1 year ago

Thx for your quick feedback.

Sounds frustrating. A few questions:

  • Does this happen immediately every time you run the example? Yes

  • What RTSP server are you using (for a camera, make/model/version)? I am using https://github.com/aler9/rtsp-simple-server

  • Does adding --initial-timestamp=permissive to the command help? I will test this parameter by next week 👍

  • Are you able to / interested in getting a packet capture with e.g. Wireshark? If you don't want to share it publicly with your camera's IP/MAC/etc, I'm happy to look at it privately instead. I'm wondering if e.g. the RTSP PLAY response has a RTP-Info header with a rtptime parameter and how that compares to the RTP timestamps in the actual data stream. (I can also add some logging around this...) I will provide you some Wireshark data as soon as possible :+1:

christopher-wilke commented 1 year ago

Here are some updates:

Does adding --initial-timestamp=permissive to the command help? The parameter --initial-timestamp=permissive did not fix the issue

I will try to provide a Wireshark protocol later

scottlamb commented 1 year ago

Any update? I'm curious to see the Wireshark capture.

Do you know if your camera uses B-frames? This is likely the same thing as #61 if so.