# Get video resolution (height & width) in the onPublish event

**URL:** <https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [July 23, 2012, 6:36pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965 "2012-07-23T18:36:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Colomb](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@Marcel\_Colomb](https://community.wowza.com/u/Marcel_Colomb)\
**Post date:** [July 23, 2012, 6:36pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/1 "2012-07-23T18:36:12Z")

</div>

Hi

I’d like to send the video resolution to my webserver in the onpublish event. I already overwritten the method to send some other stuff (like clientId) everything works fine. But I really don’t find a solution with the resolution.

Anyone with the same issue or an idea?

Thank you very much

---

<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:** [July 23, 2012, 5:55pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/2 "2012-07-23T17:55:18Z")

</div>

Take a look at IMediaStreamActionNotify3.onMetaData() and IMediaStreamActionNotify3.onCodecInfoVideo()

[https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info](https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info)

Richard

---

<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:** [August 26, 2012, 12:33pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/3 "2012-08-26T12:33:42Z")

</div>

You should be able to get frame size from IMediaStreamActionNotify3.onMetaData()

You can get a rolling average bit rate of a 5 second window of a live stream with IOPerformanceCounter.getMessagesOutBytesRate()

To do that you have to attach the counter and monitor using a timer. Take a look at this example:

[https://www.wowza.com/docs/how-to-monitor-bandwidth-of-published-streams-modulelimitpublishedstreambandwidth](https://www.wowza.com/docs/how-to-monitor-bandwidth-of-published-streams-modulelimitpublishedstreambandwidth)

Richard

---

<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:** [August 30, 2012, 10:12pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/4 "2012-08-30T22:12:19Z")

</div>

I don’t think there is equivalent for rtsp. There is the IMediaCasterNotify inteface, but it does not include similar codec methods.

[https://www.wowza.com/docs/imediacasternotify2-example](https://www.wowza.com/docs/imediacasternotify2-example)

Richard

---

<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:** [September 7, 2012, 6:46pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/5 "2012-09-07T18:46:52Z")

</div>

Apparently it is not in the stream.

Richard

---

<div class="post-metadata">

**Author:** ![Daniel\_Mahoney](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@Daniel\_Mahoney](https://community.wowza.com/u/Daniel_Mahoney)\
**Post date:** [August 23, 2012, 2:02pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/6 "2012-08-23T14:02:43Z")

</div>

Richard, is it possible to also get the bit rates and frame sizes? Just being able to get the codec data that I can get through that example is a huge help, but being able to get the additional information would be a big help in the future.

I see lines in the debug log like:

_INFO server comment - LiveStreamPacketizerCupertino.handlePacket[live/definst/test][avc1.66.30]: H.264 Video info: {H264CodecConfigInfo: codec:H264, profile:Bsaeline, level:3.0, frameSize:656x448, displaYSize:656x448, frameRate:30.0, PAR:1:1}_

and

_INFO server comment - LiveStreamPacketizerCupertino.handlePacket[live/definst/test][mp4a.40.2]: AAC Audio info: {AACFrame: codec:AAC, channels:2, frequency:48000, samplesPerFrame:1024, objectType:LC}_

I know that if I **really** want the info I can always write a custom log appender for log4j and grab the info out of the logs but that’s a really tacky way to go about it. Is there any way that I could pull that out using the API?

---

<div class="post-metadata">

**Author:** ![Daniel\_Mahoney](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@Daniel\_Mahoney](https://community.wowza.com/u/Daniel_Mahoney)\
**Post date:** [August 30, 2012, 2:30pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/7 "2012-08-30T14:30:55Z")

</div>

How would I do the same thing for RTSP streams?

---

<div class="post-metadata">

**Author:** ![Daniel\_Mahoney](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@Daniel\_Mahoney](https://community.wowza.com/u/Daniel_Mahoney)\
**Post date:** [September 7, 2012, 8:56am UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/8 "2012-09-07T08:56:58Z")

</div>

> You should be able to get frame size from IMediaStreamActionNotify3.onMetaData()
> 
> You can get a rolling average bit rate of a 5 second window of a live stream with IOPerformanceCounter.getMessagesOutBytesRate()
> 
> To do that you have to attach the counter and monitor using a timer. Take a look at this example:
> 
> [Monitor bandwidth of published streams](https://www.wowza.com/docs/how-to-monitor-bandwidth-of-published-streams-modulelimitpublishedstreambandwidth)
> 
> Richard

I might be missing something, but I’m not seeing the frame size info there. The javadocs don’t seem to be helping either.

When I call the toString method of the AMFData argument I get back:

{AMFPacket: size: 514, type: 18, src: 0, seq: 0, absTimecode: 0, timecode: 0}

What am I missing?

---

<div class="post-metadata">

**Author:** ![Daniel\_Mahoney](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@Daniel\_Mahoney](https://community.wowza.com/u/Daniel_Mahoney)\
**Post date:** [September 10, 2012, 10:12am UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/9 "2012-09-10T10:12:36Z")

</div>

> catdude,
> 
> Some other info [here](https://www.wowza.com/forums/showthread.php?687-Accessing-cs-bytes-from-custom-app), such getMessagesOutBytes() or iLogNotify. cs-bytes.

That looks like it could be exactly what I’m looking for! Thanks.

I assume that this does not require a patch with Wowza 3, is that correct?

The example shown is missing a couple lines; I believe you need to add “import com.wowza.wms.stream.IMediaStream;” since the third argument to onLog is of that type. I think it also needs “import org.apache.log4j.Level;” since the second argument’s type is defined there. But I’m now getting the info I need and sticking it into my database, so thanks again for the pointer. I’ve gone through the server-side API docs a bunch of times, but somehow managed to miss the info for the logging classes.

---

<div class="post-metadata">

**Author:** ![Randall\_Auriemma](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@Randall\_Auriemma](https://community.wowza.com/u/Randall_Auriemma)\
**Post date:** [September 8, 2012, 5:52am UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/10 "2012-09-08T05:52:43Z")

</div>

catdude,

Some other info [here](https://www.wowza.com/forums/showthread.php?687-Accessing-cs-bytes-from-custom-app), such getMessagesOutBytes() or iLogNotify. cs-bytes.

---

<div class="post-metadata">

**Author:** ![Franco\_Nero\_Franco](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@Franco\_Nero\_Franco](https://community.wowza.com/u/Franco_Nero_Franco)\
**Post date:** [January 1, 2021, 2:37pm UTC](https://community.wowza.com/t/get-video-resolution-height-width-in-the-onpublish-event/38965/11 "2021-01-01T14:37:45Z")

</div>

Hi Daniel,

I am having the same issue. I am only getting this {AMFPacket: size: 514, type: 18, src: 0, seq: 0, absTimecode: 0, timecode: 0}. Can you please show your sample code?

Thanks in advance.
