Coder Social home page Coder Social logo

go-rtmp's Introduction

go-rtmp's People

Contributors

dw-hkoba avatar hsnks100 avatar jbreich avatar julienbreux avatar kosidibe avatar locxiang avatar octu0 avatar paralin avatar tobbee avatar tobyapi avatar yutopp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-rtmp's Issues

is it possible to publish audio data every 0.5 second?

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?

can the stream be converted to hls ?

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

Rtmp Server to save flv file

I want to continuously save the recording from rtmp
I want to change the filename dynamically according to PublishingName periodically.
Can i do that

How do take path meaasge

For example:rtmp://video-center.alivecdn.com/record/3518?vhost=rec.livecourse.com"

path is : /record/3518?vhost=rec.livecourse.com

How to implement Play within current architecture

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?

Revert: hander interfaces

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.

[help] How to get "App" in "On*" hooks?

Hi!

Thanks a lot for your work!

My use cases:

  1. I want to publish via ffmpeg ffmpeg -i file.mp4 -c copy -f flv rtmp://0.0.0.0:1935/xxx/yyy
  2. I want to read from VLC rtmp://0.0.0.0:1935/xxx/yyy
  3. I want to read from HTTP http://0.0.0.0:8080/xxx/yyy

My questions:

  1. Do I need to create a buffer per app?
  2. How to access to App in OnPlay or OnPublish hooks of handler?

Stream to YouTube

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.