How to get various stream info

Hi there. So I’m able to get plenty of info from a live stream from like this:

{Obj[]: author

copyright: “”

description: “”

keywords: “”

rating: “”

title: “”

presetname: “Custom”

creationdate: "Thu Aug 15 10

videodevice: “XSplitBroadcaster”

framerate: 30.0

width: 1280.0

height: 720.0

videocodecid: “avc1”

avclevel: 31.0

avcprofile: 100.0

videodatarate: 390.625

videokeyframe_frequency: 0.1

audiodevice: “VHAudioCustom”

audiosamplerate: 16000.0

audiochannels: 1.0

audioinputvolume: 100.0

audiocodecid: 11.0

audiodatarate: 27.1484375

bufferSize: “1250k”

maxBitrate: “1250k”

xsplitBroadcasterVersion: “1.3.0.95”

xsplitCoreVersion: “1.2.1303.0101 Version 1.2”

xsplitGameSourceVersion: “1.1.1.30”

xsplitMediaLibVersion: “2.0.0.209”}

But I need to get more information, including:

  1. Video encoding mode: CBR, VBR, or Strict CBR.

  2. Video encoding keyframe.

  3. Audio encoding.

  4. Video encoding bitrate and format.

This depends on the software encoding used to stream to wowza too right? But Take XSplit or OBS for example, how do I retrieve those information?

With IMeadiaStreamActionNotify3 you can use IMediaStreamActionNotify3.onCodecInfoVideo() and .onCodecInfoAudio() to get audio and video codec info from metadata.

Referring to this article How to inject cue points or metadata, use code like this to inject the metadata:

		AMFDataList amfList = new AMFDataList();
			
			amfList.add(new AMFDataItem("@setDataFrame"));
			amfList.add(new AMFDataItem("onMetaData"));
			
			AMFDataMixedArray metaData = new AMFDataMixedArray();
			
			metaData.put("param1", data);
			metaData.put("param2", new AMFDataItem("data2"));
			amfList.add(metaData);
			
			synchronized(stream)
		    {
				byte[] dataData = amfList.serialize();
				int size = dataData.length;
	            long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());
	            stream.setDataTC(timecode);
	            stream.setDataSize(size);
	            stream.startDataPacket();
	            stream.addDataData(dataData, 0, size);
		    }
		}

There may be more metadata that can be added to the stream on the encoder side.

Salvadore

It doesn’t have everything you are looking for, but I think you are overlooking what is available in IMediaStreamActionNotify3.onCodecInfoAudio() and .onCodecInfoVideo()

The IMediaStreamActionNotify3 example logs these lines when a stream starts:

onCodecInfoAudio[live/_definst_/Stream1 Audio Codecmp4a.40.2]: 
onCodecInfoVideo[live/_definst_/Stream1 Video Codecavc1.66.30]: 

You can decode audio and video codec string here.

And there is more data (frame rate and display size, height, width) in the codecInfoVideo and codecInfoAudio objects in this methods, which you can explore with break point in the Wowza IDE.

If you enable “cupertinostreamingpacketizer” in the Application.xml /Streams /LiveStreamPacketizers Wowza will log audio and video codec info, and the first few chunks, and this is the only way I know of to get info about key frames.

a/v/k = audio/video/key frames.

INFO server comment - LiveStreamPacketizerCupertino.endChunkTS[live/_definst_/Stream1]: Add chunk: id:1 mode:TS[H264,AAC] a/v/k:176/270/3 duration:11250
INFO server comment - LiveStreamPacketizerCupertino.endChunkTS[live/_definst_/Stream1]: Add chunk: id:2 mode:TS[H264,AAC] a/v/k:175/270/3 duration:11250
INFO server comment - LiveStreamPacketizerCupertino.endChunkTS[live/_definst_/Stream1]: Add chunk: id:3 mode:TS[H264,AAC] a/v/k:118/180/2 duration:7500

With “cupertinostreamingpacketizer” enabled you will also see these LiveStreamPacketizerCupertino.handlePacket lines with the same info as the IMediaStreamActionNotify3.onCodecInfoAudio() and .onCodecInfoVideo()

INFO server comment - LiveStreamPacketizerCupertino.handlePacket[live/_definst_/Stream1][mp4a.40.2]: AAC Audio info: {AACFrame: codec:AAC, channels:2, frequency:48000, samplesPerFrame:1024, objectType:LC}
INFO server comment - LiveStreamPacketizerCupertino.handlePacket[live/_definst_/Stream1][avc1.66.30]: H.264 Video info: {H264CodecConfigInfo: codec:H264, profile:Baseline, level:3.0, frameSize:424x240, displaySize:424x240, frameRate:24.0, crop: l:0 r:4 t:0 b:0}

I don’t know of a way to detect VBR, CBR unless it is included in the metadata.

Richard

After trying your suggestion I found that it only does what “public void onMetaData()” can do.

I’m still unable to retrieve the information I need:

  1. Video encoding mode: CBR, VBR, or Strict CBR.

  2. Video encoding keyframe.

  3. Audio encoding.

  4. Video encoding bitrate and format.