Skip to content

Commit

Permalink
Revert "go modules added, fixed mediafile and tests"
Browse files Browse the repository at this point in the history
This reverts commit b06797a.
  • Loading branch information
xfrr committed Apr 2, 2020
1 parent b06797a commit eb404c9
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 79 deletions.
5 changes: 0 additions & 5 deletions go.mod

This file was deleted.

11 changes: 0 additions & 11 deletions go.sum

This file was deleted.

23 changes: 6 additions & 17 deletions models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package models
import (
"fmt"
"io"
"os/exec"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -49,7 +48,6 @@ type Mediafile struct {
inputPipeReader *io.PipeReader
inputPipeWriter *io.PipeWriter
outputPipe bool
inputPipeCommand *exec.Cmd
outputPipeReader *io.PipeReader
outputPipeWriter *io.PipeWriter
movFlags string
Expand Down Expand Up @@ -239,10 +237,6 @@ func (m *Mediafile) SetInputPipe(val bool) {
m.inputPipe = val
}

func (m *Mediafile) SetInputPipeCommand(command *exec.Cmd) {
m.inputPipeCommand = command
}

func (m *Mediafile) SetInputPipeReader(r *io.PipeReader) {
m.inputPipeReader = r
}
Expand Down Expand Up @@ -518,10 +512,6 @@ func (m *Mediafile) InputPipe() bool {
return m.inputPipe
}

func (m *Mediafile) InputPipeCommand() *exec.Cmd {
return m.inputPipeCommand
}

func (m *Mediafile) InputPipeReader() *io.PipeReader {
return m.inputPipeReader
}
Expand Down Expand Up @@ -652,7 +642,6 @@ func (m *Mediafile) ToStrCommand() []string {
"HardwareAcceleration",
"InputPath",
"InputPipe",
"InputPipeCommand",
"HideBanner",
"Aspect",
"Resolution",
Expand Down Expand Up @@ -766,7 +755,7 @@ func (m *Mediafile) ObtainInputPath() []string {
return nil
}

func (m *Mediafile) ObtainInputPipeCommand() []string {
func (m *Mediafile) ObtainInputPipe() []string {
if m.inputPipe {
return []string{"-i", "pipe:0"}
}
Expand Down Expand Up @@ -1144,10 +1133,10 @@ func (m *Mediafile) ObtainCompressionLevel() []string {
func (m *Mediafile) ObtainMapMetadata() []string {
if m.mapMetadata != "" {
return []string{"-map_metadata", m.mapMetadata}
}
return nil
}
return nil
}

func (m *Mediafile) ObtainEncryptionKey() []string {
return []string{"-hls_key_info_file", m.encryptionKey}
}
Expand All @@ -1166,6 +1155,6 @@ func (m *Mediafile) ObtainTags() []string {
result = append(result, []string{"-metadata", fmt.Sprintf("%s=%s", key, val)}...)
}
return result
}
return nil
}
return nil
}
154 changes: 108 additions & 46 deletions tests/transcoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,169 +13,231 @@ import (

func TestInputNotFound(t *testing.T) {

var inputPath = "/tmp/ffmpeg/mkv"
var outputPath = "/tmp/ffmpeg/out/mkv.mp4"
var inputPath = "/data/testmkv"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
return
}
}

func TestTranscoding3GP(t *testing.T) {

var inputPath = "/tmp/ffmpeg/3gp"
var outputPath = "/tmp/ffmpeg/out/3gp.mp4"
var inputPath = "/data/test3gp"
var outputPath = "/data/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingAVI(t *testing.T) {

var inputPath = "/tmp/ffmpeg/avi"
var outputPath = "/tmp/ffmpeg/out/avi.mp4"
var inputPath = "/data/testavi"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingFLV(t *testing.T) {

var inputPath = "/tmp/ffmpeg/flv"
var outputPath = "/tmp/ffmpeg/out/flv.mp4"
var inputPath = "/data/testflv"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingMKV(t *testing.T) {

var inputPath = "/tmp/ffmpeg/mkv"
var outputPath = "/tmp/ffmpeg/out/mkv.mp4"
var inputPath = "/data/testmkv"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingMOV(t *testing.T) {

var inputPath = "/tmp/ffmpeg/mov"
var outputPath = "/tmp/ffmpeg/out/mov.mp4"
var inputPath = "/data/testmov"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingMPEG(t *testing.T) {

var inputPath = "/tmp/ffmpeg/mpeg"
var outputPath = "/tmp/ffmpeg/out/mpeg.mp4"
var inputPath = "/data/testmpeg"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingOGG(t *testing.T) {

var inputPath = "/tmp/ffmpeg/ogg"
var outputPath = "/tmp/ffmpeg/out/ogg.mp4"
var inputPath = "/data/testogg"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingWAV(t *testing.T) {

var inputPath = "/tmp/ffmpeg/wav"
var outputPath = "/tmp/ffmpeg/out/wav.mp4"
var inputPath = "/data/testwav"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingWEBM(t *testing.T) {

var inputPath = "/tmp/ffmpeg/webm"
var outputPath = "/tmp/ffmpeg/out/webm.mp4"
var inputPath = "/data/testwebm"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingWMV(t *testing.T) {

var inputPath = "/tmp/ffmpeg/wmv"
var outputPath = "/tmp/ffmpeg/out/wmv.mp4"
var inputPath = "/data/testwmv"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}

done := trans.Run(false)
err = <-done
assert.Nil(t, err)
if err != nil {
t.Error(err)
return
}
}

func TestTranscodingProgress(t *testing.T) {

var inputPath = "/tmp/ffmpeg/avi"
var outputPath = "/tmp/ffmpeg/out/avi.mp4"
var inputPath = "/data/testavi"
var outputPath = "/data/out/testmp4.mp4"

trans := new(transcoder.Transcoder)

Expand All @@ -200,7 +262,7 @@ func TestTranscodingProgress(t *testing.T) {
}

func TestTranscodePipes(t *testing.T) {
c1 := exec.Command("cat", "/tmp/ffmpeg/mkv")
c1 := exec.Command("cat", "/tmp/data/testmkv")

trans := new(transcoder.Transcoder)

Expand Down

0 comments on commit eb404c9

Please sign in to comment.