From 0a47842314ea853d6d399c85dfbcc7f875249f9f Mon Sep 17 00:00:00 2001 From: Tong Sun Date: Fri, 26 May 2023 22:43:34 -0400 Subject: [PATCH] - [+] FFCVT_MAXC support added for -maxc --- config.go | 13 +++++++++++++ ffcvt.go | 1 + test/ffcvt_test.txt | 10 ++++++++++ test/test-all.sh | 1 + test2/ffcvt_test.txt | 10 ++++++++++ 5 files changed, 35 insertions(+) diff --git a/config.go b/config.go index 7995ec0..9e4b976 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,7 @@ import ( "flag" "fmt" "os" + "strconv" "time" ) @@ -308,6 +309,12 @@ func initVals() { if _, exists = os.LookupEnv("FFCVT_NC"); Opts.NoClobber || exists { Opts.NoClobber = true } + if Opts.MaxC == 0 || + len(os.Getenv("FFCVT_MAXC")) != 0 { + if i, err := strconv.Atoi(os.Getenv("FFCVT_MAXC")); err == nil { + Opts.MaxC = i + } + } if _, exists = os.LookupEnv("FFCVT_N"); Opts.NoExec || exists { Opts.NoExec = true } @@ -315,6 +322,12 @@ func initVals() { if _, exists = os.LookupEnv("FFCVT_FORCE"); Opts.Force || exists { Opts.Force = true } + if Opts.Debug == 0 || + len(os.Getenv("FFCVT_DEBUG")) != 0 { + if i, err := strconv.Atoi(os.Getenv("FFCVT_DEBUG")); err == nil { + Opts.Debug = i + } + } if len(Opts.FFMpeg) == 0 || len(os.Getenv("FFCVT_FFMPEG")) != 0 { Opts.FFMpeg = os.Getenv("FFCVT_FFMPEG") diff --git a/ffcvt.go b/ffcvt.go index 5779096..0c58f09 100644 --- a/ffcvt.go +++ b/ffcvt.go @@ -115,6 +115,7 @@ func main() { os.Exit(0) } + //fmt.Printf("%+v\n", Opts) if len(Opts.Seg) > 0 { // sanity check _, err := time.Parse("15:04:05", Opts.Seg) diff --git a/test/ffcvt_test.txt b/test/ffcvt_test.txt index 1ab812e..1ea4628 100644 --- a/test/ffcvt_test.txt +++ b/test/ffcvt_test.txt @@ -426,6 +426,16 @@ ffcvt: to execute - ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test1_.mkv Time taken so far xxx ms ] Max conversion count reached. +] None-video file './ffcvt_test.txt' duplicated to dest dir. +] None-video file './test-all.sh' duplicated to dest dir. + +== Transcoding [1/4] (100%): 'StreamSample.mkv' + under . +] ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv +ffcvt: to execute - + ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv +Time taken so far xxx ms +] Max conversion count reached. ] Transcoding to /tmp/test ] None-video file './ffcvt_test.txt' duplicated to dest dir. ] None-video file './test-all.sh' duplicated to dest dir. diff --git a/test/test-all.sh b/test/test-all.sh index 95790e1..e160e5f 100755 --- a/test/test-all.sh +++ b/test/test-all.sh @@ -40,6 +40,7 @@ $FFCVT -t x265-opus -n -bt 0.1s -d . -sym >> /tmp/ffcvt_test.txt 2>&1 $FFCVT -n -bt 0.1s -d . >> /tmp/ffcvt_test.txt 2>&1 $FFCVT -n -bt 0.1s -d . -sym >> /tmp/ffcvt_test.txt 2>&1 $FFCVT -n -bt 0.1s -d . -sym -maxc 2 >> /tmp/ffcvt_test.txt 2>&1 +FFCVT_MAXC=1 $FFCVT -n -bt 0.1s -d . -sym >> /tmp/ffcvt_test.txt 2>&1 $FFCVT -n -sym -debug 2 -bt 0.1s -d . -w /tmp >> /tmp/ffcvt_test.txt 2>&1 diff --git a/test2/ffcvt_test.txt b/test2/ffcvt_test.txt index 4ef5116..aa5d659 100644 --- a/test2/ffcvt_test.txt +++ b/test2/ffcvt_test.txt @@ -410,6 +410,16 @@ ffcvt: to execute - ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test1_.mkv Time taken so far xxx ms ] Max conversion count reached. +] None-video file './ffcvt_test.txt' duplicated to dest dir. +] None-video file './test-all.sh' duplicated to dest dir. + +== Transcoding [1/4] (36%): 'test_s1.avi' + under subdir +] ffmpeg -i ./subdir/test_s1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./subdir/test_s1_.mkv +ffcvt: to execute - + ffmpeg -i ./subdir/test_s1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./subdir/test_s1_.mkv +Time taken so far xxx ms +] Max conversion count reached. ] Transcoding to /tmp/test2 ] None-video file './ffcvt_test.txt' duplicated to dest dir. ] None-video file './test-all.sh' duplicated to dest dir.