From 4b403b3f1819d5e08c6f51795627f71a8a310674 Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Mon, 22 Aug 2022 03:08:22 +0800 Subject: [PATCH] =?utf8?q?=E5=BF=BD=E7=95=A5flv=E9=A6=96=E9=9F=B3=E8=A7=86?= =?utf8?q?=E9=A2=91=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Reply/flvDecode.go | 5 ++++- Reply/flvDecode_test.go | 15 +++++++++++++++ Reply/stream.go | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Reply/flvDecode_test.go diff --git a/.gitignore b/.gitignore index c4db72c..daf8476 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ demo/live demo/main.exe *.m4s *.m3u8 +*.flv \ No newline at end of file diff --git a/Reply/flvDecode.go b/Reply/flvDecode.go index 27b0aa0..ecaf1e4 100644 --- a/Reply/flvDecode.go +++ b/Reply/flvDecode.go @@ -442,6 +442,9 @@ func Seach_stream_tag(buf []byte) (front_buf []byte, keyframe [][]byte, last_avi defer func() { if sign != 0x07 { + // if sign != 0x00 { + // fmt.Printf("front_buf error:%x\n", sign) + // } front_buf = []byte{} } if len(keyframe) > 0 { @@ -502,7 +505,7 @@ func Seach_stream_tag(buf []byte) (front_buf []byte, keyframe [][]byte, last_avi tag_num += 1 - if time_stamp == 0 { + if time_stamp == 0 || sign != 0x00 { // ignore first video audio time_stamp if len(front_buf) != 0 { //first video audio script tag if (buf[tag_offset] == video_tag) && (sign&0x04 == 0x00) { diff --git a/Reply/flvDecode_test.go b/Reply/flvDecode_test.go new file mode 100644 index 0000000..ea69a4b --- /dev/null +++ b/Reply/flvDecode_test.go @@ -0,0 +1,15 @@ +package reply + +import ( + "bytes" + "testing" + + p "github.com/qydysky/part" +) + +func Test_flv(t *testing.T) { + f := p.File().FileWR(p.Filel{ + File: "1.flv", + }) + Seach_stream_tag(bytes.NewBufferString(f).Bytes()) +} diff --git a/Reply/stream.go b/Reply/stream.go index 7371e62..2adf85e 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -510,6 +510,7 @@ func (t *M4SStream) saveStreamFlv() { if e := r.Reqf(reqf.Rval{ Url: surl.String(), SaveToPipeWriter: rw, + SaveToPath: t.Current_save_path + `1.flv`, NoResponse: true, Proxy: t.common.Proxy, Header: map[string]string{ -- 2.39.2