Skip to content

Commit

Permalink
- [+] implement CPU shaping options support
Browse files Browse the repository at this point in the history
  • Loading branch information
suntong committed May 27, 2023
1 parent a26b88a commit 4718bf2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ffcvt.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ func transcodeVideos(startTime time.Time) {
videoNdx, videosTotal, v.pct, filepath.Base(inputName), filepath.Dir(inputName))
transcodeFile(inputName)
fmt.Printf("Time taken so far %s\n", time.Since(startTime))
if Opts.MaxC != 0 && videoNdx >= Opts.MaxC {
debug("Max conversion count reached.", 1)
os.Exit(0)
}
debug("Taking a breath for: "+Opts.BreathTime.String(), 1)
time.Sleep(Opts.BreathTime)
fmt.Printf("Finishing the remaining %d%% in %s\n",
100-v.pct,
time.Duration(int64(float32(time.Since(startTime))*
Expand Down
20 changes: 20 additions & 0 deletions test/ffcvt_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Flags:

-p par2create, create par2 files (in work directory) (FFCVT_P)
-nc no clobber, do not queue those already been converted (FFCVT_NC)
-bt breath time, interval between conversion to take a breath (FFCVT_BT)
-maxc max conversion done each run (default no limit) (FFCVT_MAXC)
-n no exec, dry run (FFCVT_N)

-force overwrite any existing none-empty file (FFCVT_FORCE)
Expand Down Expand Up @@ -83,6 +85,8 @@ Details:
no audio, output video only
-ato-opus
audio encode to opus, using -abr
-bt duration
breath time, interval between conversion to take a breath (default 2m0s)
-cfg string
cfg file to define your own targets: webm/wx/youtube etc
-crf string
Expand All @@ -108,6 +112,8 @@ Details:
Add a karaoke audio track to .mp4 MTV
-lang string
language selection for audio stream extraction (default "eng")
-maxc int
max conversion done each run (default no limit)
-n no exec, dry run
-nc
no clobber, do not queue those already been converted
Expand Down Expand Up @@ -289,6 +295,7 @@ Saved: 0%
ffcvt: to execute -
ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -304,6 +311,7 @@ Saved: 0%
ffcvt: to execute -
ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [2/4] (100%): 'test1.avi'
Expand All @@ -312,6 +320,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test1.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test1_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [3/4] (100%): 'test2.avi'
Expand All @@ -320,6 +329,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test2_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -328,6 +338,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test3_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -346,6 +357,7 @@ Saved: 0%
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
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -361,6 +373,7 @@ Saved: 0%
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
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [2/4] (100%): 'test1.avi'
Expand All @@ -369,6 +382,7 @@ Finishing the remaining 0% in xxx ms
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
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [3/4] (100%): 'test2.avi'
Expand All @@ -377,6 +391,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test2_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -385,6 +400,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test3_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -401,6 +417,7 @@ Saved: 0%
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 /tmp/test/StreamSample.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [2/4] (100%): 'test1.avi'
Expand All @@ -409,6 +426,7 @@ Finishing the remaining 0% in xxx ms
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 /tmp/test/test1.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [3/4] (100%): 'test2.avi'
Expand All @@ -417,6 +435,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test2.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -425,6 +444,7 @@ Finishing the remaining 0% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test3.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand Down
10 changes: 5 additions & 5 deletions test/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ $FFCVT -t x264-mp3 -n -f StreamSample.mkv -w /tmp -tkf 'F#' -tkt Db -vn -abr 72k
$FFCVT -t '' -n -f StreamSample.mkv -tkf Gb -tkt 'A#' -vn -abr 72k -aes libmp3lame -ext _.mp3 >> /tmp/ffcvt_test.txt 2>&1

echo '# Test -sym control' | tee -a /tmp/ffcvt_test.txt
$FFCVT -t x265-opus -n -d . >> /tmp/ffcvt_test.txt 2>&1
$FFCVT -t x265-opus -n -d . -sym >> /tmp/ffcvt_test.txt 2>&1
$FFCVT -t x265-opus -n -bt 0.1s -d . >> /tmp/ffcvt_test.txt 2>&1
$FFCVT -t x265-opus -n -bt 0.1s -d . -sym >> /tmp/ffcvt_test.txt 2>&1

$FFCVT -n -d . >> /tmp/ffcvt_test.txt 2>&1
$FFCVT -n -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 -sym -debug 2 -d . -w /tmp >> /tmp/ffcvt_test.txt 2>&1
$FFCVT -n -sym -debug 2 -bt 0.1s -d . -w /tmp >> /tmp/ffcvt_test.txt 2>&1

echo '# Compare test results, 0 means AOK:'
sed -i '/ [0-9.]*[nmµ]*s$/s// xxx ms/' /tmp/ffcvt_test.txt
Expand Down
18 changes: 18 additions & 0 deletions test2/ffcvt_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Flags:

-p par2create, create par2 files (in work directory) (FFCVT_P)
-nc no clobber, do not queue those already been converted (FFCVT_NC)
-bt breath time, interval between conversion to take a breath (FFCVT_BT)
-maxc max conversion done each run (default no limit) (FFCVT_MAXC)
-n no exec, dry run (FFCVT_N)

-force overwrite any existing none-empty file (FFCVT_FORCE)
Expand Down Expand Up @@ -83,6 +85,8 @@ Details:
no audio, output video only
-ato-opus
audio encode to opus, using -abr
-bt duration
breath time, interval between conversion to take a breath (default 2m0s)
-cfg string
cfg file to define your own targets: webm/wx/youtube etc
-crf string
Expand All @@ -108,6 +112,8 @@ Details:
Add a karaoke audio track to .mp4 MTV
-lang string
language selection for audio stream extraction (default "eng")
-maxc int
max conversion done each run (default no limit)
-n no exec, dry run
-nc
no clobber, do not queue those already been converted
Expand Down Expand Up @@ -297,6 +303,7 @@ Saved: 0%
ffcvt: to execute -
ffmpeg -i ./subdir/test_s1.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./subdir/test_s1_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 64% in xxx ms

== Transcoding [2/4] (57%): 'test1.avi'
Expand All @@ -305,6 +312,7 @@ Finishing the remaining 64% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test1.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test1_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 43% in xxx ms

== Transcoding [3/4] (78%): 'test2.avi'
Expand All @@ -313,6 +321,7 @@ Finishing the remaining 43% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test2_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 22% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -321,6 +330,7 @@ Finishing the remaining 22% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test3_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -347,6 +357,7 @@ Saved: 0%
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
] Taking a breath for: xxx ms
Finishing the remaining 64% in xxx ms

== Transcoding [2/4] (57%): 'test1.avi'
Expand All @@ -355,6 +366,7 @@ Finishing the remaining 64% in xxx ms
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
] Taking a breath for: xxx ms
Finishing the remaining 43% in xxx ms

== Transcoding [3/4] (78%): 'test2.avi'
Expand All @@ -363,6 +375,7 @@ Finishing the remaining 43% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test2_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 22% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -371,6 +384,7 @@ Finishing the remaining 22% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test3_.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand All @@ -387,6 +401,7 @@ Saved: 0%
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 /tmp/test2/subdir/test_s1.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 64% in xxx ms

== Transcoding [2/4] (57%): 'test1.avi'
Expand All @@ -395,6 +410,7 @@ Finishing the remaining 64% in xxx ms
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 /tmp/test2/test1.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 43% in xxx ms

== Transcoding [3/4] (78%): 'test2.avi'
Expand All @@ -403,6 +419,7 @@ Finishing the remaining 43% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test2/test2.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 22% in xxx ms

== Transcoding [4/4] (100%): 'test3.webm'
Expand All @@ -411,6 +428,7 @@ Finishing the remaining 22% in xxx ms
ffcvt: to execute -
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test2/test3.mkv
Time taken so far xxx ms
] Taking a breath for: xxx ms
Finishing the remaining 0% in xxx ms

Transcoding completed in xxx ms
Expand Down

0 comments on commit 4718bf2

Please sign in to comment.