ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.29k stars 635 forks source link

Split recording at a duration of 15 seconds and be uploaded to the cloud storage #5015

Open burak-58 opened 1 year ago

burak-58 commented 1 year ago

To upload the recording to the cloud storage, AMS waits for stream end. Instead it should upload recordings every 15 secs. In case the recording process fails due to some reason we want a fallback option such that the damage is minimal.

muratugureminoglu commented 1 year ago

You can make this up as a workaround on the operating system side by mounting the bucket to the operating system.

First install the Google SDK as follows.

sudo apt-get install apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-cli
gcloud auth application-default login

Now install the Google Cloud Storage FUSE tool.

echo "deb http://packages.cloud.google.com/apt gcsfuse-`lsb_release -c -s` main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gcsfuse

Mount your bucket to /usr/local/antmedia/webapps/WebRTCAppEE/streams.

gcsfuse --file-mode 777 --dir-mode 777  -o allow_other antmedia-test /usr/local/antmedia/webapps/WebRTCAppEE/streams

You can also follow the document below for HLS recording.

https://antmedia.io/docs/guides/playing-live-stream/hls-playing/#save-hls-records

And that's it.

Mohit-3196 commented 1 year ago

I tested the GCS fuse solution, which works as expected by mounting the streams directory to the GCS bucket.

However, when accessing the .m3u8 file from GCS bucket the content of the .m3u8 file is not updated in the bucket as the cache settings get rewritten on the bucket whereas it is updated on the OS side.

Mohit-3196 commented 1 year ago

5082