videomp4http-live-streaming

How to combine video/chunk segments of ABR video into a single seamless video?


I want to capture the segments/chunks of Adaptative Bit Rate (ABR) Video from a player (HLS/DASH) runing on my browser in order to combine all the chunks into one seamless video to later analyze the QoE (Quality of Experience) of the entire video i.e., VMAF. To do this, all segments have to be part of the same video file.

Tipically the combination of video chunks at same resolution could be done using cat command on linux based OS, e.g.,

cat init.mp4 video1.mp4 video2.mp4 > fullvideo.mp4 

However what I want is to combine the video when the ABR player switches between profiles/resolutions, e.g.,

On HLS/DASH players, the switching process happens seamlessly and I would like to reproduce this behavior in the combined file. However, when I try to combine all the segments using cat the output is not correctly handle by mp4 players like VLC. As far as I understand, it seems that .mp4 format just support the concatenation of video frames at same resolution.

By the way, if I do the concatenation by grouping the segments by resolution, the output files are correctly reproduced by video players.

Below, there is an example of what I tried initially. The order of the files is given by the order in which the video segments are requested by the player.

[administrator@PlayerMedia mediaFiles]$ cat NGK_The_Owl_Y_Co_T1_E02_HD_STR-video=800000-init.mp4 \
NGK_The_Owl_Y_Co_T1_E02_HD_STR-video=800000-0.mp4 \
NGK_The_Owl_Y_Co_T1_E02_HD_STR-video=5993000-init.mp4 \
NGK_The_Owl_Y_Co_T1_E02_HD_STR-video=5993000-60060.mp4 \
NGK_The_Owl_Y_Co_T1_E02_HD_STR-video=5993000-120120.mp4 > final.mp4

The output file final.mp4 just contains the metadata included in the first init.mp4 @ bitrate=800000 so the next video chunks with bitrate=5993000 (an upper resolution) are shown as corrupted video.

I would like to know what is the best alternative to record videos including resolution's changes experienced by players of ABR protocols such as HLS or DASH.


Solution

  • Solved with ffmpeg.

    First, all HLS segments have to ve downloaded by keeping the order they were played. Then, each segment have to be upscaled at one specific resolution, i.e., 1920x1080. This could be done by ffmpeg.

    ffmpeg -i <videoFile> -vf scale=1920:1080:flags=bicubic -c:v libx264 -preset slow -crf 21 <video upscaled>
    

    Finally, once all segments are in the same resolution they can be concatenated using cat. The output video the can be used to compute video quality metrics.