mirror of https://bitbucket.org/ausocean/av.git
lex: modified h264 lexer to consider nal type 6 packets, i.e. sei packets, which seem important fro repeating single frames
This commit is contained in:
parent
28d23ad200
commit
10860e4e48
|
@ -30,10 +30,10 @@ LICENSE
|
|||
package rtmp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -171,24 +171,24 @@ func TestFromFrame(t *testing.T) {
|
|||
t.Errorf("Session.Open failed with error: %v", err)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(filepath.Join(testDataDir, "AusOcean_logo_1080p.h264"))
|
||||
// TODO: don't hard code this path
|
||||
b, err := ioutil.ReadFile("/home/saxon/Desktop/singleframe.h264")
|
||||
if err != nil {
|
||||
t.Errorf("ReadFile failed with error: %v", err)
|
||||
}
|
||||
|
||||
// Pass RTMP session, true for audio, true for video, and 25 FPS
|
||||
// ToDo: fix this. Although we can encode the file and YouTube
|
||||
// doesn't complain, YouTube doesn't play it (even when we
|
||||
// send 1 minute's worth).
|
||||
flvEncoder := flv.NewEncoder(s, true, true, 25)
|
||||
for i := 0; i < 25; i++ {
|
||||
err := flvEncoder.Encode(b)
|
||||
if err != nil {
|
||||
t.Errorf("Encoding failed with error: %v", err)
|
||||
}
|
||||
time.Sleep(time.Millisecond / 25) // rate limit to 1/25s
|
||||
const noOfFrames = 1000
|
||||
videoData := make([]byte, 0, noOfFrames*len(b))
|
||||
for i := 0; i < noOfFrames; i++ {
|
||||
videoData = append(videoData, b...)
|
||||
}
|
||||
|
||||
const frameRate = 25
|
||||
flvEncoder := flv.NewEncoder(s, true, true, frameRate)
|
||||
err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate))
|
||||
if err != nil {
|
||||
t.Errorf("Lexing failed with error: %v", err)
|
||||
}
|
||||
err = s.Close()
|
||||
if err != nil {
|
||||
t.Errorf("Session.Close failed with error: %v", err)
|
||||
|
|
|
@ -120,9 +120,10 @@ outer:
|
|||
nonIdrPic = 1
|
||||
idrPic = 5
|
||||
paramSet = 8
|
||||
sei = 6
|
||||
)
|
||||
switch nalTyp := b & 0x1f; nalTyp {
|
||||
case nonIdrPic, idrPic, paramSet:
|
||||
case nonIdrPic, idrPic, paramSet, sei:
|
||||
writeOut = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue