-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Labels
Description
Overview
when i use
image:np.ndarray
fmpeg -y -vcodec rawvideo -pix_fmt bgr24 -s AxB -i - -c:v libx264 -pix_fmt yuv420p -preset ultrafast -f rtsp -rtsp_transport tcp url
to push image.to_string
It works well
So how can i do this by Pyav
I try:
video = av.open(url)
container = av.open(outpout_url, "w", format="rtsp", options={'rtsp_transport': 'tcp'})
stream = container.add_stream('h264')
stream.pix_fmt = 'yuv420p'
stream.options = {"preset": "ultrafast", "vcodec": "rawvideo"}
for packet in video.demux():
if packet.dts is None:
continue
for frame in packet.decode():
if packet.stream.type != 'video':
continue
print("frame = ", frame)
img = frame.to_ndarray(format='bgr24')
frame2 = av.VideoFrame.from_ndarray(img, format='bgr24')
for packet2 in stream.encode(frame2):
container.mux(packet2)
Expected behavior
the same as FFMPEG cmd
Versions
- OS: Linux
- PyAV runtime: 9.0.0
{{ Complete output of `python -m av --version`. If this command won't run, you are likely dealing with the build issue and should use the appropriate template. }}
- PyAV build:
{{ Complete output of `python setup.py config --verbose`. }}
- FFmpeg:
{{ Complete output of `ffmpeg -version` }}
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.
