Last active
November 19, 2018 11:10
-
-
Save Casxt/1e5b51ff2396209fde244730d131005d to your computer and use it in GitHub Desktop.
rstp to rmtp in python use ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipe = subprocess.Popen([FFMPEG_BIN, | |
'-y', # (optional) overwrite output file if it exists | |
'-f', 'rawvideo', | |
#'-loglevel','error', | |
#'-probesize','10M', | |
'-s', framesize, #'420x360', # size of one frame | |
'-pix_fmt', 'bgr24', | |
'-r', str(self.fps), # frames per second | |
'-i', '-', # The input comes from a pipe | |
'-an', # Tells FFMPEG not to expect any audio | |
#'-q','15', | |
'-f', 'flv', | |
'rtmp://localhost:1935/live/%s' % name] | |
, stdin=subprocess.PIPE) | |
video_capture = cv2.VideoCapture('rtmp://127.0.0.1:1935/live/%s' % self.name) | |
while video_capture.isOpened(): | |
ret, frame = self.video_capture.read() | |
# print(ret) | |
if ret: | |
pipe.stdin.write(f.frame) | |
self.index += 1 | |
else: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipe = subprocess.Popen([FFMPEG_BIN, | |
'-y', # (optional) overwrite output file if it exists | |
# '-f', 'rawvideo', | |
'-loglevel', 'error', | |
# '-probesize','10M', | |
# '-s', self.framesize, #'420x360', # size of one frame | |
# '-pix_fmt', 'bgr24', | |
# '-r', str(self.fps), # frames per second | |
'-rtsp_transport', 'tcp', | |
'-i', self.url, # The input comes from a pipe | |
'-codec:v', 'copy', | |
'-an', # Tells FFMPEG not to expect any audio | |
'-q', '15', | |
'-f', 'flv', | |
'rtmp://0.0.0.0:1935/live/%s' % name] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment