We have a bunch of binary files that represent Video data. This is how the binary files were created:
- Used MediaRecorder from a React application to capture the browser window. To capture the screen stream we used (Navigator.)MediaDevices.getDisplayMedia() API
- Each video is recorded for 1-second duration
- This data is then encoded with base64 and sent through a websocket. The server decodes the base64 string and stores the binary data in a file (without any extension)
So we now have a bunch of binary files each containing 1 second worth of video data.
The issue is, we are not able to convert all the binary files back to a single video.
We tried using ffmpeg
copy /b * merged.
ffmpeg -i merged merged.mp4
Basically first merging all the binary files and converting to mp4. It didn't work. The resulting video duration is not equal to the (number_of_files) in seconds.
We also tried converting individual chunks with ffmpeg but we get the below error:
[h264 @ 000001522dc74b80] [error] non-existing PPS 0 referenced [h264 @ 000001522dc74b80] [error] non-existing PPS 0 referenced [h264 @ 000001522dc74b80] [error] decode_slice_header error [h264 @ 000001522dc74b80] [error] no frame! I can provide the complete logs if needed.
Next thing we tried was to use MoviePy library in Python. We programmatically concatenated the files and saved them as WebM and imported it into MoviePy as a Video.
In all the above approaches, we couldn't get the full video.