Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Parser
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anduin Xue
Parser
Commits
b7d4fd0a
There was an error fetching the commit references. Please try again later.
Commit
b7d4fd0a
authored
2 years ago
by
Anduin Xue
Browse files
Options
Downloads
Patches
Plain Diff
Support GPU.
parent
71ec7b7b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Parser.FFmpeg/FFmpegEntry.cs
+11
-4
11 additions, 4 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
with
11 additions
and
4 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
+
11
−
4
View file @
b7d4fd0a
...
@@ -48,7 +48,7 @@ namespace Aiursoft.Parser.FFmpeg
...
@@ -48,7 +48,7 @@ namespace Aiursoft.Parser.FFmpeg
if
(
ShouldParseVideo
(
baseFileInfo
,
fileInfo
))
if
(
ShouldParseVideo
(
baseFileInfo
,
fileInfo
))
{
{
var
newFileName
=
GetNewFileName
(
fileInfo
);
var
newFileName
=
GetNewFileName
(
fileInfo
);
await
ParseVideoAsync
(
filePath
,
newFileName
,
folder
,
coder
:
_options
.
UseGpu
?
"hevc_nvenc"
:
"libx265"
,
crf
:
_options
.
Crf
);
await
ParseVideoAsync
(
filePath
,
newFileName
,
folder
,
gpu
:
_options
.
UseGpu
,
crf
:
_options
.
Crf
);
}
}
else
else
{
{
...
@@ -68,16 +68,23 @@ namespace Aiursoft.Parser.FFmpeg
...
@@ -68,16 +68,23 @@ namespace Aiursoft.Parser.FFmpeg
return
$"
{
fileInfo
.
Directory
}{
Path
.
DirectorySeparatorChar
}{
bareName
}
_265.mp4"
;
return
$"
{
fileInfo
.
Directory
}{
Path
.
DirectorySeparatorChar
}{
bareName
}
_265.mp4"
;
}
}
private
async
Task
ParseVideoAsync
(
string
sourceFilePath
,
string
targetFilePath
,
string
folder
,
string
coder
,
int
crf
)
private
async
Task
ParseVideoAsync
(
string
sourceFilePath
,
string
targetFilePath
,
string
folder
,
bool
gpu
,
int
crf
)
{
{
_logger
.
LogWarning
(
$"
{
sourceFilePath
}
WILL be parsed
, with codec:
{
coder
}
,
crf is
{
crf
}
"
);
_logger
.
LogWarning
(
$"
{
sourceFilePath
}
WILL be parsed
!
crf is
{
crf
}
"
);
if
(
File
.
Exists
(
targetFilePath
))
if
(
File
.
Exists
(
targetFilePath
))
{
{
File
.
Delete
(
targetFilePath
);
File
.
Delete
(
targetFilePath
);
}
}
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
sourceFilePath
}
"" -preset slower -codec:a copy -codec:v
{
coder
}
-crf
{
crf
}
""
{
targetFilePath
}
"""
,
folder
,
getOutput
:
false
);
if
(
gpu
)
{
//sudo ffmpeg -i ./PXL_20230421_165446519.mp4 -c:v hevc_nvenc -rc:v vbr -cq:v 30 -c:a copy -preset slow -rc-lookahead 10 -profile:v main10 ./output.mp4
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
sourceFilePath
}
"" -preset slow -codec:a copy -codec:v hevc_nvenc -rc:v vbr -cq:v
{
crf
}
-rc-lookahead 10 -profile:v main10 ""
{
targetFilePath
}
"""
,
folder
,
getOutput
:
false
);
}
else
{
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
sourceFilePath
}
"" -preset slow -codec:a copy -codec:v libx265 -crf
{
crf
}
""
{
targetFilePath
}
"""
,
folder
,
getOutput
:
false
);
}
var
targetFileInfo
=
new
FileInfo
(
targetFilePath
);
var
targetFileInfo
=
new
FileInfo
(
targetFilePath
);
if
(
targetFileInfo
.
Exists
&&
targetFileInfo
.
Length
>
8
*
MbToBytes
)
if
(
targetFileInfo
.
Exists
&&
targetFileInfo
.
Length
>
8
*
MbToBytes
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment