RTMP 1.0 server/client library written in Go.
Work in progress
go get github.com/yutopp/go-rtmp
See also server_demo and client_demo.
- Please use yutopp/go-iowrap.
RTMP 1.0 server/client library written in Go.
License: Boost Software License 1.0
RTMP 1.0 server/client library written in Go.
Work in progress
go get github.com/yutopp/go-rtmp
See also server_demo and client_demo.
Is it possible to determine the FPS of the incoming RTMP stream?
original code of rtmp OnAudio function like this,
func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error {
var audio flvtag.AudioData
if err := flvtag.DecodeAudioData(payload, &audio); err != nil {
return err
}
flvBody := new(bytes.Buffer)
if _, err := io.Copy(flvBody, audio.Data); err != nil {
return err
}
audio.Data = flvBody
_ = h.pub.Publish(&flvtag.FlvTag{
TagType: flvtag.TagTypeAudio,
Timestamp: timestamp,
Data: &audio,
})
return nil
}
and i want to chage the code that publish audio data every 0.5 second
so trying like this
func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error {
var audio flvtag.AudioData
if err := flvtag.DecodeAudioData(payload, &audio); err != nil {
return err
}
// if flag == true, startTimeStamp Control
if h.Flag == true {
h.startTimeStamp = timestamp
//h.Buf = new(bytes.Buffer)
h.Buf.Reset()
}
h.Flag = false
buf := new(bytes.Buffer)
if _, err := io.Copy(buf, audio.Data); err != nil {
return err
}
if audio.AACPacketType == 0 {
audio.Data = buf
tag := &flvtag.FlvTag{
TagType: flvtag.TagTypeAudio,
Timestamp: h.startTimeStamp,
Data: &audio,
}
timestamp, (timestamp - h.startTimeStamp), buf.Len())
_ = h.pub.Publish(tag)
h.Flag = true
return nil
}
h.Buf.Write(buf.Bytes())
// collect audio data into h.Buf and then publish every 0.5 seconds
if timestamp-h.startTimeStamp >= 500 {
h.lastTimeStamp = timestamp
audio.Data = h.Buf
tag := &flvtag.FlvTag{
TagType: flvtag.TagTypeAudio,
Timestamp: h.startTimeStamp,
Data: &audio,
}
_ = h.pub.Publish(tag)
h.Flag = true
}
return nil
}
when i check the audio data size There is no Data loss but Audio Data is Broken.
Is there any problem with my code?
Is there any documentation I can refer to?
Do you observe an effect when stream in relay mode decays after 2 minutes? with 1080 its more visible
For example:rtmp://video-center.alivecdn.com/record/3518?vhost=rec.livecourse.com"
path is : /record/3518?vhost=rec.livecourse.com
I want to continuously save the recording from rtmp
I want to change the filename dynamically according to PublishingName periodically.
Can i do that
Currently, handler
provides methods OnCommand
, OnData
, etc, and a user uses a type switch to assign logic per commands/data.
This method has an advantage to reduce methods of the interface, however it is too dynamic.
Maybe it is better to provide methods of all commands/data as a interface, and a default implementation of the interface, then let users use it by mixin.
Error()
function may generate a large string when there are many elements in Objs
.
the stream keeps increasing the flv file size other than that hls is capable for transferring media on lots of platforms
should we convert the flv stream to hls or is there a way to implement it in the code
Calling Server.Close
method before the listener registration in Server.Serve
cause a timing problem which failed to call listener.Close
.
Hi
Before i dig in, is it possible to use this lib to Push and h264 Stream to YouTube. The example for Client is Limited some advice would be great.
Thx
Hi!
Thanks a lot for your work!
ffmpeg -i file.mp4 -c copy -f flv rtmp://0.0.0.0:1935/xxx/yyy
rtmp://0.0.0.0:1935/xxx/yyy
http://0.0.0.0:8080/xxx/yyy
App
in OnPlay
or OnPublish
hooks of handler?I am successfully receiving stream on my server from OBS studio. I am poking my head around but I figure someone should have the answer. How to I take stream and throw it up to AWS S3?
Great Go code first of all!
However, it is hard to implement Play within current code architecture. The server is basically setup to be a passive handler. For example, after a rtmp player sends out play command and gets back the play succeed response. It sits there and waits for server to send video and audio chunks. But in server_data_play_handler.go
, it is still waiting for message send from client. How could we write a play function that fits nicely in current architecture?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.