A golang based gRPC service API that connects to a VNC host and records the frames using
ffmpeg library and vnc2video.
- Concurrent VNC recordings
- Custom recording file name
- Unique VNC host per request
- VNC encoding format per request
- Custom quality and frame rate
- Dockerized setup
-
Copy to the
api/vnc.protoprotobuf file in your project of the language of your choice, and adjust the options for the target directory for code generation. -
Follow the instructions from
https://grpc.io/docs/to generate the gRPC client side code from the protobuf file.
The api/vnc.proto exposes the VncRecorder service with three APIs
Start- Starts recording from VNC serverStop- Stops the recording and saves it in the target file.Remove- Stops the recording and removes the recording file.
Each of the service APIs accept VncRequest as a parameter and returns a VncResponse result.
The VncRequest message type has four fields - one is required and three are optional:
host- The hostname/IP address where the VNC server for the target recording is running.port- (Optional) The port on which VNC server is listening. Default value is5900or the one set forVNC_PORT.fileName- (Optional) The name of file in which the vnc recording should be saved. If a path is provided, the absolute path would be relative to either/recordingsor the value ofVNC_RECORDINGS_DIRif set. If file name is not provided, the recording will be saved invncfile.mediaType- (Optional) The target format of the recording. Defaults tomp4.
The VncResponse message type has two fields:
status- Returns the status of the VNC recording request. If no errors happen, then a status ofSTARTEDforStartservice request, andDONEforStopandRemoveservice request types. On any errors, the status code will beFAILURE.message- Returns a failure message. If no errors happened, then message is empty.
- Build the go project by executing
go build - Export the environment variables for any customization see Configuration Options below.
- Run the binary executable
- Check out the sample
docker-compose.yamlfile at the root of this project - Adjust the environment variables in the
.envfile - Execute
docker-compose up -d && docker-compose logs -f vncrecorder
The VNC recorder service allows you to customize the below parameters:
VNC_PASSWORD- The password used to authenticate with the VNC server. Default value issecret.VNC_PORT- The port on which the VNC server is listening. Default value is5900.GRPC_PORT- The port on which the VNC recording gRPC service is available. Default value is3000. This parameter is useful when running in bare metal scenario when you have other services running on port3000. When running as a docker service, only the exposed port mapping needs to be adjusted.VNC_RECORDINGS_DIR- The directory where VNC recordings are stored. Default value is/recordings.VNC_FRAME_RATE- Number of frames per second the target recording file will contain. Default value is60.VNC_CONSTANT_RATE_FACTOR- Quality of the recording. Default value is0 - (best). Valid range is0-51where 0 is the best and 51 is the worst.