分享

Wowza Transcoder 插件如何为一个直播流配置转码功能?

 看见就非常 2015-05-15
这篇文章详细介绍了Wowza Transcoder 插件如何将一个输入流进行实时解码再重新编码以输出播放终端所需要的格式,并且输出的多个不同码率的流是关键帧对齐的,以实现码率自适应。

注意: 本文只针对Wowza Media Server? 3.0.0 及以上版本。

内容



开始

故障排查


开始



对硬件和驱动的要求


Wowza Transcoder 只能在64位的Windows和Linux系统上运行。此外也不支持Mac OS X 系统。

Wowza Transcoder在64位的Windows Server 上运行时, 系统必须先具备以下功能:
  • .NET Framework 3.5.1
  • Desktop Experience


硬件加速
Wowza Transcoder 支持Windows 和 LinuxIntel系统上的Quick Sync 和 NVIDIA NVENC 加速编码以及Windows系统上的NVIDIA CUDA 加速编码。 下面的文章介绍了关于这些技术的更多硬件要求:


注意:

支持的音视频编码格式


为了将输入流(被称作"channels")进行转码或转换为多个不同输出码率的输出流,Wowza Transcoder 插件提供了很多功能,它支持以下音视品编码格式:

输入流:

  • 视频解码: H.264, MPEG-2, MPEG-4 Part 2
  • 音频解码: AAC, MP3, MPEG-1 Layer 1/2, Speex, G.711 (μ-law and A-law)

输出流:

  • 视频编码: H.264, H.263v2
  • 音频编码: AAC

注意:
  • 对于mp3格式的音频,系统支持以下采样率: 48000, 44100, and 32000

  • Instream CEA-608 隐藏字幕(closed caption)可以通过Wowza Transcoder 插件采用Apple HLS 流媒体被传送给基于iOS的终端设备。要了解更多信息,请阅读如何为HLS流媒体配置隐藏字幕(closed captioning)

  • 当使用硬件加速特性时,不支持H.263 视频输出。

关于Transcoder模版


Wowza Transcoder 使用一个模版系统来为输出流创建转码后的输出流,这个模版可以控制各种编码参数。在[install-dir]/transcoder/templates目录下有三个默认的模版文件,基本满足了常规的转码要求: transrate.xml, transcode.xml, 以及 audioonly.xml。 要了解更多关于个性化的的转码模版,请阅读模版的配置.

Wowza Transcoder 模版系统提供一个将多个输出流组合在一个逻辑组的方法(被称作 Stream Name Groups)。可以用ngrp:前缀来引用这个逻辑组以实现码率自适应。

Server.license 的配置(Wowza Media Server Perpetual Edition)


Wowza Media Server和增值插件的授权码(license key) (包括Wowza Transcoder 插件)被存储在[install-dir]/conf/Server.license

  • %WMSCONFIG_HOME%\conf\Server.license
    - Windows
  • /Library/WowzaMediaServer/conf/Server.license
    - Mac OS X
  • /usr/local/WowzaMediaServer/conf/Server.license
    - Linux/Unix

试用、日租、月租模式的授权只需要一个license key,但是永久授权模式需要多个license key。

使用增值插件时,用文本编辑器打开Server.license文件,在每一个新行输入一个新的license key。当服务被重启后,新的license将会生效。 由于多个授权码是叠加的,因此在添加一个新的授权码时,去保留文件中原有的授权码,然后在新的一行填写新的授权码。多个授权码在文件中的前后顺序是无关紧要的。 授权码的前5位和后5位字符将显示在控制台的输出中信息。

下面是一个Server.license 文件的示例,包括一个永久授权的Wowza Media Server 授权码、两个Wowza Transcoder 插件授权码以及一个Wowza nDVR 插件授权码:

SVRP3-LaGpC-ZrTD9-F4Y3S-a9bR2-h5t3C
TRN23-Ry6qe-4mT8J-yKj2W-4N5sH-2Td3a
TRN13-y9Gj2-kneqT-2zjHp-GadzB-N6fwa
DVRA3-k3r3R-nzxCB-ypjs5-Sk3y9-ahFdF

Application.xml的配置


建立一个直播应用,然后对Application.xml文件进行一些配置以使用Wowza Transcoder插件,请按下面进行:

  1. 创建一个应用的目录[install-dir]/applications/live.

  2. 创建一个配置目录[install-dir]/conf/live ,将[install-dir]/conf/Application.xml 文件拷贝到这个新目录下

  3. 用文本编辑器打开这个新拷贝的Application.xml 文件,然后做如下改动(有些设置可能已经配好了):

    1. Streams/StreamType 设置为:
      Code:
      <StreamType>live</StreamType>
    2. HTTPStreamers 设置为:
      Code:
      <HTTPStreamers>cupertinostreaming,smoothstreaming,sanjosestreaming</HTTPStreamers>
    3. Streams/LiveStreamPacketizers 设置为:
      Code:
      <LiveStreamPacketizers>cupertinostreamingpacketizer,smoothstreamingpacketizer,sanjosestreamingpacketizer</LiveStreamPacketizers>
    4. RTP/Authentication/PlayMethod 设置为:
      Code:
      <PlayMethod>none</PlayMethod>
    5. Transcoder/LiveStreamTranscoder 设置为:
      Code:
      <LiveStreamTranscoder>transcoder</LiveStreamTranscoder>
    6. 如果输入流是H.264视频编码AACMP3 音频编码,你希望创建多个不同码率的输出流,以实现码率自适应,请将Transcoder/Templates 设置为:
      Code:
      <Templates>${SourceStreamName}.xml,transrate.xml</Templates>
      如果输入流是MPEG-2MPEG-4 Part 2 视频编码,你希望转码为H.264AAC,以面向Wowza支持的例如Adobe Flash播放器、Apple iOS 设备和Microsoft Silverlight的播放器技术, 请将Transcoder/Templates 设置为:
      Code:
      <Templates>${SourceStreamName}.xml,transcode.xml</Templates>
      注意: 当使用transcode.xml时,同样也支持多码率自适应。
    7. 如果你希望转码的输入流时SHOUTcastIcecast MP3 媒体流,请在MediaCaster/Properties 中添加下面的属性以配置Wowza Media Server 在每个包中发送一个MP3 帧:
      Code:
      <Property>
      	<Name>shoutcastMP3GroupCount</Name>
      	<Value>1</Value>
      	<Type>Integer</Type>
      </Property>
  4. (只针对基于RTSP/RTP的编码器),用文本编辑器打开[install-dir]/conf/publish.password文件,添加一个用户名和密码来控制对RTSP/RTP 推流的访问。 下面是一个例子,用户名为myuser,密码为mypassword)。
    Code:
    # Publish password file (format [username][space][password])
    # username password
    myuser mypassword
  5. 启动 Wowza Media Server.

模版的配置


如果你使用系统自带的transrate.xmltranscode.xml 模版文件, 转码后的输出流将使用下面的stream names:

  • [stream-name]_360p: Main Profile stream
  • [stream-name]_160p: Baseline Profile stream
  • ngrp:[stream-name]_all: 面向Apple HTTP Live Streaming (cupertino)、 Microsoft Smooth Streaming以及 Adobe HTTP Dynamic Streaming (sanjose)的码率自适应

[stream-name] 是输入到Wowza Media Server的输入流。例如,一个输入是myStream, 那么转码后的输出流就是myStream_360pmyStream_160p以及 ngrp:myStream_all

转码的工作机制很简单。推送到live应用的所有输入流将被采用在[install-dir]/conf/[application]/Application.xml文件Transcoder/Templates中设置的转码模版文件中的参数来转码。 你可以根据需要配置多个转码后的输出流。

让我们仔细看以下转码模版中的配置。下面是随Wowza Media Server安装后自带的transrate.xml模版文件:
Code:
<!-- Example template for transrate, producing four new streams at different bitrates. Resultant streams can be played back individually or as a group. source, 360p and 160p encode blocks are enabled through the Enable property, other examples are not enabled. Add additional encode blocks to your template as needed. -->
<Root>
	<Transcode>
		<Encodes>
			<!-- Example Encode block for source, not required unless Member of StreamNameGroup. --> 
			<Encode>
				<Enable>true</Enable>
				<Name>source</Name>
				<StreamName>mp4:${SourceStreamName}_source</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceVideoBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceAudioBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
			<!-- Setup for 720p, high bandwith, main profile for desktop or set-top box -->
			<Encode>
				<Enable>false</Enable>
				<Name>720p</Name>
				<StreamName>mp4:${SourceStreamName}_720p</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>H.264</Codec>
					<!-- default, CUDA, QuickSync, NVENC -->
					<Transcoder>default</Transcoder>
					<GPUID>-1</GPUID>
					<FrameSize>
						<!-- letterbox, fit-width, fit-height, crop, stretch, match-source -->
						<FitMode>fit-height</FitMode>
						<Width>1280</Width>
						<Height>720</Height>
						<!-- <Crop>0,0,0,0</Crop> -->
						<!-- <SourceRectangle>0,0,320,240</SourceRectangle> -->
					</FrameSize>
					<!-- baseline, main, high -->
					<Profile>main</Profile>
					<Bitrate>1300000</Bitrate>
					<KeyFrameInterval>
						<FollowSource>true</FollowSource>
						<Interval>60</Interval>
					</KeyFrameInterval>
					<Overlays>
						<Overlay>
							<Enable>false</Enable>
							<Index>0</Index>
							<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
							<CheckForUpdates>false</CheckForUpdates>
							<Opacity>100</Opacity>
							<Location>
								<X>4</X>
								<Y>4</Y>
								<Width>${ImageWidth}</Width>
								<Height>${ImageHeight}</Height>
								<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
								<Align>left,top</Align>
							</Location>
						</Overlay>
					</Overlays>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceAudioBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
			<!-- Setup for 360p, high bandwith, main profile for desktop -->
			<Encode>
				<Enable>true</Enable>
				<Name>360p</Name>
				<StreamName>mp4:${SourceStreamName}_360p</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>H.264</Codec>
					<!-- default, CUDA, QuickSync, NVENC -->
					<Transcoder>default</Transcoder>
					<GPUID>-1</GPUID>
					<FrameSize>
						<!-- letterbox, fit-width, fit-height, crop, stretch, match-source -->
						<FitMode>fit-height</FitMode>
						<Width>640</Width>
						<Height>360</Height>
						<!-- <Crop>0,0,0,0</Crop> -->
						<!-- <SourceRectangle>0,0,320,240</SourceRectangle> -->
					</FrameSize>
					<!-- baseline, main, high -->
					<Profile>main</Profile>
					<Bitrate>850000</Bitrate>
					<KeyFrameInterval>
						<FollowSource>true</FollowSource>
						<Interval>60</Interval>
					</KeyFrameInterval>
					<Overlays>
						<Overlay>
							<Enable>false</Enable>
							<Index>0</Index>
							<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
							<CheckForUpdates>false</CheckForUpdates>
							<Opacity>100</Opacity>
							<Location>
								<X>4</X>
								<Y>4</Y>
								<Width>${ImageWidth}</Width>
								<Height>${ImageHeight}</Height>
								<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
								<Align>left,top</Align>
							</Location>
						</Overlay>
					</Overlays>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceAudioBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
			<!-- Setup for 240p, medium bandwidth, baseline profile -->
			<Encode>
				<Enable>false</Enable>
				<Name>240p</Name>
				<StreamName>mp4:${SourceStreamName}_240p</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>H.264</Codec>
					<!-- default, CUDA, QuickSync, NVENC -->
					<Transcoder>default</Transcoder>
					<GPUID>-1</GPUID>
					<FrameSize>
						<!-- letterbox, fit-width, fit-height, crop, stretch, match-source  -->
						<FitMode>fit-height</FitMode>
						<Width>360</Width>
						<Height>240</Height>
						<!-- <Crop>0,0,0,0</Crop> -->
						<!-- <SourceRectangle>0,0,320,240</SourceRectangle> -->
					</FrameSize>
					<!-- baseline, main, high -->
					<Profile>baseline</Profile>
					<Bitrate>350000</Bitrate>
					<KeyFrameInterval>
						<FollowSource>true</FollowSource>
						<Interval>60</Interval>
					</KeyFrameInterval>
					<Overlays>
						<Overlay>
							<Enable>false</Enable>
							<Index>0</Index>
							<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
							<CheckForUpdates>false</CheckForUpdates>
							<Opacity>100</Opacity>
							<Location>
								<X>4</X>
								<Y>4</Y>
								<Width>${ImageWidth}</Width>
								<Height>${ImageHeight}</Height>
								<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
								<Align>left,top</Align>
							</Location>
						</Overlay>
					</Overlays>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceAudioBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
			<!-- Setup for 160p, low bandwith, baseline profile for 3G mobile devices such as iOS, Android, Blackberry -->
			<Encode>
				<Enable>true</Enable>
				<Name>160p</Name>
				<StreamName>mp4:${SourceStreamName}_160p</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>H.264</Codec>
					<!-- default, CUDA, QuickSync, NVENC -->
					<Transcoder>default</Transcoder>
					<GPUID>-1</GPUID>
					<FrameSize>
						<!-- letterbox, fit-width, fit-height, crop, stretch, match-source  -->
						<FitMode>fit-height</FitMode>
						<Width>284</Width>
						<Height>160</Height>
						<!-- <Crop>0,0,0,0</Crop> -->
						<!-- <SourceRectangle>0,0,320,240</SourceRectangle> -->
					</FrameSize>
					<!-- baseline, main, high -->
					<Profile>baseline</Profile>
					<Bitrate>200000</Bitrate>
					<KeyFrameInterval>
						<FollowSource>true</FollowSource>
						<Interval>60</Interval>
					</KeyFrameInterval>
					<Overlays>
						<Overlay>
							<Enable>false</Enable>
							<Index>0</Index>
							<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
							<CheckForUpdates>false</CheckForUpdates>
							<Opacity>100</Opacity>
							<Location>
								<X>4</X>
								<Y>4</Y>
								<Width>${ImageWidth}</Width>
								<Height>${ImageHeight}</Height>
								<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
								<Align>left,top</Align>
							</Location>
						</Overlay>
					</Overlays>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>PassThru</Codec>
					<Bitrate>${SourceAudioBitrate}</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
			<!-- Setup for H.263, low bandwith, streaming to older mobile devices -->
			<Encode>
				<Enable>false</Enable>
				<Name>h263</Name>
				<StreamName>mp4:${SourceStreamName}_h263</StreamName>
				<Video>
					<!-- H.264, H.263, PassThru, Disable -->
					<Codec>H.263</Codec>
					<!-- default, CUDA, QuickSync, NVENC -->
					<Transcoder>default</Transcoder>
					<GPUID>-1</GPUID>
					<FrameSize>
						<!-- letterbox, fit-width, fit-height, crop, stretch, match-source  -->
						<FitMode>letterbox</FitMode>
						<Width>176</Width>
						<Height>144</Height>
						<!-- <Crop>0,0,0,0</Crop> -->
						<!-- <SourceRectangle>0,0,320,240</SourceRectangle> -->
					</FrameSize>
					<!-- baseline, main, high -->
					<Profile>baseline</Profile>
					<Bitrate>150000</Bitrate>
					<KeyFrameInterval>
						<FollowSource>false</FollowSource>
						<Interval>60</Interval>
					</KeyFrameInterval>
					<Overlays>
						<Overlay>
							<Enable>false</Enable>
							<Index>0</Index>
							<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
							<CheckForUpdates>false</CheckForUpdates>
							<Opacity>100</Opacity>
							<Location>
								<X>4</X>
								<Y>4</Y>
								<Width>${ImageWidth}</Width>
								<Height>${ImageHeight}</Height>
								<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
								<Align>left,top</Align>
							</Location>
						</Overlay>
					</Overlays>
					<Parameters>
					</Parameters>
				</Video>
				<Audio>
					<!-- AAC, PassThru, Disable -->
					<Codec>AAC</Codec>
					<Bitrate>64000</Bitrate>
					<Parameters>
					</Parameters>
				</Audio>
				<Properties>
				</Properties>
			</Encode>
		</Encodes>
		<Decode>
			<Video>
				<Deinterlace>false</Deinterlace>
				<Overlays>
					<Overlay>
						<Enable>false</Enable>
						<Index>0</Index>
						<ImagePath>${com.wowza.wms.context.VHostConfigHome}/content/wowzalogo.png</ImagePath>
						<CheckForUpdates>false</CheckForUpdates>
						<Opacity>100</Opacity>
						<Location>
							<X>4</X>
							<Y>4</Y>
							<Width>${ImageWidth}</Width>
							<Height>${ImageHeight}</Height>
							<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
							<Align>left,top</Align>
						</Location>
					</Overlay>
				</Overlays>
				<Parameters>
				</Parameters>
			</Video>
			<Properties>
			</Properties>
		</Decode>
		<StreamNameGroups>
			<!-- Note: Play stream using stream name ngrp:[stream-name] -->
			<StreamNameGroup>
				<Name>all</Name>
				<StreamName>${SourceStreamName}_all</StreamName>
				<Members>
					<Member>
						<EncodeName>source</EncodeName>
					</Member>
					<Member>
						<EncodeName>720p</EncodeName>
					</Member>
					<Member>
						<EncodeName>360p</EncodeName>
					</Member>
					<Member>
						<EncodeName>240p</EncodeName>
					</Member>
					<Member>
						<EncodeName>160p</EncodeName>
					</Member>
				</Members>
			</StreamNameGroup>
			<StreamNameGroup>
				<Name>mobile</Name>
				<StreamName>${SourceStreamName}_mobile</StreamName>
				<Members>
					<Member>
						<EncodeName>240p</EncodeName>
					</Member>
					<Member>
						<EncodeName>160p</EncodeName>
					</Member>
				</Members>
			</StreamNameGroup>
		</StreamNameGroups>
		<Properties>
		</Properties>
	</Transcode>
</Root>
模版细节: <Encode>...</Encode>

这部分是编码的设置。一个包含多个<Encode> 的模版.

  • Enable. 如果你设置为 true, 那么这部分的编码就是启用状态。如果你设置为 false, 这部分的编码将被忽略。默认的模版的含有多个 <Encode> 的例子, 并不是所有的都启用了。你可以根据需要在你的模版文件中启用或添加一个新的编码设置。

  • Name. 每一个编码设置都有一个名字,这个名字在整个模版中必须唯一。

  • StreamName. 这是转码后的输出流的stream name. 你可以使用${SourceStreamName} 变量, 它将被输入流的stream name替换。一个应用内的输出流的名字必须唯一。你最好把输入流的stream name作为输出流的stream name的一部分。

  • Video/Codec. 视频编码的相关设置:
    • H.264. 转码为H.264 。也用于将H.264编码的输入流输出多个不同的码率或profile等等。
    • H.263. 转码为H.263.
      注意: 当使用硬件加速时,无法输出 H.263 编码的视频。如果你将 Video/Transcoder 设置为以下硬件加速方案 (QuickSync, CUDA, 或NVENC), 这个设置将被忽略,系统将使用默认的MainConcept软件编码器来生成H.263编码的视频。
    • PassThru. 将输入流的视频透传出来,不做任何变化。
    • Disable. 屏蔽掉视频流

  • Video/Transcoder. 转码的实现方案:
    • default. 系统内建的MainConcept软件编码器(非硬件加速).
    • QuickSync. Intel Quick Sync 的编码加速(支持Windows和Linux). 如果你的硬件不支持Quick Sync指令集,那么系统将使用不带硬件加速的MainConcept软编码技术。
      注意: 从Wowza Media Server 3.5.0版本开始,已经开始逐渐支持Linux系统上的Quick Sync Video,并将在后续的版本中完成全部的支持。
    • CUDA. NVIDIA CUDA 编码加速(仅针对Windows)。如果你的硬件不支持CUDA指令集,那么系统将使用不带硬件加速的MainConcept软编码技术。
    • NVENC. NVIDIA NVENC 编码加速(支持Windows和Linux)。如果你的NVIDIA 显卡不支持NVENC基于硬件的视频编码,那是带有新的Kepler GPU架构的大多数NVIDIA显卡都具有的能力。如果你的硬件支持它,那么系统将使用NVIDIA CUDA 的编码加速功能。如果你的系统不支持这些硬件编码加速的功能,那么系统将使用不带硬件加速的MainConcept软编码技术。
      注意: 从Wowza Media Server 3.6.0开始,系统已经支持NVENC编码加速功能。
  • Video/GPUID. 编码时需要的NVIDIA CUDA/NVENC 的GPUID。 Wowza Transcoder 可以使用多个NVIDIA 显卡; 然而,它无法自动在多个显卡之间做的负载均衡。因此你需要用这个参数直接指定其中一个显卡,如果它被设置为-1则意味着选择拥有最高容量GPU的那个。多个GPU 以0 开始编号,当Transcoder插件启动时,将检查每一个GPU。

  • Video/FrameSize.帧的图形大小相关设置:
    • letterbox. 保持输入流中帧的宽高比,并按输出流中帧的大小进行扩展,对空白处用黑色条块来填充。
    • fit-width. 调整高度,以保持输入流的宽高比。
    • fit-height. 调整宽度,以保持输入流的宽高比。
    • crop. 对视频图像进行放大和裁剪以适应一个设定的宽和高,但保持输入流的宽高比。
    • stretch. 对视频图像进行拉伸,以适应一个设定的宽和高。
    • match-source. 使用和输入流一样的宽和高。

  • Video/Crop. 对输入流视频图像进行裁剪。x,x,x,x 的值代表裁剪区域的像素位置,依次为左、右、上、下。不能和Video/SourceRectangle 一起使用。

  • Video/SourceRectangle. 只选择输入流图像的一部分进行编码. x,x,x,x 的值代表一个矩形区域,依次为上、左、宽度、高度。不能和Video/Crop 一起使用。

  • Video/Profile. 视频编码的profile:
    • baseline. 针对移动流媒体的最低复杂度的设置
    • main. 针对桌面和机顶盒流媒体的较高的复杂度的设置

  • Video/Bitrate. 输出流的码率, in bits per second (bps). The value is ignored if Video/Codec is set to PassThru. The ${SourceVideoBitrate} variable can be used and will be replaced with the video bitrate of the source stream.
  • Video/KeyFrameInterval. 关键帧的间隔:
    • FollowSource. 如果设置为true,采用和输入流一样的关键帧间隔。如果设置为false,那么将采用在Video/KeyFrameInterval/Interval 中的设置。
    • Interval. 一个整数,代表关键帧的间隔(单位秒)

  • Video/Overlays/Overlay. 像水印那样,设置一个图片,覆盖在图像上。你既可以在解码时设置这个图片,也可以在每一个输出流的编码时设置这个图片。如果你希望所有的输出流采用同样的设置,那么你可以在解码时设置这个图片。
    注意: 当Wowza Transcoder使用图片覆盖时,系统对图片的设置有明确的要求。要了解更多细节,请阅读Transcoder 对覆盖图片的要求
    • Enable. 设置为true 以使用覆盖图片. Overlays with a transparency require extra CPU resources.
    • Index. 图片覆盖的图层顺序
    • ImagePath. 图片的路径。支持GIF、JPEG、PNG以及BMP格式的图片文件。
    • CheckForUpdates. 当设置为true, Wowza Transcoder 插件将每隔750毫秒重新load一次图片(如果图片有修改,将获得最新图片)。
      注意: 当使用CheckForUpdates 特性以动态检测图片的更新时,请确定按单一的原子操作去更新图片。这将确保Wowza Transcoder 可以得到一个完整的图片文件。要了解更多关于原子文件更新,请阅读:
    • Opacity. 透明度。从0(完全透明)到100(完全不透明)之间的数值.
    • Location/XLocation/Y. 开始覆盖的起始坐标位置,可以是负数。
    • Location/WidthLocation/Height. 覆盖区域的宽度和高度。如果被设置为 ${ImageWidth}${ImageHeight}, 将使用图片的大小。
    • Location/Align. 默认的覆盖区域起始位置(horizontal,vertical)。合法的horizontal 包括 leftright以及 hcenter; 合法的vertical 包括topbottom以及vcenter。例如距离右下角10个像素的位置开始用图片覆盖:
      Code:
      <Location>
      	<X>-10</X>
      	<Y>-10</Y>
      	<Width>${ImageWidth}</Width>
      	<Height>${ImageHeight}</Height>
      	<!-- horiz: left, right, hcenter - vert: top, bottom, vcenter -->
      	<Align>right,bottom</Align>
      </Location>
  • Video/Parameters。为在编码时实现一些特殊的需求而设定的参数(为以后使用保留)。

  • Audio/Codec. 音频编码:
    • AAC. 采用AAC编码。
    • PassThru. 将音频透传,不做任何改动。
    • Disable. 将音频屏蔽掉。

  • Audio/Bitrate.音频的码率,(单位bps)。当Audio/Codec 被设置为 PassThru时,它将被忽略。可以使用 ${SourceAudioBitrate} 变量,如果这样设置,那么将采用输入流的码率。


模版细节: <Decode>...</Decode>

这个部分是解码时的设置。一个模版只有一个<Decode> 的设置.

  • Video/Deinterlace. 如果输入流是隔行扫描的,请设置为true

  • Video/Overlays/Overlay/[Elements]. 解码时的覆盖图片,和编码时的覆盖图片一样。如果在解码时用了覆盖图片,那么所有的输出流都将包括这个覆盖图片。注意,任何透明的覆盖图都需要额外的CPU资源。
    注意: 当Wowza Transcoder使用图片覆盖时,系统对图片的设置有明确的要求。要了解更多细节,请阅读Transcoder overlay image requirements.
  • Video/Parameters. 为在解码时实现一些特殊的需求而设定的参数(为以后使用保留).


模版细节: <StreamNameGroup>...</StreamNameGroup>

这个部分的设置是为了实现多码率自适应而定义的一个输出流的逻辑组。<Name> 是逻辑组的名字。<StreamName> 用于在使用Apple HLS、Adobe HDS或Microsoft Smooth Streaming流媒体技术时,为实现码率自适应而使用的stream name。例如,有一个 stream name为 myStream的输入流,然后将前面的逻辑组的stream name设置为myStream_all。 当对这个部分进行设置之前,你首先要定义每一个编码后的输出流,并确保它们可以正常播放。

用StreamName逻辑组实现多码率自适应


转码后的多个输出流之间是关键帧对齐的,用以实现码率自适应。Stream Name 逻辑组的作用和用同步多媒体集成语言Synchronized Multimedia Integration Language (SMIL)描述的播放列表文件的作用是一样。

为了播放码率自适应流媒体,各种播放技术采用的播放URL如下所示:

Apple iOS device (Apple HLS/Cupertino)
Code:
http://[wowza-ip-address]:1935/live/ngrp:myStream_all/playlist.m3u8
Adobe Flash Player (Adobe HDS/San Jose)
Code:
http://[wowza-ip-address]:1935/live/ngrp:myStream_all/manifest.f4m
Microsoft Silverlight (Smooth Streaming)
Code:
http://[wowza-ip-address]:1935/live/ngrp:myStream_all/Manifest
注意:
  • 要在逻辑组中包含原始的输入流,最好的办法是将输入流加入到一个<Encode> 中,然后将Video/CodecAudio/Codec 都设置为PassThru。同时<StreamName> 必须唯一。

  • 你可以为Apple HLS streaming 创建一个逻辑组,其中包含一个只有音频的输出流,类似在How to create Apple App Store compliant streams中的介绍。如果你要这么做, 你需要在逻辑组中添加一个 <MediaListRendition>元素,并且在它的里面设置一个 <WowzaAudioOnly>true的元素。下面是一个例子:
    Code:
    <StreamNameGroup>
    	<Name>all</Name>
    	<StreamName>${SourceStreamName}_all</StreamName>
    	<Members>
    		<Member>
    			<EncodeName>source</EncodeName>
    		</Member>
    		<Member>
    			<EncodeName>360p</EncodeName>
    		</Member>
    		<Member>
    			<EncodeName>160p</EncodeName>
    		</Member>
    		<Member>
    			<EncodeName>160p</EncodeName>
    			<MediaListRendition>
    				<WowzaAudioOnly>true</WowzaAudioOnly>
    			</MediaListRendition>
    		</Member>
    	</Members>
    </StreamNameGroup>

如何控制转码流程


默认配置下,所有的转码会话都使用一个转码模版。

按下面的配置,为每一个应用配置一个模版文件:

注意: 在下面的操作指南中,用你的应用名替换[application]
  1. 用一个文本编辑器打开[install-dir]/conf/[application]/Application.xml 文件,将Transcoder/Templates 设置为 [application].xml:
    Code:
    <Templates>[application].xml</Templates>
  2. [install-dir]/transcoder/templates/transrate.xml 文件拷贝并命名为 [install-dir]/transcoder/templates/[application].xml。这个文件将成为针对你这个应用的转码模版。


转码模版也可以只针对某一个输入流(stream name),请按下面操作进行:

注意: 在下面的操作指南中,将[streamName] 替换为你的输入流的stream name。
  1. 用一个文本编辑器打开[install-dir]/conf/[application]/Application.xml文件,将Transcoder/Templates 设置为 [streamName].xml:
    Code:
    <Templates>[streamName].xml</Templates>
  2. [install-dir]/transcoder/templates/transrate.xml 文件拷贝并命名为 [install-dir]/transcoder/templates/[streamName].xml。这个文件将成为针对这个流的转码模板。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多