A live streaming tool more suitable for non-graphical servers

KPlayer

KPlayer可以帮助你快速的在服务器上进行视频资源的循环直播推流。本仓库为libkplayer的golang封装版本

查看帮助文档:https://kplayer.net/p/1

kplayer是什么

kplayer为你提供最小化成本搭建视频推流功能的工具,最优的推流方案OBS或其他软件依赖与xWindow或图形化界面的需要,不适合在服务端与云服务器上进行部署。KPlayer无需依赖图形化界面,您可以使用任意一款你喜欢的发行版本即可实现多视频资源无缝推流的方案。

只需要定义您的配置文件,针对定制化的修改。即可达成想要的结果。并且可以24小时无人值守的方式运行它。

有什么特性

  1. 多视频资源无缝推流 媒体资源推流,通常是单个资源文件连续推流。如果你有这方面的经验,那么肯定使用过ffmpeg或者obs的方案来进行推流直播。
  • 与ffmpeg相比。想要实现多资源连续推流的方式通过concat配合-loop可以达到或者使用循环运行ffmpeg命令来长时间推流。但是无法动态控制视频资源的顺序,而且在视频存在差异性的情况下,必须保证视频参数的高度一致性。类似分辨率,码率,sardar,声道数量等造成极大的不便。使用命令行循环推流则会导致资源切换时会出现资源断流的情况,严重时会出现编码数据不匹配(绿屏、音画不同步...)
  • 与obs相比。obs更依赖图形化界面的GUI操作,依赖实时编码。这在服务器上将变得不太友好。
  1. 预生成缓存,节省硬件资源 如果你的场景是循环推流,并不需要进行实时编码。KPlayer提供缓存机制,将上一次推流的数据缓存下来。下一次直接使用缓存文件,这将极大的降低你的机器CPU与内存占用量,仅使用较小的资源可以完成不间断推流。

KPlayer也支持在高性能机器上预生成缓存,传输至性能较小的服务器上直接使用缓存推流。降低资源占用量

  1. 支持多输出资源 KPlayer不仅支持输入资源的定义,对输出资源也允许定义多个输出资源并行推流。这意味着,你可以在不同的推流平台上显示一致的视频画面。

同时支持你配置重连机制,在某些原因下由于服务端的意外断开。你可以允许KPlyaer不被中断,并在某个时间段后进行尝试重新连接。

  1. 提供丰富的API接口辅助第三方应用控制 若具备基础的编码能力,KPlayer支持你通过jsonrpc调用的方式去控制它的播放行为。包括但不限于添加/删除输入资源文件、添加/删除输出资源、暂停、跳过等等等...

API是动态控制的,不必重新运行它。

  1. 提供可热拔插的插件机制,并提供自定义插件开发 丰富视频资源内容,我们提供了插件的机制。通过插件的配置,你可以实现插件提供的各种功能。例如在直播资源中添加一行文字、添加一个图片水印、显示时间、进度条等等...

并且支持你开发自定义插件提供给其他人使用。

什么样的设计

  1. 编码语言 KPlayer从v0.5.0以上由以下编程语言构成。
  • C++17 实现编解码与输入输出的核心逻辑
  • Golang 实现用户交互态的业务逻辑
  • Rust/C++ 提供插件的实现功能

相较于v0.4.x的版本,我们将各个功能解耦方便迭代开发提供更好的迭代周期和功能开发

  1. 解耦设计 KPlayer的整体控制逻辑依赖于消息队列通信,在主程序编码中可以看到大量的消息事件的处理,方便各模块中的功能解耦。同时多线程间彼此通过消息通信进行逻辑解耦

在对libkplayer与外界交互信息上,使用protobuf进行数据交互。如果有幸你参与到插件的开发工作中来,相信这会对你带来较大的便利

  1. 插件机制 得益于插件的设计逻辑,可以丰富推流视频中的内容。v0.4.x内的插件依赖于动态链接库的加载,不好的地方就是插件行为将变得不可控(读取机器磁盘文件、访问网络资源)...

得益于WebAssembly的出色设计,我们使用wasm来完成插件的编码与运行。我们可以严格控制每个插件的可访问行为。在无授权的情况下,它并不能访问任何关于你机器上的任何数据。你可以放心的使用它而不必担心会存在恶意插件或插件被篡改的情况产生。并且你可以使用你熟悉的任何语言来编写插件,只要它符合wasm标准

未来会支持什么

  1. 提供更多的插件
  2. 提供更多的辅助工具降低入门成本
  3. 完善的辅助文档
Comments
  • json配置文件中的rpc开关不起作用

    json配置文件中的rpc开关不起作用

        "rpc": {
          "on": false,
          "http_port": 4158,
          "grpc_port": 4159,
          "address": "0.0.0.0"
        }
    

    设置为false不起作用

  • 配置文件中avg_quality设置为0时候

    配置文件中avg_quality设置为0时候

    这是我的配置文件

    {
        "version": "2.0.0",
        "resource": {
            "lists": [
                "/home/ubuntu/kplayer/videos"
            ],
            "extensions": [
                "mkv"
            ]
        },
        "output": {
            "reconnect_internal": 3,
            "lists": [
                {
                    "path": "rtmp://xxxxxxxxxxxxx",
                    "unique": "aaa"
                },
                {
                    "path": "rtmp://xxxxxxxxxxx",
                    "unique": "me"
                }
            ]
        },
        "play": {
            "encode": {
                "video_width": 854,
                "video_height": 480,
                "video_fps": 24,
                "audio_channel_layout": 3,
                "audio_sample_rate": 44100,
                "bit_rate": 1,
                "avg_quality": 0
            },
            "reconnect_internal": 3,
            "play_model": "loop",
            "cache_on": true,
            "skip_invalid_resource": true,
            "rpc": {
                "on": true,
                "http_port": 4156,
                "grpc_port": 4157,
                "address": "0.0.0.0"
            }
        }
    }
    

    报错如下

    ubuntu@VM-4-13-ubuntu:~/kplayer$ ./kplayer play start
    kplayer for golang v0.5.6 Copyright(c) 2019-2022 the ByteLang Studio (https://kplayer.bytelang.cn)
      libkplayer version: v1.4.14 plugin version: 1.5.1 license version: v1
      toolchains GNU(10.3.1) C++ Standard 17 on Linux-x86_64-5.18.14-arch1-1
      build with build-chains cmake(3.21.3) type with Release
      Hope you have a good experience.
    -------------------------------------------------------------------------------------------------------------------
    INFO[2022-09-29 22:55:08] grpc server listening                         address=0.0.0.0 port=4157
    INFO[2022-09-29 22:55:08] http server listening                         address=0.0.0.0 port=4156
    ERRO[2022-09-29 22:55:08] output add failed. error: Generic error in an external library [-542398533]  error="Generic error in an external library [-542398533]" path="rtmp://xxxxxxxxxxxxxxxxxxx" unique=aaa
    INFO[2022-09-29 22:55:08] will be reconnect on after 3 seconds          path="rtmp://xxxxxxxxxxxxxxxxxxx" unique=aaa
    INFO[2022-09-29 22:55:08] core start up success
    ERRO[2022-09-29 22:55:08] output add failed. error: Generic error in an external library [-542398533]  error="Generic error in an external library [-542398533]" path="rtmp://xxxxxxxxxxxxxxxx" unique=me
    INFO[2022-09-29 22:55:08] kplayer start success
    INFO[2022-09-29 22:55:09] checked play resource                         duration=7610 hit_cache=false path="/home/ubuntu/kplayer/videos/2021-09-10 17-07-46.mkv" unique=FJJzqe
    ERRO[2022-09-29 22:55:09] core return error                             code=-542398533 error="[P17KPEncodeException] error: Generic error in an external library [-542398533]. file: codec/KPEncode.cpp. line: 175"
    INFO[2022-09-29 22:55:09] core shut down success
    
  • 报错:context deadline exceeded (Client.Timeout exceeded while awaiting headers)

    报错:context deadline exceeded (Client.Timeout exceeded while awaiting headers)

    [root@localhost kplayer]# ./kplayer play start kplayer for golang v0.5.7 Copyright(c) 2019-2022 the ByteLang Studio (https://kplayer.bytelang.cn) libkplayer version: v1.5.2 plugin version: 1.5.1 license version: v1 toolchains GNU(10.3.1) C++ Standard 17 on Linux-x86_64-5.18.14-arch1-1 build with build-chains cmake(3.21.3) type with Release Hope you have a good experience.

    FATA[2022-12-22 00:10:07] Get "https://v2api.kplayer.bytelang.cn:443/v1/resource/info?type=font&name=default&": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

  • 运行MP3链接到一半就错误(code=-110;error=decode failed.)了

    运行MP3链接到一半就错误(code=-110;error=decode failed.)了

    我是用docker的,好不容易开发了网易云点歌工具= =然后发现每次都是运行到一半就出现错误。具体错误信息如下:

    ERRO[2022-12-18 16:49:00] core return error code=-110 error="decode failed. file path: http://m701.music.126.net/20221219010741/76226bd3ae41d37386681a767592614f/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/15893871801/89ff/62da/120b/e2f07a40b4c1e23f0dc1305087cc8976.mp3. error: Operation timed out [-110]. file: codec/KPMix.cpp. line: 147"

    我也不知道是不是网易云的问题,但是我自己用浏览器去下载或者试听都没有断流这个问题

  • 关于show-time插件的时区问题

    关于show-time插件的时区问题

    由于在docker容器内,时区和系统时区不一样,导致使用show-time插件显示时间的时候,会比北京时间差8个小时,建议,可以在show-time插件的配置参数内,增加一个时区配置参数,可以在这里显式指定所需要显示的时区,应该会方便不少。 PS:如果能够再增加一个time format参数就更好了,这样可以自由指定时间日期显示格式了。

    感谢。

Related tags
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
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
🔥 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
🔥 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

lal是一个开源GoLang直播流媒体网络传输项目,包含三个主要组成部分: lalserver:流媒体转发服务器。类似于nginx-rtmp-module等应用,但支持更多的协议,提供更丰富的功能。lalserver简介 demo:一些小应用,比如推、拉流客户端,压测工具,流分析工具,调度示例程序等

Jan 1, 2023
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
Quik.do is a video conferencing tool.
Quik.do is a video conferencing tool.

Quik.do is a video conferencing tool.

Jan 3, 2023
xyz, is a tool for automating actions based on events from various sources used by streamers.
xyz, is a tool for automating actions based on events from various sources used by streamers.

Streaming Automation Software Support · Download · Report Bug · Request Feature What is xyz? xyz, is a tool for automating actions based on events fro

Nov 21, 2022
Frf-media-download - This tool downloads all the files you have uploaded to FreeFeed

FreeFeed Media Downloader This tool downloads all the files you have uploaded to

Jan 29, 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
SlideXtract - A tool to help extract slides from a video file.

SlideXtract A tool to help extract slides from a video file. Slides are output in the out folder. Features I didn't find any other piece of code that

Jul 3, 2022
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.

Red Team TL;DR English | 中文简体 What is Red Team TL;DR ? red-tldr is a lightweight text search tool, which is used to help red team staff quickly find t

Jan 5, 2023
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
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
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 from your terminal
Live streaming from your terminal

TStream - Streaming from terminal ??‍♂️ Come stream at tstream.club How to start streaming Please refer to this link Upcoming features One command to

Jan 2, 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
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

Jan 6, 2023
Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021
Live reload utility for Go web servers

gin gin is a simple command line utility for live-reloading Go web applications. Just run gin in your app directory and your web app will be served wi

Jan 4, 2023