Save video recordings

I have achieved recording videos and storing it successfully, But the major setback is some random folder is created and I’m unable to find where it is configured. My jitsi meet is a multi docker setup. because I’m recording multiple videos at a time. So kindly help me where do i find and stop that random folder creation and store the video files directly.

you can use finalize.sh like this :

you can find the path in jibri conf; you create a file and change the path

#!/bin/bash

RECORDINGS_DIR=$1

echo "This is a dummy finalize script" > /tmp/finalize.out
echo "The script was invoked with recordings directory $RECORDINGS_DIR." >> /tmp/finalize.out
echo "You should put any finalize logic (renaming, uploading to a service" >> /tmp/finalize.out
echo "or storage provider, etc.) in this script" >> /tmp/finalize.out

exit 0

this a code example i found the code in community

#!/bin/bash

RECORDINGS_DIR=$1

# Find latest modified directory
_lastdir=$(find /mnt/HC/recording -mindepth 1 -maxdepth 1 -type d  -exec stat --printf="%Y\t%n\n" {} \; | sort -n -r | head -1 | cut -f2)

# Rename the directory
if [ -r ${_lastdir} ]; then
	mv ${_lastdir} /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M)
fi

# Find files in directory
_recording=$(find /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M) -type f -name "*.mp4" -exec basename {} .mp4 \;)

# Send file(s) list
echo -e "Hi ,\n\nNew conference recording is available:\n\n ${_recording}" | mailx -s "New conference recording" your@email.com

# Move the .mp4 file & delete the folder
mv /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M)/*.mp4 /mnt/HC/recordings/

# ffmpeg need some time to finalize the .mp4 - then remove old folder
sleep 1m
cd /mnt/HC/recordings/
find . -maxdepth 1 -mindepth 1 -type d -exec rm -rf '{}' \;

exit 0

I have created finalize.sh now recording is done and random folder generation is stopped but i’m unable to find the recorded mp4 file. what is the issue? and where do i put the finalize.sh file, inside the recordings folder or outside that

I have created finalize.sh now recording is done and random folder generation is stopped but i’m unable to find the recorded mp4 file. what is the issue? and where do i put the finalize.sh file, inside the recordings folder or outside that

I have created finalize.sh now recording is done and random folder generation is stopped but I’m unable to find the recorded mp4 file. what is the issue? and where do i put the finalize.sh file, inside the recordings folder or outside that

It depends on how you set it in your jibri.conf

@badri_kvarats

recording {
  recordings-directory = "/tmp/recordings"
  # TODO: make this an optional param and remove the default
  finalize-script = "/path/to/finalize"
}

in jibri.conf you put the path then in your machine you create a file corresponding to the path of the jibri.conf and there you put this script that allows you to change the name of the random folder and if you want to change something you have to add shell script code


#!/bin/bash

RECORDINGS_DIR=$1

# Find latest modified directory
_lastdir=$(find /mnt/HC/recording -mindepth 1 -maxdepth 1 -type d  -exec stat --printf="%Y\t%n\n" {} \; | sort -n -r | head -1 | cut -f2)

# Rename the directory
if [ -r ${_lastdir} ]; then
	mv ${_lastdir} /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M)
fi

# Find files in directory
_recording=$(find /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M) -type f -name "*.mp4" -exec basename {} .mp4 \;)

# Send file(s) list
echo -e "Hi ,\n\nNew conference recording is available:\n\n ${_recording}" | mailx -s "New conference recording" your@email.com

# Move the .mp4 file & delete the folder
mv /mnt/HC/recordings/$(date +%Y-%m-%d_%H:%M)/*.mp4 /mnt/HC/recordings/

# ffmpeg need some time to finalize the .mp4 - then remove old folder
sleep 1m
cd /mnt/HC/recordings/
find . -maxdepth 1 -mindepth 1 -type d -exec rm -rf '{}' \;

exit 0

@mbiriki_koussai,

The script you shared

  • assumes the last updated folder is the searched folder but this is not true all times. This may break concurrent recordings.

  • doesn’t respect the folder set in jibri.conf. It uses a hardcoded folder ( /mnt/HC/recording) instead of the correct folder which is already shared with $1

  • deletes all subfolders of the recording directory which breaks all active recording sessions.

@emrah

thanks for replay

your script :
https://github.com/jitsi/jibri/blob/master/src/main/resources/reference.conf#L23

yours corrects my mistakes ?

The script which I shared, finds the correct MP4 file(s) but it doesn’t do any action. The user should customize it according to their needs.

For example the user can add a cp command after the “# write your codes here” line.

1 Like

thank you @emrah

1 Like

i have success fully removed the random folder but thing is im getting the file like this

ashok_2022-07-06-07-56-34.mp4 i have given room name as ashok but getting this time (07-56-34) which i didn’t scheduled and i don’t have that anywhere how to remove this

@badri_kvarats

this a bash script you can use varaible and command mv for rename file

#!/bin/bash
set -e

FOLDER=$1
DEST=/tmp/mydest
mkdir -p $DEST

[[ "$(whoami)" != "jibri" ]] && exit 1
[[ -z "$FOLDER" ]] && exit 2

KEY=$(basename $FOLDER)

i=0
for VIDEO_PATH in $(find $FOLDER -name '*.mp4')
do
    VIDEO_NAME=$(basename $VIDEO_PATH)
    ROOM_NAME=$(echo $VIDEO_NAME | cut -d_ -f1)

    [[ "$i" = "0" ]] && \
      mv $VIDEO_PATH $DEST/$ROOMNAME.mp4 || \
      mv $VIDEO_PATH $DEST/$ROOMNAME.$i.mp4

    (( i++ ))
done

rm -rf $FOLDER

exit 0

If there is already a file using the same name in the destination, this will overwrite it.

Thank you so much!

Thank you so much emrah!