Damjan
Member
Hi,
I'm coding a small control board for vMix. Basically ti sends http POST to vMix API to start or stop the recording of a video. Here is the code:
Problem is that delay is not called after the http POST is done but http POST is waiting for the delay and then completes. I need to rename and delete files after the job is done but now it rename it immediately before vMix stops recording so there is missing EOF and the file is corrupted. It is mp4 file.
If my code is correct it should do it like this:
Thank you!!
I'm coding a small control board for vMix. Basically ti sends http POST to vMix API to start or stop the recording of a video. Here is the code:
B4X:
Sub recordBtn_Action
Dim recordingDirPath = readSettings.Get("recordingPath") As String
Dim vMixControllerUrl = "http://" & readSettings.Get("vMixWebControllerIP") & ":" & readSettings.Get("vMixWebControllerPort") &"/api/" As String
If recordBtn.Text = "RECORD" And fightNumber > 0 Then
vMixWebController1.PostString(vMixControllerUrl, "Function=StartRecording")
Try
vMixDone(vMixWebController1)
recordBtn.Text = "STOP"
fightBtn.Enabled = False
fightBtn.TextColor = disabledColor
replayBtn.Enabled = False
replayBtn.TextColor = disabledColor
Catch
Log("vMixStartRecording error:")
Log(LastException.Message)
End Try
Else
recordBtn.Text = "RECORD"
vMixWebController2.PostString(vMixControllerUrl, "Function=StopRecording")
Try
vMixDone(vMixWebController2)
Catch
Log("vMixStopRecording error:")
Log(LastException.Message)
End Try
Delay(2000)
fightBtn.Enabled = True
fightBtn.TextColor = defaultColor
replayBtn.Enabled = True
replayBtn.TextColor = defaultColor
Dim lastModifiedFile As String
Try
lastModifiedFile = getLastModifiedFile(recordingDirPath)
renameLastRecordedFile(recordingDirPath, lastModifiedFile ,addLeadingZeros(fightNumber,4) &"-"& addLeadingZeros(breakNumber,2) &".mp4")
updateFileList
Catch
Log("Rename last file error:")
Log(LastException.Message)
End Try
End If
End Sub
Problem is that delay is not called after the http POST is done but http POST is waiting for the delay and then completes. I need to rename and delete files after the job is done but now it rename it immediately before vMix stops recording so there is missing EOF and the file is corrupted. It is mp4 file.
If my code is correct it should do it like this:
- Start recording
- Stop recording
- Delay for 2 sec
- Rename file (copy it with a new name)
- Delete the old file
- Start recording
- Delay for 2 sec
- Stop recording, Rename, Delete - this is happening in the same time and corrupts the file
Thank you!!