Skip to content

Commit

Permalink
[release] v3.1.2
Browse files Browse the repository at this point in the history
hot-fix: for missing SPS and PPS from opening codec.
  • Loading branch information
cedricve committed Jan 9, 2024
1 parent 00e0b0b commit 442ba97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions machinery/src/capture/Gortsplib.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (g *Golibrtsp) Connect(ctx context.Context) (err error) {
// It might be that the SPS is not available yet, so we'll proceed,
// but try to fetch it later on.
if errSPS != nil {
log.Log.Debug("capture.golibrtsp.Connect(H264): " + err.Error())
log.Log.Debug("capture.golibrtsp.Connect(H264): " + errSPS.Error())
g.Streams = append(g.Streams, packets.Stream{
Name: formaH264.Codec(),
IsVideo: true,
Expand Down Expand Up @@ -537,7 +537,6 @@ func (g *Golibrtsp) Start(ctx context.Context, streamType string, queue *packets

pkt.Data = pkt.Data[4:]
if pkt.IsKeyFrame {

annexbNALUStartCode := func() []byte { return []byte{0x00, 0x00, 0x00, 0x01} }
pkt.Data = append(annexbNALUStartCode(), pkt.Data...)
pkt.Data = append(g.VideoH264Forma.PPS, pkt.Data...)
Expand Down
16 changes: 12 additions & 4 deletions machinery/src/capture/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ func HandleRecordStream(queue *packets.Queue, configDirectory string, configurat
//cws = newCacheWriterSeeker(4096)
myMuxer, _ = mp4.CreateMp4Muxer(file)
// We choose between H264 and H265
width := configuration.Config.Capture.IPCamera.Width
height := configuration.Config.Capture.IPCamera.Height
widthOption := mp4.WithVideoWidth(uint32(width))
heightOption := mp4.WithVideoHeight(uint32(height))
if pkt.Codec == "H264" {
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H264)
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H264, widthOption, heightOption)
} else if pkt.Codec == "H265" {
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H265)
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H265, widthOption, heightOption)
}
// For an MP4 container, AAC is the only audio codec supported.
audioTrack = myMuxer.AddAudioTrack(mp4.MP4_CODEC_AAC)
Expand Down Expand Up @@ -386,10 +390,14 @@ func HandleRecordStream(queue *packets.Queue, configDirectory string, configurat
// Check which video codec we need to use.
videoSteams, _ := rtspClient.GetVideoStreams()
for _, stream := range videoSteams {
width := configuration.Config.Capture.IPCamera.Width
height := configuration.Config.Capture.IPCamera.Height
widthOption := mp4.WithVideoWidth(uint32(width))
heightOption := mp4.WithVideoHeight(uint32(height))
if stream.Name == "H264" {
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H264)
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H264, widthOption, heightOption)
} else if stream.Name == "H265" {
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H265)
videoTrack = myMuxer.AddVideoTrack(mp4.MP4_CODEC_H265, widthOption, heightOption)
}
}
// For an MP4 container, AAC is the only audio codec supported.
Expand Down

0 comments on commit 442ba97

Please sign in to comment.