44 "bytes"
55 "os"
66 "testing"
7+
8+ "github.com/Eyevinn/mp4ff/avc"
9+ "github.com/Eyevinn/mp4ff/mp4"
710)
811
912func TestOptions (t * testing.T ) {
@@ -13,8 +16,6 @@ func TestOptions(t *testing.T) {
1316 expectedErr bool
1417 goldenOut string
1518 }{
16- {desc : "vvc 2s" , args : []string {appName , "../../mp4/testdata/vvc_400kbps_2s.mp4" }, expectedErr : false ,
17- goldenOut : "testdata/golden_vvc_2s.txt" },
1819 {desc : "no args" , args : []string {appName }, expectedErr : true },
1920 {desc : "unknown args" , args : []string {appName , "-x" }, expectedErr : true },
2021 {desc : "non-existing file" , args : []string {appName , "infile.mp4" }, expectedErr : true },
@@ -40,7 +41,10 @@ func TestOptions(t *testing.T) {
4041 goldenOut : "testdata/golden_h264_frag_raw.txt" , expectedErr : false },
4142 {desc : "avcSeiTime" , args : []string {appName , "-sei" , "2" , "-annexb" , "testdata/4pics.264" },
4243 goldenOut : "testdata/golden_4pic_sei_264.txt" , expectedErr : false },
43-
44+ {desc : "vvc 2s" , args : []string {appName , "../../mp4/testdata/vvc_400kbps_2s.mp4" }, expectedErr : false ,
45+ goldenOut : "testdata/golden_vvc_2s.txt" },
46+ {desc : "vvc annexB" , args : []string {appName , "-annexb" , "-c" , "vvc" , "testdata/annexB.vvc" }, expectedErr : false ,
47+ goldenOut : "testdata/golden_vvc_annexb.txt" },
4448 {desc : "version" , args : []string {appName , "-version" }, expectedErr : false },
4549 {desc : "help" , args : []string {appName , "-h" }, expectedErr : false },
4650 }
@@ -78,3 +82,29 @@ func getExpected(t *testing.T, filename string) string {
7882 r := bytes .ReplaceAll (b , []byte ("\r \n " ), []byte ("\n " ))
7983 return string (r )
8084}
85+
86+ func MakeByteStream (t * testing.T , inFile , outFile string ) {
87+ t .Helper ()
88+ ifd , err := os .Open (inFile )
89+ if err != nil {
90+ t .Fatalf ("could not open file %s: %s" , inFile , err )
91+ }
92+ d , err := mp4 .DecodeFile (ifd )
93+ if err != nil {
94+ t .Fatalf ("could not decode file %s: %s" , inFile , err )
95+ }
96+ fullSamples , err := d .Segments [0 ].Fragments [0 ].GetFullSamples (nil )
97+ if err != nil {
98+ t .Fatalf ("could not get full samples: %s" , err )
99+ }
100+ byteStream := make ([]byte , 0 , 1024 )
101+ for i := 0 ; i <= 5 ; i ++ {
102+ fs := fullSamples [i ]
103+ bs := avc .ConvertSampleToByteStream (fs .Data )
104+ byteStream = append (byteStream , bs ... )
105+ }
106+ err = os .WriteFile (outFile , byteStream , 0644 )
107+ if err != nil {
108+ t .Fatalf ("could not write file %s: %s" , outFile , err )
109+ }
110+ }
0 commit comments