Page 3 of 3

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 27 Jan 2020, 05:37
by malcev
Such situation means that PC is slow and You need to decrease FPS.

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 29 Jan 2020, 01:58
by malcev
Fixed inaccurate frame allocation algorithm.
Now consumes more CPU, but this is IMHO OK for real-time encoding.

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 29 Jan 2020, 14:48
by burque505
Hi malcev, thank for continuing to work on this, it's very interesting.
With the code from the first post for Win7, which appears to have been updated quite recently, I get this error:

Code: Select all

IMFSinkWriter_SetInputMediaType error: 
ErrorLevel: 0xc0000005
An empty *.mp4 is produced.
Your code from ~= December 14, 2019 (no sound) is working quite well on Win7.
Regards,
burque505

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 30 Jan 2020, 02:19
by malcev
As I understand this error occurs when You want to capture video with audio?
Try to capture video only.
Sorry, but I do not know why this error occurs to You.

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 30 Jan 2020, 09:08
by burque505
I get the same error when I comment out the following lines, if I'm understanding you correctly.

Code: Select all

;audiodevice := "Microphone (HD Webcam C270)"
; x1 := 100, x2 := 1000, y1 := 100, y2 := 500
; ShowAllAudioDevicesNames := true
; CaptureCoordinatesWithCPU := true
; Rotate := true
I will try the Win10 code on Win10 to see if I have better luck.
Thanks again.
Regards,
burque505

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 02 Feb 2020, 12:47
by malcev
Update code in first post.
Add some options, reduce CPU consumption and fix bugs.
@burque505, as I understand from PM, Your hardware encoder does not let use MF_SINK_WRITER_DISABLE_THROTTLING attribute.
Therefore You have 2 choices:
Uncomment "UseSoftwareEncoding := true" to use software encoding.
or
Comment

Code: Select all

IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_SINK_WRITER_DISABLE_THROTTLING"), true)

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 02 Feb 2020, 13:53
by burque505
Thank you, @malcev. What you say does not surprise me as my video card is over ten years old. I really appreciate you staying on top of this, it's working quite well.
Regards,
burque505

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 06 Feb 2020, 16:05
by TheDewd
hardware-encoder - NVIDIA H.264 Encoder MFT

Cannot find Audio device - "CABLE Output (VB-Audio Virtual Cable)"

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 06 Feb 2020, 16:27
by burque505
@TheDewd, you might try this first:

Code: Select all

file := "test.mp4"
video_bitrate := 2000000
video_fps := 25
duration := 5
capture_cursor := true
;audiodevice := "Microphone (HD Webcam C270)"
; audiodevice := "CABLE Output (VB-Audio Virtual Cable)"
; x1 := 100, x2 := 1000, y1 := 100, y2 := 500
ShowAllAudioDevicesNames := true
; CaptureCoordinatesWithCPU := true
; Rotate := true
You'll get a MsgBox with whatever audio device(s) show up. Then you can comment out the 'ShowAllAudioDevicesNames := true (Edit: epic fail - or set it to 'false', I suppose) and add in 'audiodevice:=' with your device.
Regards,
burque505

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 06 Feb 2020, 16:46
by TheDewd
@burque505,

Excellent!

Code: Select all

done
125 captured
0 frames dropped

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 06 Feb 2020, 16:50
by burque505
:+1:

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 15 Feb 2020, 07:47
by malcev
Update first code.
1) Add quotes when enumerate devices.
2) Add support for enumerating devices with the same name
3) Now You can write ShowAllAudioDevicesNames := false.

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 15 Feb 2020, 09:11
by burque505
Hi @malcev, getting this error on Win7 again with the code from 15 February:

Code: Select all

IMFSinkWriter_SetInputMediaType error: 
ErrorLevel: 0xc0000005
Code from 31 January is still working fine.
Regards,
burque505

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 15 Feb 2020, 22:16
by malcev
Strange. Do You get this error after:
Uncomment "UseSoftwareEncoding := true" to use software encoding.
or
Comment

Code: Select all

IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_SINK_WRITER_DISABLE_THROTTLING"), true)
?

Re: Screen capture to video with Directx9 / Directx11 and Microsoft Media Foundation

Posted: 16 Feb 2020, 09:07
by burque505
@malcev, both of your fixes work fine for me.
Thanks!
Regards,
burque505