Alankar
Alankar

Reputation: 483

How to show rtmp live stream in web browser?

I have setup a nginx server for live streaming, All is working fine and i can see live streaming VLC player.

I am trying to implement live streaming in web browser instead of VLC player but not getting any proper solution.

I saw many example for jw player but its not working. Anyone please advice what whould be best to see live stream in web browser.

Thanks

Upvotes: 5

Views: 34256

Answers (3)

Josh
Josh

Reputation: 2077

Cause I landed here late when trying to solve a similar issue, here is an answer I found useful.

One option may be using this project: rtsp-simple-server

You might try using to proxy from rtmp to HLS. Then you would need to add HLS support to your browser (at this time non sarari browsers seem to need a JS fallback like hls.js)

It the config yaml you probably want to add some section like this to bridge a single stream:

paths:
  hls:
    source: rtmp://example.com:1935/stream

Upvotes: 1

Seetharam
Seetharam

Reputation: 105

import time
import cv2 
from flask import Flask, render_template, Response
from werkzeug.wrappers import Request, Response

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')


def gen():
    cap = cv2.VideoCapture("live streaming **strong text**url")
    width = 1200
    height = 700
    dim = (width, height)
    while(cap.isOpened()):
        ret, img = cap.read()
        if ret == True:
            img = cv2.resize(img, dim, fx=0.5, fy=0.5) 
            frame = cv2.imencode('.jpg', img)[1].tobytes()
            yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
            time.sleep(0.1)
        else: 
            break
        

@app.route('/video_feed')
def video_feed():
    return Response(gen(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')

    
if __name__ ==('__main__'):
    from werkzeug.serving import run_simple
    run_simple('localhost', 7600, app)

Upvotes: -2

szatmary
szatmary

Reputation: 31140

It's not possible any more. It used to be possible with FASH, but flash is no longer supported. You must use a format that is supported like HLS or DASH

Upvotes: 3

Related Questions