You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If all frames have been read, "video" will be closed automatically.
45
+
// If not all frames are read, call "video.Close()" to close the video.
38
46
```
39
47
40
48
## `Camera`
41
49
42
50
The `Camera` can read from any cameras on the device running Vidio. It takes in the stream index. On most machines the webcam device has index 0. Note that audio retrieval from the microphone is not yet supported.
43
51
44
52
```go
53
+
vidio.NewCamera(stream int) (*Camera, error) // Create a new Camera struct
54
+
45
55
Name() string
46
56
Width() int
47
57
Height() int
48
58
Depth() int
49
59
FPS() float64
50
60
Codec() string
51
61
FrameBuffer() []byte
62
+
63
+
Read() bool// Read a frame of video and store it in the frame buffer
64
+
Close()
52
65
```
53
66
54
67
```go
55
-
camera:= vidio.NewCamera(0) // Get Webcam
68
+
camera, err:= vidio.NewCamera(0) // Get Webcam
69
+
// Error handling...
56
70
defer camera.Close()
57
71
58
72
// Stream the webcam
@@ -67,6 +81,8 @@ for camera.Read() {
67
81
The `VideoWriter` is used to write frames to a video file. The only required parameters are the output file name, the width and height of the frames being written, and an `Options` struct. This contains all the desired properties of the new video you want to create.
68
82
69
83
```go
84
+
vidio.NewVideoWriter() (*VideoWriter, error) // Create a new VideoWriter struct
85
+
70
86
FileName() string
71
87
Width() int
72
88
Height() int
@@ -78,6 +94,9 @@ FPS() float64
78
94
Quality() float64
79
95
Codec() string
80
96
AudioCodec() string
97
+
98
+
Write(frame []byte) error// Write a frame to the video file
99
+
Close()
81
100
```
82
101
83
102
```go
@@ -89,7 +108,7 @@ type Options struct {
89
108
FPSfloat64// Frames per second. Default 25
90
109
Qualityfloat64// If bitrate not given, use quality instead. Must be between 0 and 1. 0:best, 1:worst
91
110
Codecstring// Codec for video. Default libx264
92
-
Audiostring// File path for audio for the video. If no audio, audio="".
111
+
Audiostring// File path for audio for the video. If no audio, audio=""
93
112
AudioCodecstring// Codec for audio. Default aac
94
113
}
95
114
```
@@ -98,11 +117,13 @@ type Options struct {
98
117
w, h, c:=1920, 1080, 3
99
118
options:= vidio.Options{} // Will fill in defaults if empty
0 commit comments