3

I am trying to figure out the issue when pushing to RTMP which has HLS turned on. Below is the command I am using:

ffmpeg -i hls.m3u8.url -vcodec: copy -acodec libfdk_aac - -f flv rtmp://serverurl/live/test

Everything is great, all works as expected. However, as the source changes on the fly, like switching to another source from far end, it shows correct if I am watching via RTMP. However, if I use HLS play list that was generated by the RTMP module, the video's getting ghosting/piexlated with sound coming through fine. Till the source video goes back to original, then it resumes fine.

If I use HLS copy rather than using RTMP/HLS, then it works fine.

Why is it that the RTMP module writing HLS files is scrambling the video?
Is there a command to fix it?
It doesn't like if source changes video on the fly and keep writing the .ts file as corrupted. I can stop the RTMP and start again. Then it clears up the video till source video again changes in middle.

Keep in mind: if I watch same video via rtmp://, then the video switches fine. Only the HLS playlist, that got generated, showed the pixelation/ghosting with audio.

With HLS commands such as this -start_number 0 -hls_time 10 -hls_list_size 0 will correct them. However, for RTMP there is no such commmand.

This is my nginx config:

allow play all;
live on;
hls on;
hls_path /home/live;
hls_fragment 10s;
hls_cleanup on;

Anyone faced this issue?

zx485
  • 2,170
  • 11
  • 17
  • 24
  • What do you my be "when the source changes". Its is a new stream with new parameter sets? Are the timestamps monotonic? did the codec change? Is it sending a new rtmp sequence header? Its sounds like what you are doing is not really a supported feature of RTMP and the fact is works at all is just lucky. – szatmary Apr 16 '20 at 20:22
  • the source is same codec and same aspect ration etc however when gets switched on the fly while rtmp still running it gets this issue, example hls.m3u8 being copied to rtmp hls.m3u8 switches feed like changes channel on a tv the rtmp feed is fine but the files its writing as hls .ts files are ghosting till the channel changed back to original or rtmp stopped and started again hope this make sense, keep in mind if ffmpeg does hls copy rather than pushing to rtmp then to hls the switching working fine, only rtmp to hls causing this issue – Peter Patel Apr 16 '20 at 20:41
  • I understand. but there are a million more things to elementary stream compatibility than just resolution. The decoder needs to know it needs to reset the internal configuration. When you switch, the next frame MUST be an IDR with inline SPS/PPS, and your decoder needs to support that capability. If that is not the case, what you are doing is an error. Some players MAY look for this type of error, But its outside the spec, and they are not required to. – szatmary Apr 16 '20 at 22:27
  • What’s puzzling is if I just do hls copy everything works fine just this rtmp converting hls breaking at this point I guess no one ever came across this scenario – Peter Patel Apr 17 '20 at 00:49
  • I am facing this problem too. If I change video resolution in client recorder, The client viewer get pixelated and some times green screen. I should change the resolution to adapt bit rate base on client upload speed. – Mneckoee Sep 11 '21 at 11:29

0 Answers0