VideoTexture, only first frame shown (gst-launch/v4l2loopback -> Blender) #48692
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#48692
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System
Ubuntu-Mate 14.04 64x, nVidia GT620.
Issue
I made a 3D scene (in BGE) with two VideoTextures: one shows the webcam image, the other one: a v4l2loopback device capturing second-display screen, using gst-launch-1.0. No matter what command I use (*), when BlenderPlayer starts, it only shows the first frame of the v4l2loopback device. Webcam works well.
What I tested:
(*) My command:
Also, I tried with the simplest one:
Blend file: 95-video-texture-v4l2loopback.blend
To reproduce the "issue"
What it should do
I also reported in v4l2loopback GitHub issues page: https://github.com/umlaeute/v4l2loopback/issues/115
Changed status to: 'Open'
Added subscriber: @MarioSottile
This file works in Blender > 2.66.
The bug is there and all the later versions. Included the last one 2.77a.
Added subscriber: @BenoitBolsee
I think "this Benoit" was the one that Dalai told me to add here...
Added subscriber: @benoit-2
Added subscriber: @Sergey
@BenoitBolsee, are you looking into this issue?
not yet, I need to get hold of a webcam to reproduce.
@BenoitBolsee, you don't really need a camera to test the bug. The webcam is there to show that /dev/video0 is working and /dev/video1 isn't.
Just comment these lines and run it:
Thanks for the instructions; I was able to reproduce the bug.
It appears that multi-thread caching doesn't work well with that particular v4l source.
I was able to get a smooth output by disabling caching.
I will analyze further and determine if I need to fix caching or disable it or make it selectable by API (caching is known to work with webcam source).
Is there any way to disable caching without modifying code and recompiling...?
If not (and if it seems to be stable to do that), could you make a diff (patch) file for me to compile Blender here?
(I don't want to seem anxious, but it would be very-great if I can make it work here during these days... it's for a particular job)
Thanks!
Cache is enabled automatically as soon as Blender detects that the CPU has more than 1 core.
To disable it you must change the code. The diff is extremely simple: just comment the two line with m_isThreaded = true; in VideoFFmpeg.cpp:
It worked. ;)
For the moment... Is it safe to disable this caching? Just optimization purpose...?
Yes, caching is just for optimization. It is safe to disable it.
I did more tests and the problem is caused by the v4l2loopback not providing correct timestamp on frames: vt thinks that the frames are in the past and drops them.
There is a flag to fix this: m_isStreaming; this flags tells vt to ignore timestamp. Then caching works but not smoothly: there is a strange jitter in the stream as if the frames were not properly ordered. It seems that the loopback device doesn't implement a proper frame queue.
I'll investigate further but the best option apparently is to make caching optional by API.
As I reported this same bug in v4l2loopback issues github page, can I add this information that you are telling to me? Is there any other further information to post there?
Maybe v4l2loopback also can be better by providing the correct timestamp on frames.
Yes you can pass that information to them. They will probably find useful to look at the source code that's doing the caching. It's all in the VideoFFmpeg::cacheThread() function.
I noticed the following anomalies:
av_read_frame() never returns < 0, which would mean 'no frame available at this time' no matter how frequently I call this function and despite the fact that the AVFMT_FLAG_NONBLOCK flag is set in the format context. This is abnormal, v4l2loopback should not return more frames than the target frame rate that is set in the configuration of the device. After decoding with avcodec_decode_video2(), the resulting AVPacket has a dts field set to a fixed value. This is abnormal, I expect dts to be a proper timestamp of the frame. It should advance as a real time clock.
@BenoitBolsee : I reported this issue in v4l2loopback github page (in June). Now, there is a new version of this module: 0.10.0.
Umlaeute (v4l2loopback dev) ask me for trying this new version with this issue. I installed new version and tested the file with last Blender version... but the issue is still there.
I don't know if Blender "multi-thread caching" issue is still there and it is the main problem... is it resolvable?
Could you try this?
I realized that, in june 2016, I wanted to write here... and I wrote in another report (in #46755)! It says:
Wow, it seems to be a big optimization... or a a big bug.
Using the same file, showing the WebCam, there's a big difference in performance between BlenderPlayer with and without caching... but only with WebCam! Look at these window-shots:
Only Webcam, with caching: 40fps.
Only Webcam, without caching (aka, commented thread line): 10-14fps.
Webcam and SecondDisplay-Capture, without caching: also 10-14fps.
Only SecondDisplay-Capture, without caching: 50-60fps.
So, now I have a problem with WebCam. Where is the problem now? :(
Notes:
Also, for a reason that I don't understand... this disabling cache workaround is not working in this new Ubuntu version (previous: 14.04, actual: 16.04).
Finally, I compiled Blender in this distro. The line about threading is still commented:
... but I run the blend file and it is doing the same as when the report was created: the image is still, not moving at all.
Blender source is the same, same version-commit, v4l2loopback does not have any new commit from that moment (june 2016).
What could be happening?
Finally... where is the problem? in v4l2loopback source code?
@BenoitBolsee I need your hand.
In v4l2loopback bug report, umlaeute (dev) asks this:
Added subscriber: @Blendify
Changed status from 'Open' to: 'Archived'
This task is being closed because the BGE has been removed in Blender 2.8.