How to push individual .ts files to Medialive rtmp push url for seemless live streaming?


How to push individual .ts files to Medialive rtmp push url for seemless live streaming?

I'm working on project which performs blurring faces in real-time using live input from a phone camera. I have two Medialive channels -

Channel 1 - RTMP push input. Input is given by a live streaming app which takes camera input and pushes it to the rtmp url. Output is list of ts segments which go through some lambda functions to detect faces (using rekognition) in each .ts segment and perform blurring at the detected coordinates of the segment using openCV. Output ts segment is uploaded to s3.

Channel 2 - RTMP push input *. Input is the resulting .ts file which contains blurred faces which is pushed to the rtmp url after the blurring process is complete. Output ts segment is uploaded to s3 and path is provided to cloudfront for live stream.

I'm using ffmpeg command to push the face blurred segment to the rtmp url of channel 2. The issue is that the pushing happens randomly whenever the blurring process is completed. The resulting live stream contains black screen for a few seconds after each segment. How to resolve this issue? Or suggest any other way to work with the edited .ts segments.

*The reason for second channel - The ts segments from channel 1 contain metadata which is lost in the face blurring process as a new ts file is generated. Hence, the .m3u8 playlist file is not able to play the segments sequentially. To resolve this, I'm pushing the .ts files at the end of the face blurring process to the rtmp url of the second channel. The result is that I get new .ts segments with m3u8 file and the stream can run seemlessly (however the ts segments themselves contain black screens as the rtmp url of channel 2 doesn't get continuous input).

1 Answer

Since you have .ts files, why not pull those files with the HLS input reader and live HLS manifest? Your application will need to keep the variant manifest updated as to when segments become available.

The medialive channel HLS reader can be configured to buffer more, i.e., to start reading higher/older in the source manifest. This should allow your workflow to provide the source segments asynchronously at various intervals, but have MediaLive read the content in a steady cadence XX segments/seconds behind live.

MediaLive has configurable input loss behavior settings, which default to emitting black after 1000ms. You can change these settings to not emit output, or to emit a freeze frame or slate image instead. ( located in /General Settings/ Global Configuration/Input Loss Behavior and for emit/no-emit, in the Output Group settings)

profile picture
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions