Skip to content

Commit a26b88a

Browse files
committed
- [+] add two CPU shaping options
1 parent d3693a9 commit a26b88a

3 files changed

Lines changed: 54 additions & 35 deletions

File tree

config.go

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"flag"
99
"fmt"
1010
"os"
11+
"time"
1112
)
1213

1314
////////////////////////////////////////////////////////////////////////////
@@ -17,39 +18,41 @@ const progname = "ffcvt" // os.Args[0]
1718

1819
// The Options struct defines the structure to hold the commandline values
1920
type Options struct {
20-
Cfg string // cfg file to define your own targets: webm/wx/youtube etc
21-
Target string // target type: webm/x265-opus/x264-mp3/wx/youtube/copy, or empty
22-
Encoding // anonymous field to hold encoding values
23-
Directory string // directory that hold input files
24-
File string // input file name (either -d or -f must be specified)
25-
Links bool // symlinks will be processed as well
26-
Exts string // extension list for all the files to be queued
27-
Suffix string // suffix to the output file names
28-
WDirectory string // work directory that hold output files
29-
AC bool // copy audio codec
30-
VC bool // copy video codec
31-
AN bool // no audio, output video only
32-
VN bool // no video, output audio only
33-
VSS bool // video: same size
34-
Cut mFlags // Cut segment(s) out to keep. Specify in the form of start-[end],\n\tstrictly in the format of hh:mm:ss, and may repeat
35-
Seg string // Split video into multiple segments (strictly in format: hh:mm:ss)
36-
Speed string // Speed up/down video playback speed (e.g. 1.28)
37-
Karaoke bool // Add a karaoke audio track to .mp4 MTV
38-
TranspFrom string // Transpose song's key from (e.g. C/C#/Db/D etc)
39-
TranspTo string // Transpose song's key to (e.g. -tkf C -tkt Db)
40-
Lang string // language selection for audio stream extraction
41-
SEL mFlags // subtitle encoding language (language picked for reencoded video)
42-
OptExtra string // more options that will pass to ffmpeg program
43-
A2Opus bool // audio encode to opus, using -abr
44-
V2X265 bool // video video encode to x265, using -crf
45-
Par2C bool // par2create, create par2 files (in work directory)
46-
NoClobber bool // no clobber, do not queue those already been converted
47-
NoExec bool // no exec, dry run
48-
Force bool // overwrite any existing none-empty file
49-
Debug int // debugging level
50-
FFMpeg string // ffmpeg program executable name
51-
FFProbe string // ffprobe program execution
52-
PrintV bool // print version then exit
21+
Cfg string // cfg file to define your own targets: webm/wx/youtube etc
22+
Target string // target type: webm/x265-opus/x264-mp3/wx/youtube/copy, or empty
23+
Encoding // anonymous field to hold encoding values
24+
Directory string // directory that hold input files
25+
File string // input file name (either -d or -f must be specified)
26+
Links bool // symlinks will be processed as well
27+
Exts string // extension list for all the files to be queued
28+
Suffix string // suffix to the output file names
29+
WDirectory string // work directory that hold output files
30+
AC bool // copy audio codec
31+
VC bool // copy video codec
32+
AN bool // no audio, output video only
33+
VN bool // no video, output audio only
34+
VSS bool // video: same size
35+
Cut mFlags // Cut segment(s) out to keep. Specify in the form of start-[end],\n\tstrictly in the format of hh:mm:ss, and may repeat
36+
Seg string // Split video into multiple segments (strictly in format: hh:mm:ss)
37+
Speed string // Speed up/down video playback speed (e.g. 1.28)
38+
Karaoke bool // Add a karaoke audio track to .mp4 MTV
39+
TranspFrom string // Transpose song's key from (e.g. C/C#/Db/D etc)
40+
TranspTo string // Transpose song's key to (e.g. -tkf C -tkt Db)
41+
Lang string // language selection for audio stream extraction
42+
SEL mFlags // subtitle encoding language (language picked for reencoded video)
43+
OptExtra string // more options that will pass to ffmpeg program
44+
A2Opus bool // audio encode to opus, using -abr
45+
V2X265 bool // video video encode to x265, using -crf
46+
Par2C bool // par2create, create par2 files (in work directory)
47+
NoClobber bool // no clobber, do not queue those already been converted
48+
BreathTime time.Duration // breath time, interval between conversion to take a breath
49+
MaxC int // max conversion done each run (default no limit)
50+
NoExec bool // no exec, dry run
51+
Force bool // overwrite any existing none-empty file
52+
Debug int // debugging level
53+
FFMpeg string // ffmpeg program executable name
54+
FFProbe string // ffprobe program execution
55+
PrintV bool // print version then exit
5356
}
5457

5558
////////////////////////////////////////////////////////////////////////////
@@ -147,6 +150,10 @@ func initVars() {
147150
"par2create, create par2 files (in work directory)")
148151
flag.BoolVar(&Opts.NoClobber, "nc", false,
149152
"no clobber, do not queue those already been converted")
153+
flag.DurationVar(&Opts.BreathTime, "bt", 120*time.Second,
154+
"breath time, interval between conversion to take a breath")
155+
flag.IntVar(&Opts.MaxC, "maxc", 0,
156+
"max conversion done each run (default no limit)")
150157
flag.BoolVar(&Opts.NoExec, "n", false,
151158
"no exec, dry run")
152159

@@ -322,7 +329,7 @@ func initVals() {
322329

323330
}
324331

325-
const usageSummary = " -cfg\tcfg file to define your own targets: webm/wx/youtube etc (FFCVT_CFG)\n -t\ttarget type: webm/x265-opus/x264-mp3/wx/youtube/copy, or empty (FFCVT_T)\n -ves\tvideo encoding method set (FFCVT_VES)\n -aes\taudio encoding method set (FFCVT_AES)\n -ses\tsubtitle encoding method set (FFCVT_SES)\n -vep\tvideo encoding method prepend (FFCVT_VEP)\n -aep\taudio encoding method prepend (FFCVT_AEP)\n -sep\tsubtitle encoding method prepend (FFCVT_SEP)\n -vea\tvideo encoding method append (FFCVT_VEA)\n -aea\taudio encoding method append (FFCVT_AEA)\n -abr\taudio bitrate (64k for opus, 256k for mp3) (FFCVT_ABR)\n -crf\tthe CRF value: 0-51. Higher CRF gives lower quality\n\t (28 for x265, ~ 23 for x264) (FFCVT_CRF)\n\n -d\tdirectory that hold input files (FFCVT_D)\n -f\tinput file name (either -d or -f must be specified) (FFCVT_F)\n -sym\tsymlinks will be processed as well (FFCVT_SYM)\n -exts\textension list for all the files to be queued (FFCVT_EXTS)\n -suf\tsuffix to the output file names (FFCVT_SUF)\n -ext\textension for the output file (FFCVT_EXT)\n -w\twork directory that hold output files (FFCVT_W)\n\n -ac\tcopy audio codec (FFCVT_AC)\n -vc\tcopy video codec (FFCVT_VC)\n -an\tno audio, output video only (FFCVT_AN)\n -vn\tno video, output audio only (FFCVT_VN)\n -vss\tvideo: same size (FFCVT_VSS)\n -C,Cut\tCut segment(s) out to keep. Specify in the form of start-[end],\n\tstrictly in the format of hh:mm:ss, and may repeat (FFCVT_C,CUT)\n -S,Seg\tSplit video into multiple segments (strictly in format: hh:mm:ss) (FFCVT_S,SEG)\n -Speed\tSpeed up/down video playback speed (e.g. 1.28) (FFCVT_SPEED)\n -K,karaoke\tAdd a karaoke audio track to .mp4 MTV (FFCVT_K,KARAOKE)\n -tkf\tTranspose song's key from (e.g. C/C#/Db/D etc) (FFCVT_TKF)\n -tkt\tTranspose song's key to (e.g. -tkf C -tkt Db) (FFCVT_TKT)\n -lang\tlanguage selection for audio stream extraction (FFCVT_LANG)\n -sel\tsubtitle encoding language (language picked for reencoded video) (FFCVT_SEL)\n -o\tmore options that will pass to ffmpeg program (FFCVT_O)\n -ato-opus\taudio encode to opus, using -abr (FFCVT_ATO_OPUS)\n -vto-x265\tvideo video encode to x265, using -crf (FFCVT_VTO_X265)\n\n -p\tpar2create, create par2 files (in work directory) (FFCVT_P)\n -nc\tno clobber, do not queue those already been converted (FFCVT_NC)\n -n\tno exec, dry run (FFCVT_N)\n\n -force\toverwrite any existing none-empty file (FFCVT_FORCE)\n -debug\tdebugging level (FFCVT_DEBUG)\n -ffmpeg\tffmpeg program executable name (FFCVT_FFMPEG)\n -ffprobe\tffprobe program execution (FFCVT_FFPROBE)\n -version\tprint version then exit (FFCVT_VERSION)\n\nDetails:\n\n"
332+
const usageSummary = " -cfg\tcfg file to define your own targets: webm/wx/youtube etc (FFCVT_CFG)\n -t\ttarget type: webm/x265-opus/x264-mp3/wx/youtube/copy, or empty (FFCVT_T)\n -ves\tvideo encoding method set (FFCVT_VES)\n -aes\taudio encoding method set (FFCVT_AES)\n -ses\tsubtitle encoding method set (FFCVT_SES)\n -vep\tvideo encoding method prepend (FFCVT_VEP)\n -aep\taudio encoding method prepend (FFCVT_AEP)\n -sep\tsubtitle encoding method prepend (FFCVT_SEP)\n -vea\tvideo encoding method append (FFCVT_VEA)\n -aea\taudio encoding method append (FFCVT_AEA)\n -abr\taudio bitrate (64k for opus, 256k for mp3) (FFCVT_ABR)\n -crf\tthe CRF value: 0-51. Higher CRF gives lower quality\n\t (28 for x265, ~ 23 for x264) (FFCVT_CRF)\n\n -d\tdirectory that hold input files (FFCVT_D)\n -f\tinput file name (either -d or -f must be specified) (FFCVT_F)\n -sym\tsymlinks will be processed as well (FFCVT_SYM)\n -exts\textension list for all the files to be queued (FFCVT_EXTS)\n -suf\tsuffix to the output file names (FFCVT_SUF)\n -ext\textension for the output file (FFCVT_EXT)\n -w\twork directory that hold output files (FFCVT_W)\n\n -ac\tcopy audio codec (FFCVT_AC)\n -vc\tcopy video codec (FFCVT_VC)\n -an\tno audio, output video only (FFCVT_AN)\n -vn\tno video, output audio only (FFCVT_VN)\n -vss\tvideo: same size (FFCVT_VSS)\n -C,Cut\tCut segment(s) out to keep. Specify in the form of start-[end],\n\tstrictly in the format of hh:mm:ss, and may repeat (FFCVT_C,CUT)\n -S,Seg\tSplit video into multiple segments (strictly in format: hh:mm:ss) (FFCVT_S,SEG)\n -Speed\tSpeed up/down video playback speed (e.g. 1.28) (FFCVT_SPEED)\n -K,karaoke\tAdd a karaoke audio track to .mp4 MTV (FFCVT_K,KARAOKE)\n -tkf\tTranspose song's key from (e.g. C/C#/Db/D etc) (FFCVT_TKF)\n -tkt\tTranspose song's key to (e.g. -tkf C -tkt Db) (FFCVT_TKT)\n -lang\tlanguage selection for audio stream extraction (FFCVT_LANG)\n -sel\tsubtitle encoding language (language picked for reencoded video) (FFCVT_SEL)\n -o\tmore options that will pass to ffmpeg program (FFCVT_O)\n -ato-opus\taudio encode to opus, using -abr (FFCVT_ATO_OPUS)\n -vto-x265\tvideo video encode to x265, using -crf (FFCVT_VTO_X265)\n\n -p\tpar2create, create par2 files (in work directory) (FFCVT_P)\n -nc\tno clobber, do not queue those already been converted (FFCVT_NC)\n -bt\tbreath time, interval between conversion to take a breath (FFCVT_BT)\n -maxc\tmax conversion done each run (default no limit) (FFCVT_MAXC)\n -n\tno exec, dry run (FFCVT_N)\n\n -force\toverwrite any existing none-empty file (FFCVT_FORCE)\n -debug\tdebugging level (FFCVT_DEBUG)\n -ffmpeg\tffmpeg program executable name (FFCVT_FFMPEG)\n -ffprobe\tffprobe program execution (FFCVT_FFPROBE)\n -version\tprint version then exit (FFCVT_VERSION)\n\nDetails:\n\n"
326333

327334
// Usage function shows help on commandline usage
328335
func Usage() {

ffcvt_cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ templateFile=$GOPATH/src/github.com/go-easygen/easygen/test/commandlineFlag
66
exit 1
77
}
88

9-
easygen $templateFile ffcvt_cli | tee /tmp/ffcvt_cli.go | sed '/\tVES\t\tstring/{ N; N; N; N; N; N; N; N; N; s|^.*$|\tEncoding\t// anonymous field to hold encoding values|; }; /\tExt\t\tstring/d; /flag.MFlagsVar/{s/flag.MFlagsVar/flag.Var/; s/, "",/,/; } ' | gofmt > config.go
9+
easygen $templateFile ffcvt_cli | tee /tmp/ffcvt_cli.go | sed '/\tVES\t\tstring/{ N; N; N; N; N; N; N; N; N; s|^.*$|\tEncoding\t// anonymous field to hold encoding values|; }; /\tExt\t\tstring/d; /flag.MFlagsVar/{s/flag.MFlagsVar/flag.Var/; s/, "",/,/; } ' | goimports > config.go

ffcvt_cli.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ Options:
266266
Value: false
267267
Usage: "no clobber, do not queue those already been converted"
268268

269+
- Name: BreathTime
270+
Type: duration
271+
Flag: bt
272+
Value: '120*time.Second'
273+
Usage: "breath time, interval between conversion to take a breath"
274+
275+
- Name: MaxC
276+
Type: int
277+
Flag: maxc
278+
Value: 0
279+
Usage: max conversion done each run (default no limit)
280+
269281
- Name: NoExec
270282
Type: bool
271283
Flag: "n"

0 commit comments

Comments
 (0)