Browse Source

switch to mkv test files

pull/340/head
aler9 4 years ago
parent
commit
0e59e3df5c
  1. 2
      Makefile
  2. 71
      main_clientrtmp_test.go
  3. 28
      main_clientrtsp_test.go
  4. 7
      main_sourcertmp_test.go
  5. 4
      main_sourcertsp_test.go
  6. 4
      main_test.go
  7. 2
      testimages/ffmpeg/Dockerfile
  8. BIN
      testimages/ffmpeg/emptyvideo.mkv
  9. BIN
      testimages/ffmpeg/emptyvideo.ts
  10. BIN
      testimages/ffmpeg/emptyvideoaudio.mkv
  11. BIN
      testimages/ffmpeg/emptyvideoaudio.ts
  12. 2
      testimages/gstreamer/Dockerfile
  13. BIN
      testimages/gstreamer/emptyvideo.mkv
  14. BIN
      testimages/gstreamer/emptyvideo.ts

2
Makefile

@ -95,7 +95,7 @@ paths: @@ -95,7 +95,7 @@ paths:
# runOnPublish: ffmpeg -i rtsp://localhost:$$RTSP_PORT/$$RTSP_PATH -c copy -f mpegts myfile_$$RTSP_PATH.ts
# readUser: test
# readPass: tast
# runOnDemand: ffmpeg -re -stream_loop -1 -i testimages/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:$$RTSP_PORT/$$RTSP_PATH
# runOnDemand: ffmpeg -re -stream_loop -1 -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$$RTSP_PORT/$$RTSP_PATH
# proxied:
# source: rtsp://192.168.2.198:554/stream

71
main_clientrtmp_test.go

@ -8,33 +8,40 @@ import ( @@ -8,33 +8,40 @@ import (
)
func TestClientRTMPPublish(t *testing.T) {
p, ok := testProgram("")
require.Equal(t, true, ok)
defer p.close()
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + ":1935/test1/test2",
})
require.NoError(t, err)
defer cnt1.close()
time.Sleep(1 * time.Second)
cnt2, err := newContainer("ffmpeg", "dest", []string{
"-rtsp_transport", "udp",
"-i", "rtsp://" + ownDockerIP + ":8554/test1/test2",
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
for _, source := range []string{
"videoaudio",
"video",
} {
t.Run(source, func(t *testing.T) {
p, ok := testProgram("")
require.Equal(t, true, ok)
defer p.close()
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "empty" + source + ".mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + ":1935/test1/test2",
})
require.NoError(t, err)
defer cnt1.close()
time.Sleep(1 * time.Second)
cnt2, err := newContainer("ffmpeg", "dest", []string{
"-rtsp_transport", "udp",
"-i", "rtsp://" + ownDockerIP + ":8554/test1/test2",
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
})
}
}
func TestClientRTMPRead(t *testing.T) {
@ -45,7 +52,7 @@ func TestClientRTMPRead(t *testing.T) { @@ -45,7 +52,7 @@ func TestClientRTMPRead(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://" + ownDockerIP + ":8554/teststream",
@ -79,7 +86,7 @@ func TestClientRTMPAuth(t *testing.T) { @@ -79,7 +86,7 @@ func TestClientRTMPAuth(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + "/teststream?user=testuser&pass=testpass",
@ -112,7 +119,7 @@ func TestClientRTMPAuth(t *testing.T) { @@ -112,7 +119,7 @@ func TestClientRTMPAuth(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + "/teststream",
@ -147,7 +154,7 @@ func TestClientRTMPAuthFail(t *testing.T) { @@ -147,7 +154,7 @@ func TestClientRTMPAuthFail(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + "/teststream?user=testuser&pass=testpass",
@ -180,7 +187,7 @@ func TestClientRTMPAuthFail(t *testing.T) { @@ -180,7 +187,7 @@ func TestClientRTMPAuthFail(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + ownDockerIP + "/teststream",

28
main_clientrtsp_test.go

@ -87,7 +87,7 @@ func TestClientRTSPPublishRead(t *testing.T) { @@ -87,7 +87,7 @@ func TestClientRTSPPublishRead(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", ca.publisherProto,
@ -100,7 +100,7 @@ func TestClientRTSPPublishRead(t *testing.T) { @@ -100,7 +100,7 @@ func TestClientRTSPPublishRead(t *testing.T) {
case "gstreamer":
cnt1, err := newContainer("gstreamer", "source", []string{
"filesrc location=emptyvideo.ts ! tsdemux ! video/x-h264 ! rtspclientsink " +
"filesrc location=emptyvideo.mkv ! matroskademux ! video/x-h264 ! rtspclientsink " +
"location=" + proto + "://" + ownDockerIP + ":" + port + "/teststream " +
"protocols=" + ca.publisherProto + " tls-validation-flags=0 latency=0 timeout=0 rtx-time=0",
})
@ -163,7 +163,7 @@ func TestClientRTSPAuth(t *testing.T) { @@ -163,7 +163,7 @@ func TestClientRTSPAuth(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -203,7 +203,7 @@ func TestClientRTSPAuth(t *testing.T) { @@ -203,7 +203,7 @@ func TestClientRTSPAuth(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -249,7 +249,7 @@ func TestClientRTSPAuth(t *testing.T) { @@ -249,7 +249,7 @@ func TestClientRTSPAuth(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -306,7 +306,7 @@ func TestClientRTSPAuthFail(t *testing.T) { @@ -306,7 +306,7 @@ func TestClientRTSPAuthFail(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -364,7 +364,7 @@ func TestClientRTSPAuthFail(t *testing.T) { @@ -364,7 +364,7 @@ func TestClientRTSPAuthFail(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -400,7 +400,7 @@ func TestClientRTSPAuthIpFail(t *testing.T) { @@ -400,7 +400,7 @@ func TestClientRTSPAuthIpFail(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -425,7 +425,7 @@ func TestClientRTSPAutomaticProtocol(t *testing.T) { @@ -425,7 +425,7 @@ func TestClientRTSPAutomaticProtocol(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://" + ownDockerIP + ":8554/teststream",
@ -455,7 +455,7 @@ func TestClientRTSPPublisherOverride(t *testing.T) { @@ -455,7 +455,7 @@ func TestClientRTSPPublisherOverride(t *testing.T) {
source1, err := newContainer("ffmpeg", "source1", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://" + ownDockerIP + ":8554/teststream",
@ -468,7 +468,7 @@ func TestClientRTSPPublisherOverride(t *testing.T) { @@ -468,7 +468,7 @@ func TestClientRTSPPublisherOverride(t *testing.T) {
source2, err := newContainer("ffmpeg", "source2", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://" + ownDockerIP + ":8554/teststream",
@ -695,7 +695,7 @@ func TestClientRTSPRedirect(t *testing.T) { @@ -695,7 +695,7 @@ func TestClientRTSPRedirect(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -742,7 +742,7 @@ func TestClientRTSPFallback(t *testing.T) { @@ -742,7 +742,7 @@ func TestClientRTSPFallback(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -771,7 +771,7 @@ func TestClientRTSPRunOnDemand(t *testing.T) { @@ -771,7 +771,7 @@ func TestClientRTSPRunOnDemand(t *testing.T) {
doneFile := filepath.Join(os.TempDir(), "ondemand_done")
onDemandFile, err := writeTempFile([]byte(fmt.Sprintf(`#!/bin/sh
trap 'touch %s; [ -z "$(jobs -p)" ] || kill $(jobs -p)' INT
ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH &
ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH &
wait
`, doneFile)))
require.NoError(t, err)

7
main_sourcertmp_test.go

@ -19,15 +19,10 @@ func TestSourceRTMP(t *testing.T) { @@ -19,15 +19,10 @@ func TestSourceRTMP(t *testing.T) {
require.NoError(t, err)
defer cnt1.close()
input := "emptyvideoaudio.ts"
if source == "video" {
input = "emptyvideo.ts"
}
cnt2, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", input,
"-i", "empty" + source + ".mkv",
"-c", "copy",
"-f", "flv",
"rtmp://" + cnt1.ip() + "/stream/test",

4
main_sourcertsp_test.go

@ -37,7 +37,7 @@ func TestSourceRTSP(t *testing.T) { @@ -37,7 +37,7 @@ func TestSourceRTSP(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
@ -83,7 +83,7 @@ func TestSourceRTSP(t *testing.T) { @@ -83,7 +83,7 @@ func TestSourceRTSP(t *testing.T) {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsps://" + ownDockerIP + ":8555/teststream",

4
main_test.go

@ -184,7 +184,7 @@ func TestHotReloading(t *testing.T) { @@ -184,7 +184,7 @@ func TestHotReloading(t *testing.T) {
err := ioutil.WriteFile(confPath, []byte("paths:\n"+
" test1:\n"+
" runOnDemand: ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH\n"+
" runOnDemand: ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH\n"+
" test3:\n"+
" runOnInit: echo aaa\n"+
" test4:\n"+
@ -213,7 +213,7 @@ func TestHotReloading(t *testing.T) { @@ -213,7 +213,7 @@ func TestHotReloading(t *testing.T) {
err = ioutil.WriteFile(confPath, []byte("paths:\n"+
" test2:\n"+
" runOnDemand: ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH\n"+
" runOnDemand: ffmpeg -hide_banner -loglevel error -re -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH\n"+
" test3:\n"+
" test4:\n"+
" runOnInit: echo bbb\n"),

2
testimages/ffmpeg/Dockerfile

@ -3,7 +3,7 @@ FROM amd64/alpine:3.12 @@ -3,7 +3,7 @@ FROM amd64/alpine:3.12
RUN apk add --no-cache \
ffmpeg
COPY *.ts /
COPY *.mkv /
COPY start.sh /
RUN chmod +x /start.sh

BIN
testimages/ffmpeg/emptyvideo.mkv

Binary file not shown.

BIN
testimages/ffmpeg/emptyvideo.ts

Binary file not shown.

BIN
testimages/ffmpeg/emptyvideoaudio.mkv

Binary file not shown.

BIN
testimages/ffmpeg/emptyvideoaudio.ts

Binary file not shown.

2
testimages/gstreamer/Dockerfile

@ -38,7 +38,7 @@ RUN apt update && apt install -y --no-install-recommends \ @@ -38,7 +38,7 @@ RUN apt update && apt install -y --no-install-recommends \
COPY --from=build /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libexitafterframe.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/
COPY emptyvideo.ts /
COPY emptyvideo.mkv /
COPY start.sh /
RUN chmod +x /start.sh

BIN
testimages/gstreamer/emptyvideo.mkv

Binary file not shown.

BIN
testimages/gstreamer/emptyvideo.ts

Binary file not shown.
Loading…
Cancel
Save