ofxDSHapVideoPlayer (Windows)


#1

Hey folks,

As part of Second Story in Portland, I wanted to share a brand new addon with the community:

ofxDSHapVideoPlayer is a DirectShow-based video player that plays Hap-encoded video files. As you may already know, Hap is a video codec that uses the GPU for decompressing video frames – making it fast and low overhead. Over at Second Story, we’ve been using it to synchronize HD video across multiple computers. Unlike the QuickTime-based version of the codec, ofxDSHapVideoPlayer decompresses the frames on the GPU natively on Windows using a mixture of snappy (optional) and DXT (the downside of this approach is that we don’t have access the the decompressed pixels on the CPU).

The Hap codec was originally released and open sourced by Tom Butterworth for VDMX. ofxDSHapVideoPlayer uses parts of Theo Watsons’s DirectShow video player (https://github.com/ofTheo/ofDirectShowVideoPlayer) and code from RenderHead’s DirectShow version of the Hap codec (http://renderheads.com/product/hap-for-directshow/).

Please give it a whirl and let us know if you have any issues or requests!

Thanks (and hope that it’s useful)!

Jeremy


ofDirectShowPlayer reverse playback
#2

I’m glad you did this, I had every intention of making a port once they made the DS drivers but then got sidetracked with real life.


#3

Hey Jeremy!
Great work on this addon, it’s just what I was looking for :slight_smile:
I’m a little unclear on how to actually encode Hap videos on Windows. I’ve got the codec installed, I can play back Hap videos and use the OF addon, but I don’t see any option for encoding Hap in Adobe Media Encoder. Is there a separate installer or separate step that’s needed?
I’m on Windows 10 and Adobe Media Encoder CC 2015.3
Thanks


#4

Hey @prisonerjohn!!

This player is specifically for videos encoded using the Hap encoder for Direct Show (files are saved in .avi containers as opposed to .mov). At Second Story, we’ve been transcoding files using Adobe Media Encoder. You’ll want to install the codec that RenderHeads released for this purpose: http://www.renderheads.com/downloads/2015/HapDirectShowCodecSetup.exe

Hope that helps!


#5

Yeah, I did all that but can’t seem to find an option in Adobe Media Encoder to use the Hap codec. Should it appear under the AVI container or is there somewhere else I should be looking?


#6

Just opened up Media Encoder to verify …

When I set the format to AVI, Hap (and its related options) show up in the list of available Video Codecs. Sounds like you’re not seeing it on your setup.

I haven’t tested on Windows 10. Wonder if that could be the issue.

There’s a tool that we’ve used at Second Story to display Direct Show filters and codecs, but I can’t seem to find it. @silverbahamut could probably chime in on this.

This site also provides instructions on viewing the codecs installed on your PC (see #3)


#7

Aaah I was looking in the Presets dropdown just below instead of the Video Codecs further down. I knew it was something silly :blush: Thanks for looking on your end!


#8

Ah great, glad that you figured it out.

This is the Direct Show filter viewer I’d mentioned earlier: http://bluesky23.yukishigure.com/en/DsfMftViewer.html


#9

Hi Jeremy,

Great work on this addon! It works perfectly for playing multiple HD streams.

I have a project where I need to route audio from multiple videos to individual audio outputs. (video 1 -> output 1, video 2 -> output 2, … video 8 -> output 8). I am wondering about the possibility of editing the player to support this and if you have any tips for where to start.

I have used this addon in the past to get what I need with just sound files.

Thanks for creating this and sharing with the community!


#10

hi @acheson,

that sounds totally do-able! but you’ll have to dig into the guts of the add-on to connect the audio channels on the video to appropriate audio channel.

take a look at this class:

there’s a function called loadMovieManualGraph() which connects all of the direct show filters. i imagine that you’ll be specifically looking at the sound component that’s contained inside the if statement containing getContainsAudio(). i’d encourage you to read up on direct show filters and use some of the available functions in this class for connecting inputs and outputs. unfortunately i have little familiarity with multichannel audio outputs in direct show.

hope that helps!!


#11

Hi Jeremy,

I happened to find that function, so I’m glad to hear I’m looking in the right place! DS filters are new territory for me, but I am making some good progress. I’ll share my results.

Thanks again!


#12

Hi @mantissa,

I forked the repo and a new function that allows you load a movie and pass it the audio device index. (My setup is using multiple USB sound cards.) It iterates through all the sound devices and creates a filter that routes to the one selected.

You can check out the code here if you’re interested.
https://github.com/acheson/ofxDSHapVideoPlayer

Cheers!
Rob


#13

@acheson nice! i’m happy to see that you figured it out.

i’m curious, is there a way to get a list of all the device names so that you can properly select which device index you want?


#14

Hey @mantissa

Yes you can do that pretty easily. This example shows it well

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370812(v=vs.85).aspx

Rob


#15

Hey Jeremy (@mantissa) and all,

I’m trying out this addon to get better performance on a very simple kiosk, but I’m running into a nullptr exception on filter

filter->EnumPins(&enumPins);

in getInputPin:

IPin * getInputPin(IBaseFilter * filter, bool &success)
{
    IEnumPins * enumPins;
    IPin * pin;
    ULONG fetched;
    PIN_INFO pinfo;
    filter->EnumPins(&enumPins);
    enumPins->Reset();
    enumPins->Next(1, &pin, &fetched);
    pin->QueryPinInfo(&pinfo);
    pinfo.pFilter->Release();
    if (pinfo.dir == PINDIR_OUTPUT){
        pin->Release();
        enumPins->Next(1, &pin, &fetched);
    }
    if (pin == NULL){
        success = false;
    }
    else
    {
        pin->QueryPinInfo(&pinfo);
        pinfo.pFilter->Release();
        if (pinfo.dir != PINDIR_INPUT)
        {
            success = false;
        }
    }
    enumPins->Release();

    return pin;
}

The app runs fine with the example .avi from the VDMX site, but breaks on the one I encoded with Adobe Media Encoder. Any pointers? :slight_smile: Running on Windows 10, btw.


#16

@ptterb,
what position in the BufferCB() does this crash? getInputPin() gets called a number of times.
feel free to share the video as well.
jeremy


#17

@ptterb I’ve been trying to encode files too and have had no luck whatsoever, did you figure something out in the end?


#18

hey @oscarw,
i just tested a the addon with a file created using mpegstreamclip and experienced the same behavior you were describing (yellow bars).
digging into the code, it looks like mpegstreamclip (and probably the other applications) are not including a frame size in the header (it’s set to zero), so the addon ends up creating an empty array for the pixel.
i just pushed a fix-hopefully that will solve your problem.
thanks!
jeremy


#19

Hi @mantissa

Thanks so much for looking into this. I’ve tried this with a lot of files now and it’s still showing up as yellow stripes

It logs “Video frame size not encoded in file header” as I’d expect given that’s the if clause you added for the fix
However, the addon also now logs “SampleCB<> - raw buffer is NULL” as well. I’ve had a look through the code that throws it and I haven’t been able to figure out what’s causing it

Should I be doing something special with MPEGStreamclip? I’ve tried a variety of encoding options to no avail and I’ve looked through some information on my file and the sample one that does work and as far as I can tell they’re identical - although there must be something causing it?! I’ve double checked I have everything installed that I should

If its any help, I’m using VS 2015 update 3 on Windows 8 Embedded Standard (which I still haven’t ruled out a being part of the problem) and I’m compiling for Win32. I’ve tried compiling for x64 which comes up with a linker error

If you can shed any light on this I’d be so grateful, we’re supposed to be presenting something next Thursday and an audio visual installation without any visuals won’t be quite so interesting!


#20

@oscarw, sorry to hear that. please post one of your problematic files and i’ll take a look into it. i’m curious if your file is just RGB or contains an alpha channel.

i didn’t use any special settings for mpegstreamclip–just the defaults for HAP.

also worth checking what the value of videoSize is (in ofxDSHapVideoPlayer.cpp) and if it makes sense for the resolution of your video (i.e. 1280 x 720 x 3 = 2764800).

ps-the SampleCB error is just a timing issue that happens every now and then.