Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the user doesn't properly quit the recording the mp4 file is corrupted #413

Open
pierreozoux opened this issue Jun 10, 2021 · 3 comments

Comments

@pierreozoux
Copy link

Description, Current behavior


If your jibri server has a problem, or the last user quit the call without stoping the recording, the resulting mp4 is corrupted
(In vlc I get this error: moov atom not found )

Expected Behavior


I think the recording should be able to resist failure of any component and still produce a readable file.

Possible Solution


Solution 1

I'm currently using this ffmpeg script to create ts files instead of mp4:

#!/bin/bash

ARGS=$@
echo $ARGS >> /tmp/ffmpeg.log

if echo $ARGS | grep rtmp; then
  echo Stream starting... > /tmp/ffmpeg.log
else
  echo Record starting... > /tmp/ffmpeg.log
  RDIR="/config/recordings"
  NAME=$(echo $ARGS | egrep -o '[^/]*$' | cut -d. -f1)
  SUBDIR="$RDIR/$NAME"
  mkdir -p $SUBDIR
  # -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i plug:bsnoop -acodec aac -strict -2 -ar 44100 -b:a 128k -af aresample=async=1 -c:v libx264 -preset veryfast -profile:v main -level 3.1 -pix_fmt yuv420p -r 30 -crf 25 -g 60 -tune zerolatency -f mp4 /config/recordings/rkkojjkkyegfxoms/tesst_2021-06-10-16-49-30.mp4
  #-f segment -segment_list playlist.m3u8 -segment_time 10 output%03d.ts
  ARGS=`echo $ARGS | \
      sed "s#-f mp4#-f segment -segment_list $SUBDIR/playlist.m3u8 -segment_time 10 $SUBDIR/output%03d.ts#g" | \
      rev | cut -d" " -f2- | rev`
fi

ARGS=`echo $ARGS | \
      sed "s#1920x1080#1280x720#g" | \
      sed "s#2976k#1900k#g"`


echo $ARGS >> /tmp/ffmpeg.log
echo Exec ffmpeg... >> /tmp/ffmpeg.log

exec /usr/bin/ffmpeg $ARGS

And then I recompile the file with this script:
owncast/owncast#886

Solution 2

Apparently, it would be possible to repair the corrupted file, I tried with vlc or ffmpeg, without luck..

Solution 3

It would be nice if natively jibri records in chunck to avoid corruption, and at the end of the stream, recompiles it.
(Could be the post processing script actually.)

Steps to reproduce


  • start a recording
  • quit the recording without stopping it properly
  • you'll not be able to play this mp4 in vlc
@bbaldino
Copy link
Member

Please include all Jibri logs.

@pierreozoux
Copy link
Author

This is not really an issue from jibri, but more the mp4 container used.
When you finish to write an mp4, you need to finish the file by writing some metadata.
If your server has crashed, then.. you don't have these metadata, and jibri will never be able to fix that.
the only way of fixing is to use a different container, like using ts files.

@aaronkvanmeerten
Copy link
Member

Another option is to use jibri in rtmp mode, and stream to a redundant rtmp service which then handles the transcoding and storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants