mirror of
				https://github.com/lkmio/lkm.git
				synced 2025-10-31 10:36:25 +08:00 
			
		
		
		
	修复rtmp音视频不同步问题
This commit is contained in:
		| @@ -44,14 +44,8 @@ func (t *httpTransStream) Input(packet utils.AVPacket) error { | ||||
| 	var dts int64 | ||||
| 	var pts int64 | ||||
|  | ||||
| 	if utils.AVCodecIdAAC == packet.CodecId() { | ||||
| 		dts = packet.ConvertDts(1024) | ||||
| 		pts = packet.ConvertPts(1024) | ||||
| 	} else { | ||||
| 	dts = packet.ConvertDts(1000) | ||||
| 	pts = packet.ConvertPts(1000) | ||||
| 	} | ||||
|  | ||||
| 	if utils.AVMediaTypeAudio == packet.MediaType() { | ||||
| 		flvSize = 17 + len(packet.Data()) | ||||
| 		data = packet.Data() | ||||
|   | ||||
| @@ -16,7 +16,7 @@ type Publisher struct { | ||||
| } | ||||
|  | ||||
| func NewPublisher(sourceId string, stack *librtmp.Stack, conn net.Conn) *Publisher { | ||||
| 	deMuxer := libflv.NewDeMuxer(libflv.TSModeRelative) | ||||
| 	deMuxer := libflv.NewDeMuxer() | ||||
| 	publisher_ := &Publisher{PublishSource: stream.PublishSource{Id_: sourceId, Type_: stream.SourceTypeRtmp, TransDeMuxer: deMuxer, Conn: conn}, stack: stack} | ||||
| 	//设置回调,从flv解析出来的Stream和AVPacket都将统一回调到stream.PublishSource | ||||
| 	deMuxer.SetHandler(publisher_) | ||||
|   | ||||
| @@ -36,14 +36,8 @@ func (t *transStream) Input(packet utils.AVPacket) error { | ||||
| 	var pts int64 | ||||
| 	chunkHeaderSize := 12 | ||||
|  | ||||
| 	if utils.AVCodecIdAAC == packet.CodecId() { | ||||
| 		dts = packet.ConvertDts(1024) | ||||
| 		pts = packet.ConvertPts(1024) | ||||
| 	} else { | ||||
| 	dts = packet.ConvertDts(1000) | ||||
| 	pts = packet.ConvertPts(1000) | ||||
| 	} | ||||
|  | ||||
| 	if dts >= 0xFFFFFF { | ||||
| 		chunkHeaderSize += 4 | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 yangjiechina
					yangjiechina