mirror of
https://github.com/asticode/go-astiav.git
synced 2025-09-26 20:21:15 +08:00
Added missing format context tests
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
.DS_STORE
|
||||
coverage.out
|
||||
tmp
|
||||
coverage.out
|
@@ -35,7 +35,7 @@ func TestFormatContext(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "v=0\r\no=- 0 0 IN IP4 127.0.0.1\r\ns=Big Buck Bunny\r\nt=0 0\r\na=tool:libavformat 61.1.100\r\nm=video 0 RTP/AVP 96\r\nb=AS:441\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LADasgKDPz4CIAAAMAAgAAAwBhHihUkA==,aM48gA==; profile-level-id=42C00D\r\na=control:streamid=0\r\nm=audio 0 RTP/AVP 97\r\nb=AS:161\r\na=rtpmap:97 MPEG4-GENERIC/48000/2\r\na=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1190\r\na=control:streamid=1\r\n", sdp)
|
||||
|
||||
fc2, err := AllocOutputFormatContext(nil, "", "/tmp/test.mp4")
|
||||
fc2, err := AllocOutputFormatContext(nil, "mp4", "")
|
||||
require.NoError(t, err)
|
||||
defer fc2.Free()
|
||||
require.True(t, fc2.OutputFormat().Flags().Has(IOFormatFlagGlobalheader))
|
||||
@@ -83,11 +83,57 @@ func TestFormatContext(t *testing.T) {
|
||||
require.Equal(t, 1, len(ps))
|
||||
require.Equal(t, 1, ps[0].ID())
|
||||
|
||||
// TODO Test ReadFrame
|
||||
// TODO Test SeekFrame
|
||||
// TODO Test Flush
|
||||
// TODO Test WriteHeader
|
||||
// TODO Test WriteFrame
|
||||
// TODO Test WriteInterleavedFrame
|
||||
// TODO Test WriteTrailer
|
||||
fc6 := AllocFormatContext()
|
||||
require.NotNil(t, fc6)
|
||||
defer fc6.Free()
|
||||
require.NoError(t, fc6.OpenInput("testdata/video.mp4", nil, nil))
|
||||
require.NoError(t, fc6.FindStreamInfo(nil))
|
||||
require.Equal(t, 2, fc6.NbStreams())
|
||||
pkt1 := AllocPacket()
|
||||
require.NotNil(t, pkt1)
|
||||
defer pkt1.Free()
|
||||
require.NoError(t, fc6.ReadFrame(pkt1))
|
||||
require.Equal(t, int64(48), pkt1.Pos())
|
||||
pkt2 := AllocPacket()
|
||||
require.NotNil(t, pkt2)
|
||||
defer pkt2.Free()
|
||||
require.NoError(t, fc6.ReadFrame(pkt2))
|
||||
require.Equal(t, int64(261), pkt2.Pos())
|
||||
require.NoError(t, fc6.SeekFrame(0, 0, NewSeekFlags().Add(SeekFlagBackward)))
|
||||
require.NoError(t, fc6.ReadFrame(pkt1))
|
||||
require.Equal(t, int64(48), pkt1.Pos())
|
||||
|
||||
const outputPath = "tmp/test-format-context-output.mp4"
|
||||
fc7, err := AllocOutputFormatContext(nil, "", outputPath)
|
||||
require.NoError(t, err)
|
||||
defer fc7.Free()
|
||||
for _, is := range fc6.Streams() {
|
||||
os := fc7.NewStream(nil)
|
||||
require.NotNil(t, os)
|
||||
require.NoError(t, is.CodecParameters().Copy(os.CodecParameters()))
|
||||
}
|
||||
ic, err := OpenIOContext(outputPath, NewIOContextFlags(IOContextFlagWrite))
|
||||
require.NoError(t, err)
|
||||
fc7.SetPb(ic)
|
||||
require.NoError(t, fc7.WriteHeader(nil))
|
||||
require.NoError(t, fc7.WriteFrame(pkt1))
|
||||
require.NoError(t, fc7.WriteInterleavedFrame(pkt2))
|
||||
require.NoError(t, fc7.WriteTrailer())
|
||||
require.NoError(t, fc7.Flush())
|
||||
fc8 := AllocFormatContext()
|
||||
require.NotNil(t, fc8)
|
||||
defer fc8.Free()
|
||||
require.NoError(t, fc8.OpenInput(outputPath, nil, nil))
|
||||
require.NoError(t, fc8.FindStreamInfo(nil))
|
||||
require.Equal(t, 2, fc8.NbStreams())
|
||||
pkt3 := AllocPacket()
|
||||
require.NotNil(t, pkt3)
|
||||
defer pkt3.Free()
|
||||
require.NoError(t, fc8.ReadFrame(pkt3))
|
||||
require.Equal(t, int64(48), pkt3.Pos())
|
||||
pkt4 := AllocPacket()
|
||||
require.NotNil(t, pkt4)
|
||||
defer pkt4.Free()
|
||||
require.NoError(t, fc8.ReadFrame(pkt4))
|
||||
require.Equal(t, int64(261), pkt4.Pos())
|
||||
}
|
||||
|
1
internal/benchmarks/.gitignore
vendored
Normal file
1
internal/benchmarks/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tmp
|
1
internal/test/arm/7/.gitignore
vendored
Normal file
1
internal/test/arm/7/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tmp
|
2
tmp/.gitignore
vendored
Normal file
2
tmp/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Reference in New Issue
Block a user