Record separately video stream and audio stream and mux them when playing

Dani

Member
Is is possible to record the video from one stream, the audio from a 2nd stream and mux them when I play ?
 

Max

Administrator
Staff member
Good day.
There are two options to do this:
1. (Low cost way) You can record video and audio stream to different files and then mux them using ffmpeg. This way cannot provide audio and video synchronization especially if two different sources are used, so out of lipsync will occur.
2. You can use mixer by adding audio and video streams to it
- add the following parameter to flashphoner.properties
Code:
mixer_show_separate_audio_frame=false
- use REST API to create mixer and to add video and audio streams to it
Code:
POST /rest-api/mixer/startup HTTP/1.1
HOST: wcs:8081
content-type: application/json
 
{
    "uri": "mixer://mixer1",
    "localStreamName": "mixer1"
}

POST /rest-api/mixer/add HTTP/1.1
HOST: wcs:8081
content-type: application/json
 
{
    "uri": "mixer://mixer1",
    "remoteStreamName": "video_stream1",
    "hasVideo": true,
    "hasAudio": false
}

POST /rest-api/mixer/add HTTP/1.1
HOST: wcs:8081
content-type: application/json
 
{
    "uri": "mixer://mixer1",
    "remoteStreamName": "audio_stream2",
    "hasVideo": false,
    "hasAudio": true
}
- record the stream mixer1 using /stream/startRecording REST API
Note that mixer requires CPU resources (at least one CPU core per two mixers with default settings), so this is not low cost way.
Please read details about mixer here and here.
 
Top