AvProxy icon indicating copy to clipboard operation
AvProxy copied to clipboard

Support for MPTS

Open midicase opened this issue 1 year ago • 6 comments

I have an MPTS that I would like to output as HLS, but AvProxy seems to only use the first program.

ffprobe udp://234.7.8.9:2000?localaddr=192.168.2.62
Input #0, mpegts, from 'udp://234.7.8.9:2000?localaddr=192.168.2.62':
  Duration: N/A, start: 37632.403911, bitrate: N/A
  Program 3 
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
  Program 4 
    Stream #0:4[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x480 [SAR 1:1 DAR 3:2], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:8[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
  Program 5 
    Stream #0:3[0x51]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x480 [SAR 32:27 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:7[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
  Program 6 
    Stream #0:5[0x61]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x480 [SAR 32:27 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:6[0x64](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
cat AvProxy.xml
<?xml version="1.0"?>
<AvProxy Ver="1">
<Input Url="udp://234.7.8.9:2000?IFace=192.168.2.62">
	<Output ApplePreroll=10 Name="http3"/>
</Input>
</AvProxy>

./AvProxy-x64 -Trace
[AvProxy]	Build=[Mar  1 2023 01:29:34 (host_x64.r1)]
[Main]	Build=[Mar  1 2023 02:10:30 (host_x64.r1)]
[BaseLib]	Build=[Mar  1 2023 02:10:30 (host_x64.r1)]
[Arg 0-0]	[./AvProxy-x64]
[Arg 1-1]	[-Trace]
[NetLib]	Host=zino
[NetLib]	IFace=lo	Ip=[127.0.0.1]
[NetLib]	IFace=enp3s0f0	Ip=[192.168.0.140]
[NetLib]	IFace=enp3s0f1	Ip=[192.168.2.62]
[NetLib]	IFace=enp3s0f1	Mac=[00:1B:21:39:15:8A]
[NetLib]	IFace=lo	Mac=[00:00:00:00:00:00]
[NetLib]	IFace=enp3s0f0	Mac=[00:1B:21:39:15:8B]
[HttpServer]	Build=[Mar  1 2023 01:32:00 (host_x64.r1)]
[HttpServer]	[Open] Tcp=41953
[AvProxy]	Url is invalid, use local configuration file [AvProxy.xml]
[TaskThread]	[11875] Began operating
[AvProxy]	Synchronization XML [0 -> 1]
[AvProxy]	Open Input=[udp://234.7.8.9:2000?IFace=192.168.2.62]
IFace: addr 192.168.2.62
Update Output...
Open Output=http3
Output: Name http3, Desc http3, Pnr -1, Apple(AES128 0, Reserve 1, Preroll 10)
[Pat]	Ver=00	Key=96F3DBCE	Nit=0000(0)
	  Program=0030(48)  	Index=3
	  Program=0040(64)  	Index=4
	  Program=0050(80)  	Index=5
	  Program=0060(96)  	Index=6
[Pmt]	Pid=0030(48)	Ver=14	Key=158BB3DA	Pcr=0031(49)
	    Tag=05	Data=4  (47 41 39 34 )	REGD=GA94
	  Stream=0031(49)	Type=Video	Codec=MP2V	Tag=02(MPEG-2 Video)
	    Tag=11	Data=1  (FF )
	    Tag=10	Data=6  (C0 BD 62 C0 08 00 )
	    Tag=06	Data=1  (02 )
	    Tag=86	Data=7  (E1 65 6E 67 C1 3F FF )
	  Stream=0034(52)	Type=Audio	Codec=AC3	Tag=81(AC3)
	    Tag=05	Data=4  (41 43 2D 33 )	REGD=AC-3
	    Tag=81	Data=10 (08 3A 0F FF 0F 01 BF 65 6E 67 )
	    Tag=0A	Data=4  (65 6E 67 00 )	LANG=eng
	  Stream=0035(53)	Type=Audio	Codec=AC3	Tag=81(AC3)
	    Tag=05	Data=4  (41 43 2D 33 )	REGD=AC-3
	    Tag=81	Data=10 (08 28 45 FF 00 01 BF 73 70 61 )
	    Tag=0A	Data=4  (73 70 61 00 )	LANG=spa

ffprobe http://192.168.2.62:34423/live/http3/index.m3u8
Input #0, hls, from 'http://192.168.2.62:38681/live/http3/index.m3u8':
  Duration: N/A, start: 36659.166578, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 0
  Stream #0:0: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn
    Metadata:
      variant_bitrate : 0
    Side data:
      cpb: bitrate max/min/avg: 12870000/0/0 buffer size: 9764864 vbv_delay: N/A
  Stream #0:1: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Metadata:
      variant_bitrate : 0
  Stream #0:2: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      variant_bitrate : 0

If I probe the ts files emitted, the PMT has the PRG in it but no data.

Input #0, mpegts, from 'F81FC810466F4379314B10A977B0AC93.ts':
  Duration: 00:00:06.01, start: 37026.846578, bitrate: 11242 kb/s
  Program 3 
  Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn
    Side data:
      cpb: bitrate max/min/avg: 12870000/0/0 buffer size: 9764864 vbv_delay: N/A
  Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
  Stream #0:2[0x35](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
  Program 4 
  Program 5 
  Program 6 

I know it might be non-standard to have MPTS in hls, but I see it more often in low-budget broadcast distribution systems and trying to re-create. Just would like to keep all input as is in the output.
Thanks

midicase avatar May 15 '23 14:05 midicase

declare Output section for each programm

<?xml version="1.0"?>
<AvProxy Ver="1">
<Input Url="udp://234.7.8.9:2000?IFace=192.168.2.62">
      <Output ApplePreroll=10 Pnr=3 Name="http3"/>
      <Output ApplePreroll=10 Pnr=4 Name="http4"/>
      <Output ApplePreroll=10 Pnr=5 Name="http5"/>
      <Output ApplePreroll=10 Pnr=6 Name="http6"/>
</Input>
</AvProxy>

etc

marakew avatar May 15 '23 14:05 marakew

Thanks, But I need a single output with all the interleaved programs and streams in it, not as separate manifests. Is there a way to keep all the programs, something like?

<?xml version="1.0"?>
<AvProxy Ver="1">
<Input Url="udp://234.7.8.9:2000?IFace=192.168.2.62">
	<Output ApplePreroll=10 Pnr=3,4,5,6 Name="http3"/>
</Input>
</AvProxy>

midicase avatar May 15 '23 14:05 midicase

no and i seems dont known any hls player which support MPTS hls stream how you will play this hls stream ?

marakew avatar May 15 '23 14:05 marakew

It's not for players, but for broadcaster distribution. Players, like ffplay/ffmpeg/vlc, can play MPTS by picking the "best" program already and ignore the rest.

midicase avatar May 15 '23 15:05 midicase

its not good way to use hls for this better UDP or SRT SRT unsupported for now

marakew avatar May 15 '23 15:05 marakew

I agree with you on that. A few broadcasters are already using it that way (which means someone is manufactoring equipment that does it). I don't have that equipment and so trying to reconstruct in my lab to test against. I may just have to write it myself.

midicase avatar May 15 '23 16:05 midicase