🔥 Golang live stream lib/client/server. support RTMP/RTSP/HLS/HTTP[S]-FLV/HTTP-TS, H264/H265/AAC, relay, cluster, record, HTTP API/Notify, GOP cache. 官方文档见 https://pengrl.com/lal

Live And Live




lal是一个开源GoLang直播流媒体网络传输项目,包含三个主要组成部分:

  • lalserver:流媒体转发服务器。类似于nginx-rtmp-module等应用,但支持更多的协议,提供更丰富的功能。lalserver简介
  • demo:一些小应用,比如推、拉流客户端,压测工具,流分析工具,调度示例程序等。类似于ffmpeg、ffprobe等应用。Demo简介
  • pkg:流媒体协议库。类似于ffmpeg的libavformat等库。

lal源码package架构图:

lal源码package架构图

lalserver特性图:

lalserver特性图

了解更多请访问:

联系作者:

  • email:[email protected]
  • 微信:q191201771
  • QQ:191201771
  • 微信群: 加我微信好友后,告诉我拉你进群
  • QQ群: 1090510973
Owner
yoko
c++, Go, network, system, audio&video.
yoko
Comments
  • rtmp推流大小分辨率超过平时常规大小宽度 HLS切片不能正常工作?

    rtmp推流大小分辨率超过平时常规大小宽度 HLS切片不能正常工作?

    因为需要测试一些拼接后的视频推流,视频分辨率大小非常规大小,推流后 切片HLS和其它的都工作不正常 Server : NGINX RTMP (github.com/arut/nginx-rtmp-module) displayWidth : 4096 displayHeight : 2048 fps : 0 profile : level : encoder : Lavf58.45.100 Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p(progressive), 4096x2048 [SAR 1:1 DAR 2 :1], q=2-31, 1999 kb/s, 7.50 fps, 15 tbr, 1k tbn, 1k tbc

    推流4096 X 2048大小后 hls切片 flv等 都不能正常工作,自动切片识别为1920*1088的视频大小,图像也无内容了 其它的flv也是

  • Unble push stream to Wowza RTMP Server with authencation

    Unble push stream to Wowza RTMP Server with authencation

    Hi all, I am trying push rtmp to wowza with user and password but i cann't work. without password, it still works normally

    My command format: pullrtsp2pushrtmp.go -i rtsp://root:@xxx.196:8555/live1s2.sdp -o rtmp://xxx:1935/hung/mystream -t 0

    image

    Plz help me Tks u

  • RTSP拉流时,如果缺少sprop-parameter-sets字段,则拉流失败

    RTSP拉流时,如果缺少sprop-parameter-sets字段,则拉流失败

    拉取海康威视NVR 回看流时,因为缺少sprop-parameter-sets字段,导致拉流失败。

    程序读到的Describe返回如下:

    2021/05/20 17:59:05.485378 DEBUG [RTSPPULL1] > write OPTIONS. - client_command_session.go:530
    2021/05/20 17:59:05.529151 DEBUG [RTSPPULL1] < read response. version=RTSP/1.0, code=200, reason=OK, headers=map[CSeq:2 Date:Thu, 20 May 2021 09:59:05 GMT Public:OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, PAUSE, SET_PARAMETER, GET_PARAMETER], body= - client_command_session.go:548
    2021/05/20 17:59:05.529264 DEBUG [RTSPPULL1] > write DESCRIBE. - client_command_session.go:530
    2021/05/20 17:59:05.589633 DEBUG [RTSPPULL1] < read response. version=RTSP/1.0, code=200, reason=OK, headers=map[CSeq:3 Content-Length:605 Content-Type:application/sdp Date:Thu, 20 May 2021 09:59:05 GMT], body=v=0
    o=- 1109162014219182 0 IN IP4 0.0.0.0
    s=HIK Media Server V3.4.106
    i=HIK Media Server Session Description : standard
    e=NONE
    c=IN IP4 0.0.0.0
    t=0 0
    a=control:*
    b=AS:4106
    a=range:clock=20210520T063812Z-20210520T064816Z
    m=video 0 RTP/AVP 96
    i=Video Media
    a=rtpmap:96 H264/90000
    a=fmtp:96 profile-level-id=4D0014;packetization-mode=0
    a=control:trackID=video
    b=AS:4096
    m=audio 0 RTP/AVP 98
    i=Audio Media
    a=rtpmap:98 G7221/16000
    a=control:trackID=audio
    b=AS:10
    a=Media_header:MEDIAINFO=494D4B48020100000400000121720110803E0000803E000000000000000000000000000000000000;
    a=appversion:1.0
     - client_command_session.go:548
    
    

    使用wireshark抓包也验证了这个情况

  • hevc 265 problem audio rtsp and block image and not support rtmp and flv server

    hevc 265 problem audio rtsp and block image and not support rtmp and flv server

    hi

    hevc 265 problem audio rtsp and block image and not support rtmp and flv server

    error not support ac3 : ffmpeg -i input -c:v copy -c:a copy -f rtsp rtsp://host:port/id


    good run : ffmpeg -i input -c:v copy -c:a aac -f rtsp rtsp://host:port/id

    ffmpeg : image hevc frezzz and not audio ac3 @ 0x55c229397c40] expacc 126 is out-of-range.26 bitrate=N/A speed=1.04x
    [ac3 @ 0x55c229397c40] error decoding the audio block

    app lal : 2021/05/04 14:47:31.353880 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:190 2021/05/04 14:47:31.353950 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:190 2021/05/04 14:47:31.354015 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:190

  • 推送H265的rtsp流接收的时候 会产生大量一直发报错

    推送H265的rtsp流接收的时候 会产生大量一直发报错

    在推送H265格式的rtsp流接收的时候 会产生大量一直发报错 推送的ffmpeg -re -i h265.mp4 -c:v copy -c:a copy -f rtsp rtsp://127.0.0.1:5544/live/test 使用的是修改版本的ffmpeg 就是对rtmp也支持H265的 就是共同定义id为12的。 测试使用rtmp推h265失败,PS:可以考虑后期兼容支持 RTMP H265 目前使用rtsp推送的h265 后 log不停每秒产生大量ERROR:

    2022/04/07 00:42:25.170983 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.171985 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.191038 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.191038 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.192039 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.193041 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.194044 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.194044 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.195046 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192 2022/04/07 00:42:25.196049 ERROR invalid position. pos=0 - rtp_unpacker_avc_hevc.go:192

    测试环境是windows

  • [接口] /api/ctrl/start_pull 如何使用?

    [接口] /api/ctrl/start_pull 如何使用?

    頻道地址:佛教2,rtmp://hk2.hwadzan.com/liveedge/amtb

    測試播放:ffplay rtmp://hk2.hwadzan.com/liveedge/amtb

    1. 指令: curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"hk2.hwadzan.com", "app_name":"liveedge", "stream_name":"amtb"}' http://127.0.0.1:8083/api/ctrl/start_pull

    錯誤訊息: lalserver.go

    2021/11/26 18:54:06.805791 DEBUG group size=0 - server_manager.go:244
    2021/11/26 18:54:36.801188 DEBUG group size=0 - server_manager.go:244
    2021/11/26 18:54:37.140985  INFO http api start pull. req info={Protocol:rtmp Addr:hk2.hwadzan.com AppName:liveedge StreamName:amtb UrlParam:} - http_api.go:115
    2021/11/26 18:54:37.141042  WARN group not exist, ignore start pull. streamName=amtb - server_manager.go:327
    2021/11/26 18:55:06.801238 DEBUG group size=0 - server_manager.go:244
    
    1. 靜態設定: lalserver.conf.json "relay_pull": { "enable": false, "addr": "" },

    可以給個範例或是說明以上兩個怎麼使用嗎?

    不太懂這邊的流程和指令應該怎麼下。謝謝

    我的理解是 1. 指令要拉取遠端流,卻去判斷 group 是否存在? 這不是很奇怪嗎

  • pub接入自定义流 数据帧部分与接入相机流不一致

    pub接入自定义流 数据帧部分与接入相机流不一致

    首先感谢大佬的项目👍👍👍

    需求

    基于lal库做自己的应用,通过自定义流,接入lalserver服务,以rtsp的形式提供给第三方使用。

    版本

    v0.30.1

    实现

    自定义二次开发参考 customize_lalserver.go已实现。

    差异

    自定义流与接入相机流后,第三方应用从lalserver拉取rtsp的时候,数据帧中的sps和pps有区别。

    • 直接接入相机流(RTSP H264),sdp回调有sps和pps,数据帧也有完整sps和pps。

    • 自定义接入流时,sdp回调中有sps和pps,数据帧中没有sps和pps。

    影响

    会给第三方应用(比如录像)带来额外的工作量

    image

    解决方式

    自己做了个简单处理,在判断是关键帧时,关键处追加了sps和pps信息。

    spps := append(r.sps[:], append(avc.NaluStartCode4, r.pps...)...)
    nal = append(spps, append(avc.NaluStartCode4, nal...)...)
    r.clearVideoSeqHeader()
    

    https://github.com/q191201771/lal/blob/82f092128f584aedb7bf2b2e02acdbc9e0416b68/pkg/remux/avpacket2rtmp.go#L197

  • 无法转发带token验证的rtsp链接的疑问

    无法转发带token验证的rtsp链接的疑问

    首先感谢作者的开源和帮助

    1. 我用ffmpeg 进行了普通rtsp推流,lal能够正常转发和转流。
    2. 对于一台nvr的 rtsp://xxxxxxx?token=12345, lal不能正常转发

    我想问一下,请问代码里面对于 第二种 使用场景目前有支持吗,如果有支持的话,我再检查下

    如果没有支持的话,可以告诉我一下在哪里改吗,我可以自己改了再PR给本项目

    谢谢

  • pullrtmp2pushrtmp 转推地址部分平台无法解析

    pullrtmp2pushrtmp 转推地址部分平台无法解析

    视频号推流地址(无法转推) rtmp://111583.livepush.myqcloud.com/trtc_1400439699/live_2078417772407243576?txSecret=a406ad944287c4a54bfeff63d4b8bea7&txTime=626785A5 B站地址(无法转推) rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_520152711_16309405&key=b35c1c447e10134e5e4ef9de161e1235&schedule=rtmp&pflag=1

    快手地址(可以转推) rtmp://open-push.voip.yximgs.com/gifshow/kwai_actL_ol_act_9452380093_strL_origin?sign=62971bf6-f52fdaf4e7c3c77e51264cfa9b1b94b7&ks_fix_ts

    lal自己地址(可以转推) rtmp://127.0.0.1/live/test220

  • crash issues

    crash issues

    2022/03/17 10:12:32.695575 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS16] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:33.639745 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS17] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:35.158588 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS18] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:35.651467 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS19] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:35.742931 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS20] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:37.159199 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS21] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:37.254519 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS22] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:43.073283 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS23] invalid audio message length. len=2 - rtmp2mpegts.go:281
    2022/03/17 10:12:45.847994 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS21] invalid video message length. header={Csid:6 MsgLen:5 MsgTypeId:9 MsgStreamId:1 TimestampAbs:8680}, payload=00000000  17 02 0>
     - rtmp2mpegts.go:148
    2022/03/17 10:12:49.777507 ^[[22;31mERROR ^[[0m[RTMP2MPEGTS24] invalid audio message length. len=2 - rtmp2mpegts.go:281
    
    
  • RTSP 1080视频花屏

    RTSP 1080视频花屏

    测试环境

    • 测试版本:lal_v0.19.1_linux,默认配置

    出现问题

    • RTSP over udp 推流1080p视频: ffmpeg -re -stream_loop -1 -i "bbb_sunflower_1080p_30fps_normal.mp4" -an -vcodec copy -f rtsp rtsp://localhost:5544/live/test110
    • ffplay播放rtsp,看几秒钟后兔子出洞后花屏,每次重新播放花屏的时间和位置都一样。
    • 转rtmp播放或者改为rtsp over tcp推流均没有问题
    • RTSP over udp 推流小码流文件(source.200kbps.768x320.flv)没有这个问题

    测试资源

    • bbb_sunflower_1080p_30fps_normal.mp4 国外
    • bbb_sunflower_1080p_30fps_normal.mp4 国内
  • 关于文档中命名PushSession, PullSession, PubSession, SubSession的疑问

    关于文档中命名PushSession, PullSession, PubSession, SubSession的疑问

    官方文档中提到:

    A连接B,A向B发送数据:
    
    A | --connect--> | B
      | --av data--> |
    上面这种情况:
    
    A属于ClientSession+OutSession,我们称之为PushSession
    B属于ServerSession+InSession,我们称之为PubSession
    另一种情况,A连接B,B向A发送数据:
    
    A | --connect--> | B
      | <--av data-- |
    上面这种情况:
    
    A属于ClientSession+InSession,我们称之为PullSession
    B属于ServerSession+OutSession,我们称之为SubSession
    

    ========================================

    我的疑问是: ServerSession+InSession,为什么叫PubSession? Publish不应该是发布出去,out的方向吗?

    ServerSession+OutSession,为什么叫SubSession? Subscribe是订阅别人的消息,in的方向

    我对PullSession和PushSession的理解没有问题,但是PubSession和SubSession我理解和文档是相反的

  • Save video livestream after finish

    Save video livestream after finish

    i want save video livestream after finish to cloud storage, I wil open service down hls link and push to S3. Is there a better and more optimal way than what I'm planning to do? Thank you so much ?

  • After API post server not store changes

    After API post server not store changes

    Describe how to replicate the issue:

    • enable API in config
    • start the server
    • change something with API or add new start_relay_pull
    • restart the server result: config file not changed, old config loaded @q191201771
Parse and generate m3u8 playlists for Apple HTTP Live Streaming (HLS) in Golang (ported from gem https://github.com/sethdeckard/m3u8)

go-m3u8 Golang package for m3u8 (ported m3u8 gem https://github.com/sethdeckard/m3u8) go-m3u8 provides easy generation and parsing of m3u8 playlists d

Nov 19, 2022
RTSP 1.0 client and server library for the Go programming language

RTSP 1.0 client and server library for the Go programming language

Jan 3, 2023
golang library for mux and demux file containers such as mpeg-ts,mpeg-ps,flv

gomedia mpeg-ts,mpeg-ps,flv muxer/demuxer mpeg-ts muxer mpeg-ts demuxer mpeg-ps muxer mpeg-ps demuxer flv muxer flv demuxer mpeg-ps will be done in th

Jan 4, 2023
Take control over your live stream video by running it yourself. Streaming + chat out of the box.
Take control over your live stream video by running it yourself.  Streaming + chat out of the box.

Take control over your content and stream it yourself. Explore the docs » View Demo · Use Our Server for Testing · FAQ · Report Bug Table of Contents

Jan 1, 2023
Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:

M3U8 This is the most complete opensource library for parsing and generating of M3U8 playlists used in HTTP Live Streaming (Apple HLS) for internet vi

Dec 20, 2022
hls converter.

hlsconv hls converter. 外部依赖 ffmpeg: 4.2.1 使用方式 linix/macos # 转换单个文件 bin/hlsconv -i video/in.mp4 -o outvideo/ # 批量转换文件 bin/hlsconv -i video/ -o outvide

Jan 15, 2022
live video streaming server in golang
live video streaming server in golang

中文 Simple and efficient live broadcast server: Very simple to install and use; Pure Golang, high performance, and cross-platform; Supports commonly us

Jan 4, 2023
live streaming server in golang
live streaming server in golang

中文 Simple and efficient live broadcast server: Very simple to install and use; Pure Golang, high performance, and cross-platform; Supports commonly us

Nov 10, 2022
Live on-demand transcoding in go using ffmpeg. Also with NVIDIA GPU hardware acceleration.

Go live HTTP on-demand transcoding Transcoding is expensive and resource consuming operation on CPU and GPU. For big companies with thousands of custo

Dec 16, 2022
A live streaming tool more suitable for non-graphical servers

KPlayer KPlayer可以帮助你快速的在服务器上进行视频资源的循环直播推流。

Jan 2, 2023
Stream video from ffmpeg to webrtc

ffmpeg-to-webrtc demonstrates how to send video from ffmpeg to your browser using pion.

Dec 28, 2022
A tool to stream videos📺 directly into VLC media player just by its name from terminal.
A tool to stream videos📺 directly into VLC media player just by its name from terminal.

PeerWatch A tool to stream videos directly into the VLC media player. Download Download the tool from here: Windows Linux win-x64 linux-x64 Building Y

Feb 12, 2022
Personal video streaming server.

tube This is a Golang project to build a self hosted "tube"-style video player for watching your own video collection over HTTP or hosting your own ch

Jan 5, 2023
Go4vl is Go library for working with the Video for Linux API (V4L2) natively, without any C bindings.

go4vl A Go library for working with the Video for Linux user API (V4L2). Gov4l hides all the complexities of working with V4L2 and exposes idiomatic G

Dec 23, 2022
Golang bindings for FFmpeg

goav Golang binding for FFmpeg A comprehensive binding to the ffmpeg video/audio manipulation library. Usage import "github.com/giorgisio/goav/avforma

Dec 27, 2022
golang library to read and write various subtitle formats

libgosubs Golang library to read and write subtitles in the following formats Advanced SubStation Alpha v4 SRT TTML v1.0 - This is based on the spec p

Sep 27, 2022
Video converter with golang

Requirements Debian-like system (ubuntu, mint, etc...) with apt package manager Golang >1.15 Command tool make (use sudo apt install make -y to instal

Sep 10, 2022
ffmpeg core for golang

go-ffmpeg-core ffmpeg core for golang 基于ffmpeg命令封装简单功能,因此运行环境需事先安装有ffmpeg命令。 ffmpeg官方下载地址: http://ffmpeg.org/download.html 1. 剥离视频文件的音频/视频 package mai

Nov 26, 2021
golang function that download a video from youtube, and convert it to a mp3 file using ffmpeg

echedwnmp3 echedwnmp3 is a function that download a video from youtube, and convert it to a mp3 file using ffmpeg example package main import(echedwn

Dec 7, 2021