Results 1 to 18 of 18

Thread: 4K Video Play

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    368

    4K Video Play

    Can VB6 play a .mp4 4K movie ?
    I built a VB6 app using Quartz but it does not play.

    My app will play lower rez movies.

    I am Windows 7 Pro.
    Do I need a very fast CPU or better video hardware than my laptop?
    How do i determine necessary hardware ?

    Suggestions please.

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,909

    Re: 4K Video Play

    Quartz should be able to utilize GPU for playback. but u need to render it into direct2d/directx surface.
    I have never done that, but I know its possible to set the rendering target.

  3. #3
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

  4. #4
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,909

    Re: 4K Video Play

    Im in windows 10
    I get this error fafalone

    Line 36: Cannot load control Slider2; license not found.
    Line 50: Cannot load control Slider1; license not found.

    also why are u using Controls 5.0 (SP2) and not Controls 6.0?
    but removing the slider completely the player works.
    Last edited by baka; Mar 25th, 2025 at 03:30 AM.

  5. #5
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    The IMFPMediaPlayer interface is actually outdated. You should use the IMFMediaEngine(Ex) interface, at least starting with Windows 10. MediaFoundation can play MP4 in H.264 and H.265 formats. To play videos in H.265 format, you must also install the H.265 / HEVC video codec from the Windows Store.

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    They're just the regular common controls like in all my projects... vb6 sp6 + security updates.

    The "5.0" controls are the only way to get visual styles and a few modern features. They're the more recent version of the underlying control --- because it's dynamically linked to the current comctl32.dll, while the "6.0" control is statically linked to a frozen in time 1998 version.

  7. #7
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    Quote Originally Posted by -Franky- View Post
    The IMFPMediaPlayer interface is actually outdated. You should use the IMFMediaEngine(Ex) interface, at least starting with Windows 10. MediaFoundation can play MP4 in H.264 and H.265 formats. To play videos in H.265 format, you must also install the H.265 / HEVC video codec from the Windows Store.
    IMFMediaEngine is far more complicated for simple playback and doesn't support Win7 which the OP explicitly mentioned as the target.

    Right now it's like a thousand other things where MS wants you to use something newer, but it's not going anywhere because the new thing is a step down.

  8. #8
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    Quote Originally Posted by fafalone View Post
    IMFMediaEngine is far more complicated for simple playback and doesn't support Win7 which the OP explicitly mentioned as the target.
    Right now it's like a thousand other things where MS wants you to use something newer, but it's not going anywhere because the new thing is a step down.
    Okay, I actually overlooked the Win7 thing. I haven't actually tried the IMFPMediaPlayer interface, so I can't confirm that the IMFMediaEngine(Ex) interfaces are more complicated. I didn't find the IMFMediaEngine(Ex) interfaces to be complicated.

  9. #9

  10. #10
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    Quote Originally Posted by -Franky- View Post
    Okay, I actually overlooked the Win7 thing. I haven't actually tried the IMFPMediaPlayer interface, so I can't confirm that the IMFMediaEngine(Ex) interfaces are more complicated. I didn't find the IMFMediaEngine(Ex) interfaces to be complicated.
    Ok well I'm sure whatever you *do* find complicated, there's someone who's wondering why *you* don't think it's simple

    But ucSimplePlayer and cMFPlayer.cls aren't very far apart feature wise and there's a 3500 line difference between them, so I think relatively most would say low level details like topology nodes and synchronization clocks taking 4k lines to implement a basic player around are a tiny bit more complicated.

  11. #11
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    Not complex... why does IMFMediaEngine as implemented by your cMFPlayer class/player demo not play .mkv files, while IMFPMediaPlayer does?

    CreateVideoDisplayControl/CreateVideoProcessor/CreateVideoMixerBitmap fail (you need to create 3 different video objects just to play? Complicated )

    (I can't find a 4K MP4 without HDR/DV which I can't use in anything right now; but 4K MKVs play fine in IMFPMediaPlayer/ucSimplePlay, pretty sure they're the same codec underneath the container).

    Edit: Might have spoken too soon; it's not playing the audio for .mkv

    Edit2: Lol typical Microsoft... I installed the MF AC-3 codec for the audio, and it broke video playback entirely.

    Edit3: Wow, evil #(&#(^&@ers. Their *audio codec* requires the "Microsoft Account Sign-in Assistant" service to be enabled, even if you're on a local account without the MS Store installed. Once their spyware service is enabled both video and audio started working. This is the solution if you get error 0x80070426 after a store-free install of the DolbyLaboratories.DolbyDigitalPlusDecoderOEM codec you need so the common AC-3/E-AC3 audio plays, which wasn't preinstalled on my Windows 10 1809. It appears you can disable the service again after the first time you use the codec (though I haven't rebooted to see if it sticks after that).
    Last edited by fafalone; Mar 26th, 2025 at 01:27 AM.

  12. #12
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    @fafalone: I don't know what you mean by "complicated." Otherwise, there are a few websites where you can download 4K MP4 test videos (e.g. from here: https://de.videezy.com/gratis-video/...lution-4k=true). I even took the liberty of using your TLBs. My first project with your TLBs.
    Code:
    Option Explicit
    
    
    Implements IMFMediaEngineNotify
    
    
    Private MFMediaEngineClassFactory As IMFMediaEngineClassFactory
    Private MFMediaEngine As IMFMediaEngine
    Private MFMediaEngineEx As IMFMediaEngineEx
    
    
    Private Sub Form_Load()
        If MFStartup(MF_VERSION, 0&) = S_OK Then
            If CoCreateInstance(CLSID_MFMediaEngineClassFactory, _
                                Nothing, _
                                CLSCTX_INPROC_SERVER, _
                                IID_IMFMediaEngineClassFactory, _
                                MFMediaEngineClassFactory) = S_OK Then
                Dim MFAttributes As IMFAttributes
                Call MFCreateAttributes(MFAttributes, 0&)
                Call MFAttributes.SetUnknown(MF_MEDIA_ENGINE_CALLBACK, Me)
                Call MFAttributes.SetUINT32(MF_MEDIA_ENGINE_AUDIO_CATEGORY, AUDIO_STREAM_CATEGORY.AudioCategory_Media)
                Call MFAttributes.SetUINT32(MF_MEDIA_ENGINE_AUDIO_ENDPOINT_ROLE, ERole.eMultimedia)
                Call MFAttributes.SetUINT64(MF_MEDIA_ENGINE_PLAYBACK_HWND, CCur(Me.hWnd) / CCur(10000))
                Call MFMediaEngineClassFactory.CreateInstance(0&, MFAttributes, MFMediaEngine)
                Set MFAttributes = Nothing
    
    
                Set MFMediaEngineEx = MFMediaEngine
                Call MFMediaEngine.SetSource("d:\hidden_beach_hawaii_4K.mp4")
                Call MFMediaEngine.Play
                
            End If
        End If
    End Sub
    
    
    Private Sub Form_QueryUnload(Cancel As Integer, _
                                 UnloadMode As Integer)
    
    
        MFMediaEngine.Pause
        MFMediaEngine.Shutdown
    
    
        Set MFMediaEngineEx = Nothing
        Set MFMediaEngine = Nothing
        Set MFMediaEngineClassFactory = Nothing
        
        Call MFShutdown
    End Sub
    
    
    Private Sub IMFMediaEngineNotify_EventNotify(ByVal lEvent As Long, _
                                                 ByVal param1 As oleexp.LongPtr, _
                                                 ByVal param2 As Long)
        Select Case lEvent
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_LOADSTART
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_PROGRESS
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_SUSPEND
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_ABORT
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_ERROR
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_EMPTIED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_STALLED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_PLAY
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_PAUSE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_LOADEDMETADATA
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_LOADEDDATA
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_WAITING
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_PLAYING
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_CANPLAY
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_CANPLAYTHROUGH
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_SEEKING
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_SEEKED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_TIMEUPDATE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_ENDED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_RATECHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_DURATIONCHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_VOLUMECHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_FORMATCHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_TIMELINE_MARKER
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_BALANCECHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_DOWNLOADCOMPLETE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_BUFFERINGSTARTED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_BUFFERINGENDED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_FRAMESTEPCOMPLETED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_NOTIFYSTABLESTATE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_FIRSTFRAMEREADY
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_TRACKSCHANGE
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_OPMINFO
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_RESOURCELOST
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_DELAYLOADEVENT_CHANGED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_STREAMRENDERINGERROR
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_SUPPORTEDRATES_CHANGED
        Case MF_MEDIA_ENGINE_EVENT.MF_MEDIA_ENGINE_EVENT_AUDIOENDPOINTCHANGE
        End Select
    End Sub
    For me this code plays the MP4 without any problems. I have already written here how to get the free HEVC video codec from the Windows Store without using the Windows Store so that H.264/H.265 videos can be played.

  13. #13
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    That does also play MKVs but I was going by the documented examples from MS and your existing demo, didn't know there was a 100x simpler way.

    IMFPMediaPlayer in ucSimplePlayer also handles the 4K MP4 fine. I've got to update that, just testing a possible new fullscreen method.

    And see wasn't that so much nicer with a TLB
    Just wait til you join the future in tB where it's the best of both worlds, interfaces can be defined within the project so no TLB file and still can make quick changes like DispCallFunc.
    Last edited by fafalone; Mar 26th, 2025 at 04:46 AM.

  14. #14
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    Quote Originally Posted by fafalone View Post
    And see wasn't that so much nicer with a TLB
    Just wait til you join the future in tB where it's the best of both worlds, interfaces can be defined within the project so no TLB file and still can make quick changes like DispCallFunc.
    I agree with you, it's easier using a TLB. But... Some functions return an HRESULT, which I miss in your TLB. I can only call the function via a Call, and I don't have an HRESULT. Your TLB contains the following: IMFMediaEngineNotify_EventNotify(ByVal event As Long, ... VB6 complains about the "event," so I changed it to "lEvent." That's why I'm taking the difficult route via DispCallFunc to avoid such things.


    I have tB installed, but haven't really gotten around to looking into it yet. I know that you can define COM interfaces in tB without a TLB. VanGoghGaming has already provided some nice examples. In principle, it's almost exactly how I would do it in VB.NET.

  15. #15
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    Yeah it's definitely stupid how VB6 doesn't allow Implements if you change it to a function that returns the HRESULT... that's why I never changed that. Still though that's *a lot* of work just to avoid that minor inconvenience, since a bad HR triggers an error.

    ---

    In tB, you have Err.LastHResult, so you can get it even if it's not a function (tB doesn't support Implements with HRESULT-returning versions either yet).

    While my oleexp.tlb works in tB, it's superseded by 'Windows Development Library for twinBASIC' (few to no changes to switch)... it covers everything from oleexp.tlb and more interfaces (2800+ total, but doesn't cover any of your WinRT stuff), then also 8500+ APIs and associated types/consts, and helper functions. You can use that, but then if you want an HRESULT returning version, just copy it into your local project and switch Sub foo() to [PreserveSig] Function foo() As Long.

    Your projects generally work as-is (I'm a big fan, you've got so many great ones!), minus some changes to replace assembly thunk internals hacks-- those won't ever be supported but in almost every case there's a much simpler way to do it in tB, e.g. tB supports AddressOf on class members so you can self-sub with the normal SetWindowSubclass and use API timers in classes/forms/ucs.

  16. #16
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    Quote Originally Posted by fafalone View Post
    Yeah it's definitely stupid how VB6 doesn't allow Implements if you change it to a function that returns the HRESULT... that's why I never changed that. Still though that's *a lot* of work just to avoid that minor inconvenience, since a bad HR triggers an error.
    I was a bit confused by the fact that the MFStartup API returns an HRESULT (As Long) from the TLB, but IMFMediaEngineClassFactory::CreateInstance, for example, doesn't. It's not a big deal, and I can live with it.

    Quote Originally Posted by fafalone View Post
    Your projects generally work as-is (I'm a big fan, you've got so many great ones!), minus some changes to replace assembly thunk internals hacks-- those won't ever be supported but in almost every case there's a much simpler way to do it in tB, e.g. tB supports AddressOf on class members so you can self-sub with the normal SetWindowSubclass and use API timers in classes/forms/ucs.
    Thanks. My examples are just meant to demonstrate how it works. The fact that I use a few small hacks when not using TLB is a minor side effect. It's not nice, but it serves the purpose.

  17. #17
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,966

    Re: 4K Video Play

    APIs are never used with Implements so there's never any hesitation to change them. For IMFMediaEngineClassFactory, since it's unlikely it would ever be used with Implements I can certainly change that one to return the HRESULT instead of leave it to VB. Probably the case for a lot of the MF interfaces, but then I was surprised by a number of DirectX interfaces I never thought would be that are, so I'd be hesitant to go change them all.

  18. #18
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: 4K Video Play

    Quote Originally Posted by fafalone View Post
    APIs are never used with Implements so there's never any hesitation to change them. For IMFMediaEngineClassFactory, since it's unlikely it would ever be used with Implements I can certainly change that one to return the HRESULT instead of leave it to VB. Probably the case for a lot of the MF interfaces, but then I was surprised by a number of DirectX interfaces I never thought would be that are, so I'd be hesitant to go change them all.
    Leave everything as it is. It would just be a bonus for interfaces that aren't integrated via implements. For me, you don't need to make any extra adjustments to the TLB.

    FYI: Why it makes sense to return the HRESULT, except for interfaces that are implemented via Implements. IMFMediaError::GetExtendedErrorCode is a sub in your TLB and therefore doesn't return an HRESULT in VB6. Don't take this as a criticism of your TLB.
    Last edited by -Franky-; Mar 27th, 2025 at 10:47 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width