how to push a .264 file to the rtp url?
Overview
I want to open the local file and push the stream to rtp, but I haven't found a suitable example. I wrote a simple script, but it did not run well. I think the option is not set correctly. How should I modify it? in ffmpeg cmd it just like "ffmpeg -re -i .\bin\big.264 -vcodec copy -an -t 100 -f rtp rtp://127.0.0.1:12150"
import av
path_to_video = ".\\bin\\big.264"
with av.open(path_to_video) as input_:
with av.open("rtp://127.0.0.1:12150", "w", format="rtp") as output:
stream = output.add_stream('libx264', rate=23, options={"crf": "23"})
stream.width = input_.streams.video[0].codec_context.width
stream.height = input_.streams.video[0].codec_context.height
stream.pix_fmt = input_.streams.video[0].codec_context.pix_fmt
print(type(output))
for frame in input_.decode(video=0):
output.mux(stream.encode(frame))
output.close()
input_.close()
Expected behavior
RTP receives video packets at normal rate
Actual behavior
rtp terminal plays thevery fast, and the second time he runs the script, he will report the following error.
Traceback:
non-existing SPS 0 referenced in buffering period
non-existing SPS 0 referenced in buffering period
non-strictly-monotonic PTS
non-strictly-monotonic PTS
(repeated 1438 more times)
Investigation
- query the pyav docs (But that doesn't any help)
- checked all relevant issues (but it seems that no one has tried to do it)
- query help in Google
- ask in gitter but no one can help me
Research
I have done the following:
- [ √ ] Checked the PyAV documentation
- [ √ ] Searched on Google
- [ √ ] Searched on Stack Overflow
- [ √ ] Looked through old GitHub issues
- [ √ ] Asked on PyAV Gitter
-
... and waited 72 hours for a response.