Skip to content

Camera feeds for Android, Windows and iOS and OGV support for MovieWriter #98416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ cscope.po.out
*.swp

# Visual Studio Code
.vscode/
*.code-workspace
.history/

Expand Down Expand Up @@ -378,4 +377,7 @@ $RECYCLE.BIN/
*.msm
*.msp
*.lnk
.vscode/c_cpp_properties.json
.vscode/settings.json
*.generated.props
*.ogv
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Godot Editor",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/godot.macos.editor.dev.arm64",
"args": [
"--editor",
"--path",
"${workspaceFolder}/examples/camera",
],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "${workspaceFolder}",
"environment": [],
"MIMode": "lldb",
"preLaunchTask": "Build Godot"
},
{
"name": "Godot Project",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/godot.macos.editor.dev.arm64",
"args": [
"--path",
"${workspaceFolder}/examples/camera",
"--write-movie",
"test.ogv",
"--fixed-fps",
"15"
],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "${workspaceFolder}",
"environment": [],
"MIMode": "lldb",
"preLaunchTask": "Build Godot"
}
]
}
218 changes: 218 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Clean Godot",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"--clean",
"dev_build=yes"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Godot",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"dev_build=yes",
"debug_symbols=yes",
"progress=no",
"vulkan=yes"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android debug template ARM32",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=arm32",
"target=template_debug",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android debug template ARM64",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=arm64",
"target=template_debug",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android debug template X86_32",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=x86_32",
"target=template_debug",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android debug template X86_64",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=x86_64",
"target=template_debug",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android release template ARM32",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=arm32",
"target=template_release",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android release template ARM64",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=arm64",
"target=template_release",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android release template X86_32",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=x86_32",
"target=template_release",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Build Android release template X86_64",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"platform=android",
"arch=x86_64",
"target=template_release",
"progress=no"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
]
}
},
{
"label": "Install Android export templates",
"group": "build",
"type": "shell",
"command": "./gradlew",
"args": [
"generateGodotTemplates",
],
"options": {
"cwd": "${workspaceFolder}/platform/android/java"
},
"dependsOrder": "sequence",
"dependsOn": [
"Build Android debug template ARM32",
"Build Android debug template ARM64",
"Build Android release template ARM32",
"Build Android release template ARM64",
// "Build Android debug template X86_32",
// "Build Android debug template X86_64",
// "Build Android release template X86_32",
// "Build Android release template X86_64"
]
}
]
}
34 changes: 13 additions & 21 deletions doc/classes/CameraFeed.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CameraFeed" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A camera feed gives you access to a single physical camera attached to your device.
A camera feed gives you access to a physical camera attached to your device.
</brief_description>
<description>
A camera feed gives you access to a single physical camera attached to your device. When enabled, Godot will start capturing frames from the camera which can then be used. See also [CameraServer].
[b]Note:[/b] Many cameras will return YCbCr images which are split into two textures and need to be combined in a shader. Godot does this automatically for you if you set the environment to show the camera image in the background.
A camera feed gives you access to a physical camera attached to your device with specific media size and format. When enabled, Godot will start capturing frames from the camera which can then be user as texture in other nodes. See also [CameraServer].
[b]Note:[/b] Some media formats, like YUV or N12 produce two textures (one for the Y plane and one for the UV plane). These textures need be drawn using a suitable shader where the Y plane is provided as TEXTURE and the UV plane as NORMAL_TEXTURE. See the camera project in the examples folder.
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_datatype" qualifiers="const">
<return type="int" enum="CameraFeed.FeedDataType" />
<description>
Returns feed image data type.
</description>
</method>
<method name="get_id" qualifiers="const">
<return type="int" />
<description>
Expand All @@ -34,6 +28,16 @@
Returns the position of camera on the device.
</description>
</method>
<method name="get_width" qualifiers="const">
<return type="int" />
<description>
Returns the width of the captured camera frames.
</description>
</method>
<method name="get_height" qualifiers="const">
<return type="int" />
<description>
Returns the height of the captured camera frames.
<method name="set_format">
<return type="bool" />
<param index="0" name="index" type="int" />
Expand Down Expand Up @@ -98,18 +102,6 @@
</signal>
</signals>
<constants>
<constant name="FEED_NOIMAGE" value="0" enum="FeedDataType">
No image set for the feed.
</constant>
<constant name="FEED_RGB" value="1" enum="FeedDataType">
Feed supplies RGB images.
</constant>
<constant name="FEED_YCBCR" value="2" enum="FeedDataType">
Feed supplies YCbCr images that need to be converted to RGB.
</constant>
<constant name="FEED_YCBCR_SEP" value="3" enum="FeedDataType">
Feed supplies separate Y and CbCr images that need to be combined and converted to RGB.
</constant>
<constant name="FEED_UNSPECIFIED" value="0" enum="FeedPosition">
Unspecified position.
</constant>
Expand Down
16 changes: 1 addition & 15 deletions doc/classes/CameraServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>
The [CameraServer] keeps track of different cameras accessible in Godot. These are external cameras such as webcams or the cameras on your phone.
It is notably used to provide AR modules with a video feed from the camera.
[b]Note:[/b] This class is currently only implemented on Linux, macOS, and iOS, on other platforms no [CameraFeed]s will be available. To get a [CameraFeed] on iOS, the camera plugin from [url=https://github.com/godotengine/godot-ios-plugins]godot-ios-plugins[/url] is required.
[b]Note:[/b] This class currently only supports macOS, iOS, Android and Windows platform. On other platforms, supported [CameraFeed]s are in development.
</description>
<tutorials>
</tutorials>
Expand Down Expand Up @@ -59,18 +59,4 @@
</description>
</signal>
</signals>
<constants>
<constant name="FEED_RGBA_IMAGE" value="0" enum="FeedImage">
The RGBA camera image.
</constant>
<constant name="FEED_YCBCR_IMAGE" value="0" enum="FeedImage">
The [url=https://en.wikipedia.org/wiki/YCbCr]YCbCr[/url] camera image.
</constant>
<constant name="FEED_Y_IMAGE" value="0" enum="FeedImage">
The Y component camera image.
</constant>
<constant name="FEED_CBCR_IMAGE" value="1" enum="FeedImage">
The CbCr component camera image.
</constant>
</constants>
</class>
5 changes: 3 additions & 2 deletions doc/classes/MovieWriter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
</brief_description>
<description>
Godot can record videos with non-real-time simulation. Like the [code]--fixed-fps[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url], this forces the reported [code]delta[/code] in [method Node._process] functions to be identical across frames, regardless of how long it actually took to render the frame. This can be used to record high-quality videos with perfect frame pacing regardless of your hardware's capabilities.
Godot has 2 built-in [MovieWriter]s:
- AVI container with MJPEG for video and uncompressed audio ([code].avi[/code] file extension). Lossy compression, medium file sizes, fast encoding. The lossy compression quality can be adjusted by changing [member ProjectSettings.editor/movie_writer/mjpeg_quality]. The resulting file can be viewed in most video players, but it must be converted to another format for viewing on the web or by Godot with [VideoStreamPlayer]. MJPEG does not support transparency. AVI output is currently limited to a file of 4 GB in size at most.
Godot has 3 built-in [MovieWriter]s:
- OGV container with Theora for video and Vorbis for audio ([code].ogv[/code] file extension). Lossy compression, medium file sizes, fast encoding. The lossy compression quality can be adjusted by changing [member ProjectSettings.editor/movie_writer/video_quality] and [member ProjectSettings.editor/movie_writer/audio_quality]. The resulting file can be viewed in Godot with [VideoStreamPlayer] and most video players and web-browsers.
- AVI container with MJPEG for video and uncompressed audio ([code].avi[/code] file extension). Lossy compression, medium file sizes, fast encoding. The lossy compression quality can be adjusted by changing [member ProjectSettings.editor/movie_writer/video_quality]. The resulting file can be viewed in most video players, but it must be converted to another format for viewing on the web or by Godot with [VideoStreamPlayer]. MJPEG does not support transparency. AVI output is currently limited to a file of 4 GB in size at most.
- PNG image sequence for video and WAV for audio ([code].png[/code] file extension). Lossless compression, large file sizes, slow encoding. Designed to be encoded to a video file with another tool such as [url=https://ffmpeg.org/]FFmpeg[/url] after recording. Transparency is currently not supported, even if the root viewport is set to be transparent.
If you need to encode to a different format or pipe a stream through third-party software, you can extend the [MovieWriter] class to create your own movie writers. This should typically be done using GDExtension for performance reasons.
[b]Editor usage:[/b] A default movie file path can be specified in [member ProjectSettings.editor/movie_writer/movie_file]. Alternatively, for running single scenes, a [code]movie_file[/code] metadata can be added to the root node, specifying the path to a movie file that will be used when recording that scene. Once a path is set, click the video reel icon in the top-right corner of the editor to enable Movie Maker mode, then run any scene as usual. The engine will start recording as soon as the splash screen is finished, and it will only stop recording when the engine quits. Click the video reel icon again to disable Movie Maker mode. Note that toggling Movie Maker mode does not affect project instances that are already running.
Expand Down
Loading
Loading