# Determining codec name from VideoCodecId and AudioCodecId

**URL:** <https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [July 9, 2012, 1:48pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435 "2012-07-09T13:48:38Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [July 9, 2012, 1:48pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/1 "2012-07-09T13:48:38Z")

</div>

I’ve been looking through the server-side API and in the IMedia section I see the getPublishVideoCodecId and getPublishAudioCodecId calls. Both of these calls return an int. How do I translate that int into the name of the codec?

---

<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 9, 2012, 9:19pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/2 "2012-07-09T21:19:54Z")

</div>

Take a look at IVHost.CODEC\_VIDEO\_\*

And you can use FLVUtils.getVideoCodecToString(int)

Richard

---

<div class="post-metadata">

**Author:** ![Tit\_Petric](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@Tit\_Petric](https://community.wowza.com/u/Tit_Petric)\
**Post date:** [July 9, 2012, 10:22pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/3 "2012-07-09T22:22:27Z")

</div>

> I’ve been looking through the server-side API and in the IMedia section I see the getPublishVideoCodecId and getPublishAudioCodecId calls. Both of these calls return an int. How do I translate that int into the name of the codec?

Returns:

codec id IVHost.CODEC\_VIDEO\_\*

Check IVHost for definitions of audio and video codecs. You have to enumerate theese if you need a String.

---

<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 9, 2012, 9:26pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/4 "2012-07-09T21:26:31Z")

</div>

It is in the version of the server-side api that I have.

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:** [July 9, 2012, 9:35pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/5 "2012-07-09T21:35:59Z")

</div>

Tit,

I’m not sure, but the version running on this machine is 3.1.1

Richard

---

<div class="post-metadata">

**Author:** ![Tit\_Petric](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@Tit\_Petric](https://community.wowza.com/u/Tit_Petric)\
**Post date:** [July 9, 2012, 10:25pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/6 "2012-07-09T22:25:00Z")

</div>

rrlanham: getVideoCodecToString is undocumented (the only mention I found was on one or two wowza forum threads). API pdf or javadoc are both without it.

---

<div class="post-metadata">

**Author:** ![Tit\_Petric](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@Tit\_Petric](https://community.wowza.com/u/Tit_Petric)\
**Post date:** [July 9, 2012, 10:33pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/7 "2012-07-09T22:33:18Z")

</div>

Ok,

this needs updating: [https://www.wowza.com/resources/WowzaMediaServer\_ServerSideAPI.pdf](https://www.wowza.com/resources/WowzaMediaServer_ServerSideAPI.pdf) 🙂

I’ll ignore the javadoc, as I’m running 3.0.6 because of EC2 requirements :). In which version was the method added, if you have that information?

Best,

Tit

---

<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:** [July 9, 2012, 4:08pm UTC](https://community.wowza.com/t/determining-codec-name-from-videocodecid-and-audiocodecid/35435/8 "2012-07-09T16:08:49Z")

</div>

> Returns:
> 
> codec id IVHost.CODEC\_VIDEO\_\*
> 
> Check IVHost for definitions of audio and video codecs. You have to enumerate theese if you need a String.

It looks like this should contain the info I need, but it also looks like the onPublish method must be too early to call it, as I’m getting audioCodecId and videoCodecId of -1. Where would be the appropriate place in the overall flow to call this?

Better yet, when I look though Eclipse’s log output I see lines like:

INFO server comment - MediaStreamMap.getLiveStreamPacketizer: Create live stream packetizer: cupertinostreamingpacketizer:1084563

INFO server comment - CupertinoPacketHandler.startStream[liverecord/_definst_/1084563]

INFO server comment - LiveStreamPacketizerCupertino.handlePacket[liverecord/_definst_/1084563]: Video codec:H264 isCompatible:true

INFO server comment - LiveStreamPacketizerCupertino.handlePacket[liverecord/_definst_/1084563]: Audio codec:AAC isCompatible:true

INFO server comment - LiveStreamPacketizerCupertino.handlePacket[liverecord/_definst_/1084563][mp4a.40.2]: AAC Audio info: {AACFrame: size: 0, rate: 44100, channels: 2, samples: 1024, errorBitsAbsent: true, profileObjectType: “LC”}

INFO server comment - MediaStreamMap.getLiveStreamPacketizer: Create live stream packetizer: smoothstreamingpacketizer:1084563

INFO server comment - LiveStreamPacketizerSmoothStreaming.startStream[liverecord/_definst_/1084563]

INFO server comment - LiveStreamPacketizerCupertino.handlePacket[liverecord/_definst_/1084563][avc1.66.30]: H.264 Video info: {H264CodecConfigInfo: profile: “Baseline”, level: 3.0, frameSize: 640x480, displaySize: 640x480, PAR: 1:1, frameRate: 24.0}

I would dearly love to be able to write this info into a database. Two questions: 1) I assume this info is only available for streams that are coming via RTMP, is that correct? That would be ok as at present all of my live streams are RTMP; I’ll worry about getting that info for stream that come in via RTSP later; and 2) can I access that information somehow, short of having to parse the log file?

FOLLOWUP:

I added calls to getPublishVideoCodecId() and FLVUtils.videoCodecToString() in my onStreamCreate, onMediaStreamCreate, and onPublish methods, and in every case they get audio and video codec IDs of -1. Where should I be making these calls?
