Home > other >  Python using ffmpeg push video streaming
Python using ffmpeg push video streaming

Time:11-14

Want to push a frame after the video processing a frame out go to, let others through the RTMP access, the following is to find the code, I python3.6
Run, p.com municate (frame. The tostring ())
The File "F: \ software \ Anaconda3 \ envs \ pytorch \ lib \ subprocess py", line 924, communicate in
Self. _stdin_write (input)
The File "F: \ software \ Anaconda3 \ envs \ pytorch \ lib \ subprocess py", line 873, in _stdin_write
The self. The stdin. Write (input)


 import cv2 
The import subprocess as sp
The import subprocess as sp

RtmpUrl="RTMP://39.107.26.100:1935/myapp/test1"
Camera_path="video. Mp4"

Cap=cv2. VideoCapture (camera_path)

# Get video information
FPS=int (cap) get (cv2. CAP_PROP_FPS))
Width=int (cap) get (cv2. CAP_PROP_FRAME_WIDTH))
Height=int (cap) get (cv2. CAP_PROP_FRAME_HEIGHT))
# ffmpeg command
The command=[' ffmpeg,
'- y'
'- f', 'rawvideo',
'- vcodec', 'rawvideo',
'- pix_fmt', 'bgr24',
'-s', "{} {} x". The format (width, height),
'-r' STR (FPS),
'-i', '-',
'- c: v', 'libx264'
'- pix_fmt', 'yuv420p',
'- preset', 'ultrafast',
'- f', 'FLV',
RtmpUrl]
# pipeline configuration
P=sp. Popen (command, stdin=sp. PIPE)
# read webcamera
While (cap) isOpened ()) :
Ret, frame=cap. The read ()
# print (" running...
")If not ret:
Print (" Opening camera is failed ")
Break
P. tdin. Write (frame. The tostring ())


Return_value, frame=cap. The read ()
  • Related