Skip to content

Any way to resolve noise problem #902

@wqh17101

Description

@wqh17101

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)

I get many noise like square
image

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions