admin管理员组文章数量:1125555
This is a video frame receiving program using TCP data transfer. I am sending 5400x3010 pixel frame data, but on the receiving side, the video becomes slow. Why is this happening? and how can I solve it?
The 1080p video is being received correctly.
FIFO_PATH = '/tmp/video_fifo'
# Create a named pipe (FIFO)
if not os.path.exists(FIFO_PATH):
os.mkfifo(FIFO_PATH)
# Start the GStreamer pipeline in a subprocess
gst_command = f"gst-launch-1.0 -v filesrc location={FIFO_PATH} ! decodebin ! videoscale ! video/x-raw,width=800,height=480 ! autovideosink"
gst_process = subprocess.Popen(gst_command, shell=True)
# Set up socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((SERVER_IP, PORT))
sock.listen(1)
print("Waiting for connection...")
conn, addr = sock.accept()
print(f"Connection established with {addr}")
# Prepare to receive data
header = struct.Struct('>L') # for 4 bytes frame size header
# Open the FIFO for writing
with open(FIFO_PATH, 'wb') as fifo:
try:
while True:
# Receive the frame size header
data = conn.recv(header.size)
if not data:
break
frame_size = header.unpack(data)[0]
# Receive the actual frame data
frame_data = b''
while len(frame_data) < frame_size:
packet = conn.recv(frame_size - len(frame_data))
if not packet:
break
frame_data += packet
# Write the frame data to the FIFO
fifo.write(frame_data)
fifo.flush()
except Exception as e:
print(f"Error: {e}")
finally:
print("Closing connection...")
conn.close()
本文标签: pythonHow to solve the lagging issue of gstlaunch10 running videoStack Overflow
版权声明:本文标题:python - How to solve the lagging issue of gst-launch-1.0 running video? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736669724a1946853.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论