Changes to the python API for Kodi Krypton - RenderCapture
#1
Referring to: 2191068 (post)

I read through the thread for the pull request before posting this, but something remains unclear to me.
"
xbmc.RenderCapture().getImage()
- added the option to specify wait time in msec.
"

It's not clear to me if:
1) including the 'wait time' as a parameter causes the code to wait that specified amount of time before copying an image out of the buffer?
or
2) is it a timeout such that the function returns after that amount of time if no image is available to be copied out of the buffer?

If it is 1), then what happens if the code is called when no video is playing? Will that hang?
If 2) what does the function return if the timeout is reached?

My apologies in advance that my cpp skills are insufficient to answer this by reading through the code of the PR. I actually did try.
Reply
#2
After biting the bullet and downloading the most recent Krypton nightly for windows, I have discovered several things:

1) The 'wait time' does not function as waiting the amount of time specified and then returning a frame.
2) If no video is playing and you call the function it returns immediately with a bytearray of length 0, regardless of the 'wait time'.
3) The highest achievable frame rate of getting frames from the buffer is around 83%.
For example for a 1920x1036 native resolution at 23.97 fps, requesting images at 640 x 435, it the actual rendercapture/getimage takes about 40ms and an effective framerate of about 21 averaged over 500 frames.
4) If have no way of telling if the 'wait time' might be performing a look-ahead in the buffer and retrieving that frame, but I doubt it.

So without the devs reading this and chiming in, I still have no real idea what is going on.

Other notes:

Code:
waitForCaptureStateChangeEvent()
is also gone, but not stated as such in the sticky post.

On windows, on my machine, while calling the rendercapture routine, kodi krypton FREQUENTLY hangs, requiring a hard kill.

Code:
15:33:52 T:26148  NOTICE: VideoPlayer: Opening: G:\Movies\Ant Man.mkv
15:33:52 T:26148 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
15:33:52 T:26148   ERROR: DXVA::CProcessorHD::IsFormatSupported - Unsupported format 104 for 1.
15:33:52 T:26148   ERROR: DXVA::CProcessorHD::IsFormatSupported - Unsupported format 105 for 1.
15:33:52 T:38200  NOTICE: Creating InputStream
15:33:52 T:38200  NOTICE: Creating Demuxer
15:33:52 T:38200  NOTICE: Opening stream: 0 source: 256
15:33:52 T:38200  NOTICE: Creating video codec with codec id: 28
15:33:52 T:38200  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
15:33:52 T:38200  NOTICE: Creating video thread
15:33:52 T:38200  NOTICE: Opening stream: 1 source: 256
15:33:52 T:38200  NOTICE: Finding audio codec for: 86020
15:33:52 T:38200  NOTICE: Creating audio thread
15:33:52 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:33:52 T:42856  NOTICE: Previous line repeats 2 times.
15:33:52 T:42856  NOTICE: running thread: video_thread
15:33:52 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:33:52 T:43460  NOTICE: running thread: CVideoPlayerAudio::Process()
15:33:52 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:33:52 T:42856  NOTICE: Previous line repeats 1 times.
15:33:52 T:42856  NOTICE: CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(1920x1036)
15:33:52 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:33:52 T:43460  NOTICE: Previous line repeats 2 times.
15:33:52 T:43460  NOTICE: Creating audio stream (codec id: 86020, channels: 6, sample rate: 48000, no pass-through)
15:33:52 T:26148  NOTICE: D3D: rendering method forced to DXVA processor
15:33:52 T:26148  NOTICE: DXVA::CProcessorHD::InitProcessor - Supported deinterlace methods: Blend:yes, Bob:yes, Adaptive:yes, MoComp:no.
15:33:52 T:26148 WARNING: CWinRenderer::UpdateVideoFilter - chosen scaling method 1 is not supported by renderer
15:33:52 T:26148 WARNING: CRenderCaptureDX: D3D11_QUERY_OCCLUSION not supported, performance might suffer
15:34:08 T:42856 WARNING: Previous line repeats 240 times.
15:34:08 T:42856 WARNING: CRenderManager::WaitForBuffer - timeout waiting for buffer         <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
15:34:16 T:43460 WARNING: Previous line repeats 2 times.
15:34:16 T:43460  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:34:16 T:43460  NOTICE: Previous line repeats 6 times.
15:34:16 T:43460  NOTICE: CVideoPlayerAudio::Process - stream stalled
15:34:16 T:42856  NOTICE: CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(1920x1036)
15:34:16 T:42856   ERROR: CDVDVideoCodecFFmpeg::Decode - avcodec_decode_video returned failure
15:34:16 T:42856  NOTICE: DXVA::CDecoder::Close - closing decoder
15:34:16 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:34:16 T:42856  NOTICE: CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(1920x1036)
15:34:16 T:38200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
15:34:16 T:42856  NOTICE: Previous line repeats 11 times.
15:34:16 T:42856  NOTICE: DXVA::CDecoder::Close - closing decoder

If you look at the log before force kill, it is hung on the marked line. The rest of the lines get written after the hard kill.
Reply
#3
(2016-06-27, 21:37)KenV99 Wrote: Other notes:

Code:
waitForCaptureStateChangeEvent()
is also gone, but not stated as such in the sticky post.

thx, added it to the post.
Reply
#4
Example adaption
https://github.com/bobo1on1/script.xbmc....0c3691c10d
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Thanks ronie and Martijn.

I don't know if FernetMenta, the PR author from github reads the forum.
Is it bad etiquette to ask him on github for input on a closed PR?
Reply
#6
Regarding the wait time. It is a timeout. If there is no capture within this time, the function returns a null buffer.

If no video is Playing, calling this interface makes no sense and getImage returns immediately with a null buffer.

Regarding the hang. There is D311 error in the log. I would guess that this is a Windows error that came with migration from DX9.
Reply
#7
(2016-06-28, 06:08)FernetMenta Wrote: Regarding the wait time. It is a timeout. If there is no capture within this time, the function returns a null buffer.

Thanks for the clarification,

(2016-06-28, 06:08)FernetMenta Wrote: If no video is Playing, calling this interface makes no sense and getImage returns immediately with a null buffer.

I was trying to create a condition under which a timeout occurred. Even calling it with 'timeout' values of 0 or 1, while video was playing, I was always getting a bytearray of appropriate length.

(2016-06-28, 06:08)FernetMenta Wrote: Regarding the hang. There is D311 error in the log. I would guess that this is a Windows error that came with migration from DX9.

Although indeed, it may be something to do with D311, that error seems to occur even when the video plays successfully:

Code:
06:09:21 T:34948  NOTICE: VideoPlayer: Opening: G:\Movies\Deadpool.mkv
06:09:21 T:34948 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
06:09:21 T:34948   ERROR: DXVA::CProcessorHD::IsFormatSupported - Unsupported format 104 for 1.
06:09:21 T:34948   ERROR: DXVA::CProcessorHD::IsFormatSupported - Unsupported format 105 for 1.
06:09:21 T:35556  NOTICE: Creating InputStream
06:09:21 T:35556  NOTICE: Creating Demuxer
06:09:21 T:35556  NOTICE: Opening stream: 0 source: 256
06:09:21 T:35556  NOTICE: Creating video codec with codec id: 28
06:09:21 T:35556  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
06:09:21 T:35556  NOTICE: Creating video thread
06:09:21 T:35556  NOTICE: Opening stream: 1 source: 256
06:09:21 T:35556  NOTICE: Finding audio codec for: 86020
06:09:21 T:35556  NOTICE: Creating audio thread
06:09:21 T:35556  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
06:09:21 T:42844  NOTICE: Previous line repeats 8 times.
06:09:21 T:42844  NOTICE: running thread: video_thread
06:09:21 T:42844  NOTICE: CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(1920x804)
06:09:21 T:38640  NOTICE: running thread: CVideoPlayerAudio::Process()
06:09:21 T:38640  NOTICE: Creating audio stream (codec id: 86020, channels: 6, sample rate: 48000, no pass-through)
06:09:21 T:34948  NOTICE: D3D: rendering method forced to DXVA processor
06:09:21 T:34948  NOTICE: DXVA::CProcessorHD::InitProcessor - Supported deinterlace methods: Blend:yes, Bob:yes, Adaptive:yes, MoComp:no.
06:09:21 T:34948 WARNING: CWinRenderer::UpdateVideoFilter - chosen scaling method 1 is not supported by renderer
06:09:21 T:47988  NOTICE: $$$ [testRenderCapture] - starting capture w=640, h=268
06:09:21 T:34948 WARNING: CRenderCaptureDX: D3D11_QUERY_OCCLUSION not supported, performance might suffer
06:09:46 T:47988 WARNING: Previous line repeats 549 times.
06:09:46 T:47988  NOTICE: $$$ [testRenderCapture] - timeout = 0
06:09:46 T:47988  NOTICE: $$$ [testRenderCapture] - counter = 550
06:09:46 T:47988  NOTICE: $$$ [testRenderCapture] - elapsed = 24.9988460661
06:09:46 T:47988  NOTICE: $$$ [testRenderCapture] - framerate = 22.0010155087
06:09:50 T:34948  NOTICE: CVideoPlayer::CloseFile()
06:09:50 T:34948  NOTICE: VideoPlayer: waiting for threads to exit
06:09:50 T:35556  NOTICE: CVideoPlayer::OnExit()
06:09:50 T:35556  NOTICE: Closing stream player 1
06:09:50 T:35556  NOTICE: Waiting for audio thread to exit
06:09:50 T:38640  NOTICE: thread end: CVideoPlayerAudio::OnExit()
06:09:50 T:35556  NOTICE: Closing audio device
06:09:50 T:35556  NOTICE: Deleting audio codec
06:09:50 T:35556  NOTICE: Closing stream player 2
06:09:50 T:35556  NOTICE: waiting for video thread to exit
06:09:50 T:42844  NOTICE: thread end: video_thread
06:09:50 T:35556  NOTICE: deleting video codec
06:09:50 T:35556  NOTICE: DXVA::CDecoder::Close - closing decoder
06:09:50 T:35556  NOTICE: DXVA::Close - closing decoder context
06:09:50 T:34948  NOTICE: VideoPlayer: finished waiting
06:09:50 T:34948  NOTICE: CVideoPlayer::CloseFile()
06:09:50 T:34948  NOTICE: VideoPlayer: waiting for threads to exit
06:09:50 T:34948  NOTICE: VideoPlayer: finished waiting
06:09:50 T:34948  NOTICE: CVideoPlayer::CloseFile()
06:09:50 T:34948  NOTICE: VideoPlayer: waiting for threads to exit
06:09:50 T:34948  NOTICE: VideoPlayer: finished waiting

Since when it hangs, the following message is logged: 'WARNING: CRenderManager::WaitForBuffer - timeout waiting for buffer', and the fact that I cannot otherwise ever generate timeout conditions, could it be that at least on Windows, the buffer timeout is causing an unhandled exception upstream from your code?
Reply
#8
Quote:I was trying to create a condition under which a timeout occurred. Even calling it with 'timeout' values of 0 or 1, while video was playing, I was always getting a bytearray of appropriate length.

A timeout of 0 is set to 1000ms, because 0 means infinity which makes no sense here. RenderCapture is asynchronous. The capture was most likely ready when you called this.

Quote:could it be that at least on Windows, the buffer timeout is causing an unhandled exception upstream from your code?

I don't think so. "WARNING: CRenderManager::WaitForBuffer - timeout waiting for buffer" is not critical if its only logged twice in a row.

I am almost sure that this is a Windows only issue. Could your try Linux or OSX? I didn't get any sign from the maintainers of boblight or philips hue that rendercapture has an issue.
Reply
#9
Unfortunately Kodi nightly crashing during startup for me on Linux MintXFCE. Jarvis runs fine. Just kills itself unceremoniously. Log truncated as below.

Code:
14:15:16 T:139703354128384  NOTICE: Enumerated PULSE devices:
14:15:16 T:139703354128384  NOTICE:     Device 1
14:15:16 T:139703354128384  NOTICE:         m_deviceName      : Default
14:15:16 T:139703354128384  NOTICE:         m_displayName     : Default
14:15:16 T:139703354128384  NOTICE:         m_displayNameExtra: Default Output Device (PULSEAUDIO)
14:15:16 T:139703354128384  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
14:15:16 T:139703354128384  NOTICE:         m_channels        : FL,FR
14:15:16 T:139703354128384  NOTICE:         m_sampleRates     : 5512,8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000,384000
14:15:16 T:139703354128384  NOTICE:         m_dataFormats     : AE_FMT_U8,AE_FMT_S16NE,AE_FMT_S24NE3,AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_FLOAT
14:15:16 T:139703354128384  NOTICE:         m_streamTypes     : No passthrough capabilities
14:15:16 T:139703354128384  NOTICE:     Device 2
14:15:16 T:139703354128384  NOTICE:         m_deviceName      : alsa_output.pci-0000_00_05.0.analog-stereo
14:15:16 T:139703354128384  NOTICE:         m_displayName     : Built-in Audio Analog Stereo
14:15:16 T:139703354128384  NOTICE:         m_displayNameExtra: Analog Output / Amplifier (PULSEAUDIO)
14:15:16 T:139703354128384  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
14:15:16 T:139703354128384  NOTICE:         m_channels        : FL,FR
14:15:16 T:139703354128384  NOTICE:         m_sampleRates     : 5512,8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000,384000
14:15:16 T:139703354128384  NOTICE:         m_dataFormats     : AE_FMT_U8,AE_FMT_S16NE,AE_FMT_S24NE3,AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_FLOAT
14:15:16 T:139703354128384  NOTICE:         m_streamTypes     : No passthrough capabilities
14:15:16 T:139703354128384  NOTICE: No settings file to load (special://xbmc/system/advancedsettings.xml)
14:15:16 T:139703354128384  NOTICE: No settings file to load (special://masterprofile/advancedsettings.xml)
14:15:16 T:139703354128384  NOTICE: Default Video Player: VideoPlayer
14:15:16 T:139703354128384  NOTICE: Default Audio Player: paplayer
14:15:16 T:139703354128384  NOTICE: Disabled debug logging due to GUI setting. Level 0.
14:15:16 T:139703354128384  NOTICE: Log level changed to "LOG_LEVEL_NORMAL"
14:15:16 T:139703354128384  NOTICE: CMediaSourceSettings: loading media sources from special://masterprofile/sources.xml
14:15:16 T:139703354128384  NOTICE: Loading player core factory settings from special://xbmc/system/playercorefactory.xml.
14:15:16 T:139703354128384  NOTICE: Loaded playercorefactory configuration
14:15:16 T:139703354128384  NOTICE: Loading player core factory settings from special://masterprofile/playercorefactory.xml.
14:15:16 T:139703354128384  NOTICE: special://masterprofile/playercorefactory.xml does not exist. Skipping.
14:15:16 T:139703354128384  NOTICE: Running database version Addons26
14:15:16 T:139703354128384  NOTICE: ADDONS: Using repository repository.xbmc.org
14:15:16 T:139702907799296  NOTICE: PulseAudio: Opened device Default in pcm mode with Buffersize 180 ms
14:15:16 T:139703354128384  NOTICE: Checking resolution 15
14:15:16 T:139703354128384   ERROR: Failed to determine egl config for visual info
14:15:16 T:139703354128384 WARNING: Visual 0x11c of the window is not suitable, looking for another one...
14:15:16 T:139703354128384  NOTICE: Using visual 0x21
14:15:16 T:139703354128384  NOTICE: Using visual 0x11c
Reply
#10
OK, Migrating my VM to VMWare fixed that.
I can verify that on Linux MintXFCE 17.3 Kodi does not hang during RenderCapture.
The only problem is that my addon is windows only (Ambibox). So I can't really see updating to be Krypton compatible if the addon is going to cause Kodi to become unresponsive Sad

However, I do get a similar error:

08:46:19 T:139895231137792 WARNING: CRenderCaptureGL: GL_ARB_occlusion_query disabled, performance might suffer
Reply
#11
VMWare has limited graphics capabilities and not a platform recommended for running Kodi apart from some testing.

Please file a ticket on trac and let me know the ticket#. Maybe our Windows dev finds time looking at it.
Reply
#12
(2016-07-01, 13:56)FernetMenta Wrote: VMWare has limited graphics capabilities and not a platform recommended for running Kodi apart from some testing.

Indeed, my platform is native windows. I do not have a dual boot to Linux currently, so I use VMWare for code testing.

(2016-07-01, 13:56)FernetMenta Wrote: Please file a ticket on trac and let me know the ticket#. Maybe our Windows dev finds time looking at it.

I created the ticket here: http://trac.kodi.tv/ticket/16788
Thanks for your input and attention.
Reply
#13
Any findings on this issue? I am using the dfatmo addon of durchflieger.
I decided to give Krypton Beta1 a try, and noticed, that the addon does not work anymore.

Then I read the pull request thread and did the changes needed for the new RenderCapture API myself.
I notice exactly the same behaviour as KenV99 mentioned.

I also get a lot of

Code:
CRenderCaptureDX: D3D11_QUERY_OCCLUSION not supported, performance might suffer

messages and at some time

Code:
CRenderManager::WaitForBuffer - timeout waiting for buffer

and then kodi hangs. I am on Win10.
Reply
#14
I'm back to Kodi 16.1, Ambibox stopped working on kodi 17 Beta 1 and I thought that boblight still worked but it seems to cause microstuttering after a while.

I am also on windows 10 and get lots of CRenderCaptureDX: D3D11_QUERY_OCCLUSION not supported, performance might suffer, like the person above.
Reply
#15
Unfortunately, there has not been any action on the ticket above.
Hopefully with others reporting issues with other addons, the issue might get more attention.
I would suggest also commenting in the ticket thread above.

Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
Changes to the python API for Kodi Krypton - RenderCapture0