-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ffmpeg): implement new features of ffmpeg 7 #1040
Open
skrashevich
wants to merge
11
commits into
AlexxIT:master
Choose a base branch
from
skrashevich:feat-ffmpeg-7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+286
−3
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a93e55c
feat(ffmpeg): adapt ffmpeg args for version 7.0
skrashevich a8cfc72
feat(core): replace semver with FlexVer for version comparison
skrashevich 24e4cb5
feat(core): handle comparison errors in CompareVersions
skrashevich ad9b2b6
feat(api): include FFmpeg version in API response
skrashevich 7412476
feat(www): display FFmpeg version in info section
skrashevich 42bd62e
Merge remote-tracking branch 'upstream/master' into feat-ffmpeg-7
skrashevich 88ba7fe
feat(ffmpeg): allow manual FFmpeg version specification in config
skrashevich a399afb
feat(ffmpeg): allow manual FFmpeg version specification in config
skrashevich 616f12c
Merge remote-tracking branch 'upstream/master' into feat-ffmpeg-7
skrashevich a5d2dce
Merge branch 'AlexxIT:master' into feat-ffmpeg-7
skrashevich 9dba8db
Merge branch 'AlexxIT:master' into feat-ffmpeg-7
skrashevich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package core | ||
|
||
import ( | ||
"math" | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func TestMaxCPUThreads(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
want int | ||
}{ | ||
{ | ||
name: "ExpectPositive", | ||
want: int(math.Round(math.Abs(float64(runtime.NumCPU())))) - 1, | ||
}, | ||
{ | ||
name: "CompareWithGOMAXPROCS", | ||
want: runtime.GOMAXPROCS(0) - 1, // This may not always equal NumCPU() if GOMAXPROCS has been set to a specific value. | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := MaxCPUThreads(1); got != tt.want { | ||
t.Errorf("NumCPU() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestCompareVersions(t *testing.T) { | ||
type args struct { | ||
v1 string | ||
v2 string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want int | ||
}{ | ||
{ | ||
name: "equal versions", | ||
args: args{v1: "1.0.0", v2: "1.0.0"}, | ||
want: 0, | ||
}, | ||
{ | ||
name: "v1 greater than v2", | ||
args: args{v1: "1.0.1", v2: "1.0.0"}, | ||
want: 1, | ||
}, | ||
{ | ||
name: "v1 less than v2", | ||
args: args{v1: "1.0.0", v2: "1.0.1"}, | ||
want: -1, | ||
}, | ||
{ | ||
name: "v1 greater with pre-release", | ||
args: args{v1: "1.0.1-alpha", v2: "1.0.1-beta"}, | ||
want: -1, | ||
}, | ||
{ | ||
name: "v1 less with different major", | ||
args: args{v1: "1.2.3", v2: "2.1.1"}, | ||
want: -1, | ||
}, | ||
{ | ||
name: "v1 greater with different minor", | ||
args: args{v1: "1.3.0", v2: "1.2.9"}, | ||
want: 1, | ||
}, | ||
{ | ||
name: "btbn-ffmpeg ebobo version format", | ||
args: args{v1: "n7.0-7-gd38bf5e08e-20240411", v2: "6.1.1"}, | ||
want: 1, | ||
}, | ||
{ | ||
name: "btbn-ffmpeg ebobo version format 2", | ||
args: args{v1: "n7.0-7-gd38bf5e08e-20240411", v2: "7.1"}, | ||
want: -1, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := CompareVersions(tt.args.v1, tt.args.v2); got != tt.want { | ||
t.Errorf("CompareVersions() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package ffmpeg | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestArgs_GetFFmpegVersion(t *testing.T) { | ||
type fields struct { | ||
Bin string | ||
Global string | ||
Input string | ||
Codecs []string | ||
Filters []string | ||
Output string | ||
Video int | ||
Audio int | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Default FFmpeg Path", | ||
fields: fields{ | ||
Bin: "ffmpeg", | ||
}, | ||
want: "*", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Invalid FFmpeg Path", | ||
fields: fields{ | ||
Bin: "/invalid/path/to/ffmpeg", | ||
}, | ||
want: "", | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
a := &Args{ | ||
Bin: tt.fields.Bin, | ||
Global: tt.fields.Global, | ||
Input: tt.fields.Input, | ||
Codecs: tt.fields.Codecs, | ||
Filters: tt.fields.Filters, | ||
Output: tt.fields.Output, | ||
Video: tt.fields.Video, | ||
Audio: tt.fields.Audio, | ||
} | ||
got, err := a.GetFFmpegVersion() | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("Args.GetFFmpegVersion() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want && tt.want != "*" { | ||
t.Errorf("Args.GetFFmpegVersion() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩼