# Live Recording RTMP stream to FLV resets timestamp on reconnects

**URL:** https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615
**Category:** Wowza Streaming Engine
**Created:** [May 7, 2009, 7:05pm UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615 "2009-05-07T19:05:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)
#### Post date: [May 7, 2009, 7:05pm UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/1 "2009-05-07T19:05:37Z")

</div>

Hi,

I’ve been experimenting with different codecs and saw the same issue in recoded FLV’s. Every time RTMP stream reconnects, timestamps in output FLV get reset. It’s somewhat expected as timestamps inside RTMP stream are relative to the header packet. Header packet may contain an absolute timestamp.

I just got a raw RTMP dump and found that timestamp is there. It looks like wowza does not use that value to make base offset for flv timestamps. Is this right? Is it possible to make timestamps more consistent and abosolute? I’m trying to come up with solution that keeps two RTMP coming from the same encoder (but different content) streams synchronized. Unfortunately, it’s unreliable because of timestamps resets as one of steams may reconnect. Is it possible to embed cue points with, say, UTC time in flv file on wowza side?

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [May 20, 2009, 3:25am UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/2 "2009-05-20T03:25:07Z")

</div>

Did you see the updated docs that come with the patches? They should match the patched builds.

Charlie

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [May 24, 2009, 3:55am UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/3 "2009-05-24T03:55:37Z")

</div>

We really don’t support synchronizing between streams like this. If what you are doing works then I guess it is fine. We are working with the encoder companies to make stream synchronization reliable so we can properly do adpative bitrate/smooth streaming.

Charlie

---

<div class="post-metadata">

### Author: ![Alex\_Avseyev](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@Alex\_Avseyev](https://community.wowza.com/u/Alex_Avseyev)
#### Post date: [May 14, 2009, 7:08pm UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/4 "2009-05-14T19:08:04Z")

</div>

Ok, I’ve figured out this from the sample MediaWriter code. I want to refactor existing MediaWriter class. Is there source code in the ServerSideAPI.pdf the latest one? If not, where can I get the updated version? If there’s a simple way to adjust base timestamp for output flv file, I would be happy to hear how to do that. 🙂

Thanks!

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [May 15, 2009, 11:36am UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/5 "2009-05-15T11:36:54Z")

</div>

Alex,

You can download the [latest patch here](https://www.wowza.com/devbuild.html) to get the latest documentation, including server-side api pdf.

You don’t have to apply the patch if you are not ready, just grab the pdf from the /documentation folder.

Richard

---

<div class="post-metadata">

### Author: ![Alex\_Avseyev](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@Alex\_Avseyev](https://community.wowza.com/u/Alex_Avseyev)
#### Post date: [May 19, 2009, 5:48pm UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/6 "2009-05-19T17:48:14Z")

</div>

Thanks! I was able to customize MediaWriter for my needs now. Doc was still missing couple new methods though. 🙂

---

<div class="post-metadata">

### Author: ![Alex\_Avseyev](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@Alex\_Avseyev](https://community.wowza.com/u/Alex_Avseyev)
#### Post date: [May 23, 2009, 9:49pm UTC](https://community.wowza.com/t/live-recording-rtmp-stream-to-flv-resets-timestamp-on-reconnects/615/7 "2009-05-23T21:49:55Z")

</div>

Yes, I used docs from the latest patch6. Example for MediaWriter was still missing isWaitForKeyFrame() and setIsWaitForKeyFrame(). Not a big deal.

By the way, what would be in your opinion the right way to synchronize timestamps across multiple streams? Problem is that econders may connect and reconnect at different points of time, but I still want to keep output FLV’s synchronized having the same absolute timestamps.

I’m currently using currentTCs structure which is used for buffer timestamp adjustment in writePackets(). It’s a bit hackish. Output buffer is accessible only in writePackets(), and it’s called when buffer is ready for flush. So I also have to remember when the method was called and calculate start timestamps for secondary streams as

```auto
secondaryStreamTC = masterStreamTC + whenSecondaryWritePacketsWasCalled - whenMasterWritePacketsWasCalled

```

I do this at start of writePackets(). Like I said, it’s hackish, but it works in my test setup. Can I do something similar on the incoming stream?
