[iOS] Is it possible to play UDP stream from local PC
Hello. I confuse a little bit on my task.
I trying to figure out solution to display stream without delay from local PC.
For example PC server can sent stream as Elementary stream(.h264 NALu packets) or it can stream as MPEG-TS chunks of data.
Past few weeks a read about my option, and found out then there is a VideoToolbox framework on iOS, which can parse this NALu packets and create CMSampleBuffer
and AVSampleBufferDisplayLayer
layer which can enqueue
this sample and display it (VideoToolbox decoding) example.
I was able to successfully play local .h264 file and .ts file using mediaPlayer.media = VLCMedia(url: localFileURL)
.
I also found out the VLC able to play UDP stream (UDP stream)
From application i tried:
First step
mediaPlayer.drawable = view
mediaPlayer.media = VLCMedia(url: URL(string: "udp://@:5000")!) // "udp://@0.0.0.0:5000", "udp://192.168.0.100:5000"
What i tried on local PC two commands(Second step):
1. ffmpeg -re -i out.ts -vcodec copy -acodec copy -f mpegts udp://192.168.0.103:5000
2. cat file2.h264 | pv -L 200k | nc -u 192.168.0.103 5000
/// With 1 command I got this message in console: (but nothing is display)
[h264 @ 0x110002000] top block unavailable for requested intra mode -1
[h264 @ 0x110002000] error while decoding MB 55 0, bytestream -3
[h264 @ 0x11081fa00] error while decoding MB 37 0, bytestream -5
[h264 @ 0x110820000] top block unavailable for requested intra mode -1
[h264 @ 0x110820000] error while decoding MB 47 0, bytestream -3
[h264 @ 0x110820600] error while decoding MB 75 1, bytestream -5
[h264 @ 0x110822800] error while decoding MB 83 0, bytestream -5
[h264 @ 0x110822e00] error while decoding MB 69 0, bytestream -7
Third step
mediaPlayer.play()
192.168.0.100 - local PC ip-address
192.168.0.103 - my test iPhone ip-address
But unfortunately all this tries doesn't work for me as expected.
Does VLC support this kind of "udp://" stream? Or my only option to use VideoToolbox?
Can somebody please point me out my options or any examples or suggestions. Thank you!