Tag Archives: H.264

Live H.264 streaming from Digital Rapids to Helix and Wowza

Helix Mobile Server 14

I had a few difficulties with getting this set up so it’s probably worth sharing them here. Digital Rapids apparently don’t support live broadcasting from their hardware encoder companion software ‘Stream’ to Helix Mobile Server even though the latter supports RTP and SDP, and the encoder clearly offers these up as possible exports when you’re using the Digital Rapids AVC for Web codec profile (an optional extra purchase):

Stream encoder RTP broadcast SDP settings

What happens is that when you copy the SDP file into your Helix server’s Content/rtpencodersdp folder and try to connect to the stream pointing a media player at rtsp://helixserver/rtpencoder/live_stream.sdp it will fail, with the following error appearing in rmerror.log:

21-Sep-2010 13:47:14.062 tmplgpln(6076): 32: Error retrieving URL `rtpencoder/live_stream.sdp’ (Invalid path)

Following contact with Helix support, it turns out that the SDP file which the encoder creates does not declare the bandwidth of the audio track using a b= line as per RFC 4566 – though apparently this is an optional field. You will need to manually add this. 64Kbps results in b=AS:64 as below:

v=0
o=- 1287599430 1287599438 IN IP4 10.45.0.155
s=Session Streamed by Digital Rapids Corp Stream Server
t=0 0
a=type:broadcast
c=IN IP4 10.45.0.150/15
m=audio 20002 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/90000/2
a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;bitrate=64000;config=1390
a=control:trackID=1
b=AS:64
m=video 20000 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4D4020;sprop-parameter-sets=J01AIJZWDQ/8mApEAAADAAQAAAMAyhA=,KO8GDMg=
a=cliprect:0, 0, 416, 234
a=control:trackID=2

I also discovered that QuickTime Player is not a reliable player to use for testing as it sometimes crashes, and will not play H.264+AAC streams which VLC has no issue with. This view was echoed by Helix support.

I did have another problem – one of aspect ratios. The Digital Rapids Stream encoder will author files with garbage aspect ratio metadata if the resolution isn’t exactly 16:9 to the nearest even number of pixels. I read somewhere else that the chosen picture width should be a multiple of the x part of the aspect ratio. Here is FFMPEG’s analysis of a non-compliant resolution:

Stream #0.0(eng): Video: h264, yuv420p, 412×232 [PAR 37376:14889 DAR 401453:90053], 399 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc

and a correct 16:9 resolution:

Stream #0.0(eng): Video: h264, yuv420p, 416×234 [PAR 1:1 DAR 16:9], 399 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc

 

Wowza Media Server 2.1.2

Setting this up was also a little bit confusing, given that the encoder offers you so little insight into what the problem is if it doesn’t start. Anyway, there are excellent tutorials on the Wowza forums – this is the one we need.

As you can see from the screenshot I run Wowza Media Server on port 80 rather than 1935 to make sure that clients using restricted and proxied wifi networks (hotels etc.) are not prevented from viewing the streams:

Digital Rapids Stream RTMP media server settings

There is a gotcha though. In the forum tutorial they mention setting up security, but this is only for RTP encoders, not RTMP. I had been setting the credentials in the dialog above, but in fact you need to leave the drop-down on Server with no password.

Fortunately you can secure RTMP stream publishing in Wowza – you will need to make the following additions to live/application.xml to invoke an additional module:

       <Module>
              <Name>ModuleSecureURLParams</Name>
              <Description>ModuleSecureURLParams</Description>
              <Class>com.wowza.wms.plugin.security.ModuleSecureURLParams</Class>
       </Module> 
</Modules>
<!-- Properties defined here will be added to the IApplication.getProperties() and IApplicationInstance.getProperties() collections -->
<Properties>
       <Property>
              <Name>secureurlparams.publish</Name>
              <Value>mysecret4231.doPublish</Value>
       </Property>
</Properties>

You would then append this secret as a query string on the stream name as below:

Security settings for RTMP stream publishing

The mount point for testing with VLC for this example would be still be rtsp://10.45.0.151:80/live/mystream
or from an iPhone http://10.45.0.151/live/mystream/playlist.m3u8 (assuming AVC Level 3.0 or lower and standard AAC audio).

DXVA H.264 playback on Intel GMA 500 with subtitles (Windows 7)

Update – This guide was updated on 04/04/2012

Out of the box, Windows 7’s Windows Media Player (WMP) will play HD video using the Intel GMA 500 and DirectX Video Acceleration (DXVA) to do the decode. Using the Matroska Splitter you will also be able to play MKV files. However, they may occasionally stutter and use a fair amount your humble Atom Z series CPU’s power (around 40-50% of 1.33GHz), and you won’t be able to use subtitles.

The PowerDVD H.264 decoder on the other hand will use about 10-20% less CPU, is less prone to locking up, and by using Media Player Classic Home Cinema (MPC-HC) you gain subtitle rendering support. Apparently PowerDVD does itself support MKVs with subtitles but on the several occasions I have attempted this with the trial version it has locked up and crashed. If you don’t have the PowerDVD decoder, you can use the ‘ffdshow tryouts’ open source decoder which is a very good alternative, but seems to suffer some screen tearing during high motion scenes while subtitles are enabled.

Ingredients

  • Media Player Classic Home Cinema (MPC-HC 1.60.4014 at the time of updating this document) – don’t confuse with Media Player Classic, this is a separate version
  • Matroska Splitter (optional) – this reads the MKV container format. MPC-HC has its own implementation included but you could use this if you want to play MKV files in Windows Media Player
  • Optional DirectVobSub subtitle renderer for Windows Media Player (will not work for MKVs), useful for Xvid/DivX files though
  • PowerDVD’s H.264 decoderĀ CyberLink Combo MPEG-2/H.264/VC1 Decoder v.1.0.4960.3320
  • or ffdshow tryouts decoder – don’t use the beta release, it doesn’t have the DXVA decoder. I tested with the SVN build.
  • DirectX End-User Runtimes (June 2010) – required for the EVR Custom Presenter renderer which is needed for subtitle compositing

Method

Firstly disable Aero.

If you want to have subtitles in WMP for Xvid/DivX movies then download and register vsfilter.dll. To do this, copy the DLL to C:\Windows\System32 and open a Command Prompt using right-click & “Run as Administrator”. Then type
regsvr32 c:\windows\system32\vsfilter.dll

If later on you want to remove this, just open the Command Prompt as Administrator and type
regsvr32 /u c:\windows\system32\vsfilter.dll

When it’s registered you can open an Xvid AVI file in WMP and, as long as there’s an SRT subtitle file with the same filename as the AVI then you will see your subtitles. There will be a new icon in the system tray which will allow you to toggle subs, as well as choose the language if there are several sets of subs.

Now install Haali Splitter if you want MKV support in WMP and other players. When you load a MKV, it behaves in a similar way to VSFilter (icon in systray), except it’s even more versatile since MKV containers can have different soundtracks too.

Next, install MPC-HC.

Now use WinRAR to extract the DirectX End-User Runtime file you downloaded. In WinRAR, select File > Open, then change the filename dropdown from All archives to All archives including self-extracting. Browse to your downloaded directx_Jun2010_redist.exe and open it. Inside you will find some more archives. Drag and drop to extract the file Jun2010_d3dx9_43_x86.cab, then open this in WinRAR too. Extract the file d3dx9_43.dll into the folder C:\Program Files\Media Player Classic – Home Cinema.

Finally, install the Cyberlink H.264 decoder or ffdshow. During setup ffdshow will offer a choice of decoders to use, pick libavcodec (not ffmpeg-mt).

Now we need to configure MPC-HC. Load it then go to View -> Options.
Go to Playback, and make sure Auto-load subtitles is set (assuming you want them). Note that you can also set language code preference orders for audio and subs:

Auto load subtitles

Move to the section called Output. If you will never use subtitles select EVR and don’t touch anything else.
If you do want subtitle support, use EVR Custom Presenter, reduce the EVR buffers from 5 to 4, and check the Alternative Vsync and D3D Fullscreen boxes. With the default settings the additional load of compositing subtitles brings the framerate down below 24fps, however by using these last two options we can just maintain 24fps.

Output settings

Now select the heading Internal filters and uncheck both H.264 options on the right. This stops MPC-HC using its own support for those features, since we’re going to use external modules for those. If you’re using the CyberLink Video Decoder version I posted above you can optionally uncheck the MP4/MOV and MKV source filters which will cause the CyberLink ones to be used instead (it doesn’t seem to improve performance).

Internal filters

Under the heading External Filters click Add. Then browse to the CyberLink Video Decoder and add it. Make sure to set it to Prefer on the right as shown. If you’re using ffdshow then instead add ffmpeg DXVA video decoder an set to Prefer.
If you installed the Vsfilter.dll subtitle driver (some other media players/codec packs will register this) we need to add DirectVobSub (auto-loading version) too, but select Block on the right. This prevents it from loading, since we’re using MPC-HC’s subtitle renderer. Apparently the way DirectVobSub renders is fundamentally incompatible with DXVA:

External filters

Close MPC-HC for the settings to take effect. At this point it’s a good idea to associate .mkv files with MPC-HC. If videos are launched by double clicking like this, when you pin MPC-HC to your Start Menu it will have that child menu showing you the last ten or so files you launched which is very useful.

Start an H.264 encoded MKV in MPC-HC and as it starts to play, right-click on the video window and select Filters -> CyberLink Video Decoder. Check that DXVA is selected. I believe that HAM mode uses OpenCL on GPUs that support it (the GMA 500 doesn’t) which if I remember was recommended for ATI GPUs, the early ones having glitchy DXVA implementations apparently. If you’re using EVR Custom Presenter you wont be able to do this with D3D Fullscreen enabled, so toggle it and reload MPC-HC to verify this step.

CyberLink decoder filter settings

Close and reopen MPC-HC and you should be done! Though using D3D Fullscreen reduces tearing and seems to keep the framerate higher when using the EVR Custom Presenter renderer you cannot right-click and see the normal MPC-HC GUI elements. You have to use Ctrl-C to exit playback to modify settings. Two essential keyboard shortcuts are A to switch audio track, and S to switch subtitle track, though shortcut keys do exist for just about everything, and can be customised in the Player > Keys menu in Options.

If using ffdshow you also need to enable hardware acceleration by running Start Menu > All Programs > ffdshow > DXVA video decoder configuration:

DXVA decoder settings

ffdshow’s built-in subtitle rendering seems to produce smeary artifacts on the picture so ignore those options and use MPC-HC’s subtitles instead.

If you have a video that won’t playback nicely with this setup then it’s likely that the bitrate is too high for the GMA 500 to cope with (a straight 1:1 rip from Blu-ray for instance) or perhaps the file has not been encoded to be fully DXVA compliant (quite likely with older stuff). Framerates over 24fps cannot really be played unfortunately.
There are some H.264 movie trailers available here for testing.
In my experience the GMA 500 in my VAIO P will play most 1080p content perfectly well, even outputting to a TV at 1920 x 1080. If in doubt about whether it’s dropping frames, while using EVR Custom Presenter you can press CTRL-J several times to view the frame rate (get rid of the graph and verbose text – they slow it down even more!).

Further reading

This handy guide explains in detail what all the options in MPC-HC mean.

Continue to DXVA VC-1 playback on Intel GMA 500 or learn how to get a surround sound experience from ordinary headphones.