Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

9. Video stream from Bob is published:

Merging stream records using ffmpeg

Stream record files can be merged in chronological order using ffmpeg. To allow this,  when stream is created, stream timeshift relative to room creation time is specified with setTimeShift() method, by default:

Code Block
languagejs
themeRDark
stream.setTimeShift(new Date().getTime() - room.getCreateDate().getTime());

This method can be used from client web application.

Stream record files written by this way are merged with command (two participants example)

Code Block
languagebash
themeRDark
ffmpeg -i stream1.mp4 -i stream2.mp4 -filter_complex "[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid];[0:a][1:a]amerge[a]" -map [vid] -map "[a]" -ac 2 -strict -2 -c:v libx264 -crf 23 -preset veryfast output.mp4

Where

  • stream1 - first participant stream
  • stream2 - second participant stream

To merge files obtained during our test, enter the command:

Code Block
languagebash
themeRDark
ffmpeg -i stream-34296a60-7b36-11e8-bd9c-31aaed48935e-db8mp51bajcidn9qmcnda3967k.mp4 -i stream-5aeb2351-7b36-11e8-b398-b74e804508b2-g97j81cgrf8h1m7jl7184fa788.mp4 -filter_complex "[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid];[0:a][1:a]amerge[a]" -map [vid] -map "[a]" -ac 2 -strict -2 -c:v libx264 -crf 23 -preset veryfast output.mp4

Then play output.mp4.file:

Image Added

Image Added