MPEG-TS HTTP Live Streaming Segments

I am trying to alternate segments of MPEG-TS, but fail. One set of segments was actually captured using the built-in camera in a laptop, and then encoded using FFMPEG with the following command:

ffmpeg -er 4 -y -f video4linux2 -s 640x480 -r 30 -i %s -isync -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 640x480 -vcodec libx264 -fflags +genpts -b 386k -coder 0 -me_range 16 -keyint_min 25 -i_qfactor 0.71 -bt 386k -maxrate 386k -bufsize 386k -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -aspect 640:480 

And the other is an avi file that has been encoded using the following command:

 fmpeg -er 4 -y -f avi -s 640x480 -r 30 -i ./DSCF2021.AVI -vbsf dump_extra -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 640x480 -vcodec libx264 -fflags +genpts -b 386k -coder 0 -me_range 16 -keyint_min 25 -i_qfactor 0.71 -bt 386k -maxrate 386k -bufsize 386k -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -aspect 640:480 

The output is then segmented into ts segments using an open source segmenter.

If both come from the same source (both from the camera), they work fine. However, in this case, the second set of segments freezes. Time passes, but the video does not move. Therefore, I believe this is a coding problem. So my question is: how do I change the ffmpeg command for this?

By alternation, I mean having a playlist with the first set of segments and another playlist with a different set of segments and having a client call, and then another (streaming HTTP streaming)

The output of ffprobe is one of the first sets of segments:

 Input #0, mpegts, from 'live1.ts': Duration: 00:00:09.76, start: 1.400000, bitrate: 281 kb/s Program 1 Service01 Metadata: name : Service01 provider_name : FFmpeg Stream #0.0[0x100]: Video: h264, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 29.92 fps, 29.92 tbr, 90k tbn, 59.83 tbc Stream #0.1[0x101]: Audio: aac, 48000 Hz, stereo, s16, 111 kb/s 

The output ffprobe of one of the second set of segments:

 Input #0, mpegts, from 'ad1.ts': Duration: 00:00:09.64, start: 1.400000, bitrate: 578 kb/s Program 1 Service01 Metadata: name : Service01 provider_name : FFmpeg Stream #0.0[0x100]: Video: h264, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0.1[0x101]: Audio: aac, 48000 Hz, stereo, s16, 22 kb/s 

Thanks,

+2
source share
1 answer

I saw quite a few questions in the subject - see:

I’m not sure what the problem is, but I think most people complain that when you mix content from both sources, they are different, then it freezes.

I think this situation can occur if the PTS and / or PCR are interrupted and the player does not recognize it or does not wash it off. You can probably determine the sequence of timestamps and see if this fixes the problem.

Also see 3.3.11. http://tools.ietf.org/html/draft-pantos-http-live-streaming-07 : EXT-X-DISCONTINUITY

The EXT-X-DISCONTINUITY tag indicates coding interruption
between the media segment that follows it and the one that preceded It. A set of characteristics that MAY change:

o file format
o number and type of tracks
o encoding parameters
o coding sequence
o timestamp sequence

Thus, a break flag in a playlist file may just help if the problem is in any of the above. Please try some of them and post more details. I think this will help many other people.

+3
source

Source: https://habr.com/ru/post/1385138/


All Articles