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
9bf64d06
There was a problem fetching the latest pipeline status.
Commit
9bf64d06
authored
2 years ago
by
Anduin Xue
Browse files
Options
Downloads
Patches
Plain Diff
Support dry run. Release 1.0.0.
parent
e833c274
No related branches found
No related tags found
No related merge requests found
Pipeline
#908
failed
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Parser.FFmpeg/FFmpegEntry.cs
+31
-10
31 additions, 10 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
src/Parser/Parser.csproj
+1
-1
1 addition, 1 deletion
src/Parser/Parser.csproj
with
32 additions
and
11 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
+
31
−
10
View file @
9bf64d06
...
@@ -35,11 +35,11 @@ namespace Anduin.Parser.FFmpeg
...
@@ -35,11 +35,11 @@ namespace Anduin.Parser.FFmpeg
foreach
(
var
file
in
videos
)
foreach
(
var
file
in
videos
)
{
{
_logger
.
LogTrace
(
"Parsing video file: "
+
file
);
_logger
.
LogTrace
(
"Parsing video file: "
+
file
);
await
this
.
ProcessVideoAsync
(
file
);
await
this
.
ProcessVideoAsync
(
file
,
shouldTakeAction
);
}
}
}
}
private
async
Task
ProcessVideoAsync
(
string
filePath
)
private
async
Task
ProcessVideoAsync
(
string
filePath
,
bool
shouldTakeAction
)
{
{
var
folder
=
Path
.
GetDirectoryName
(
filePath
)
??
throw
new
Exception
(
$"
{
filePath
}
is invalid!"
);
var
folder
=
Path
.
GetDirectoryName
(
filePath
)
??
throw
new
Exception
(
$"
{
filePath
}
is invalid!"
);
var
baseFileInfo
=
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
filePath
}
"""
,
folder
);
var
baseFileInfo
=
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
filePath
}
"""
,
folder
);
...
@@ -48,18 +48,38 @@ namespace Anduin.Parser.FFmpeg
...
@@ -48,18 +48,38 @@ namespace Anduin.Parser.FFmpeg
if
(
ShouldParseVideo
(
baseFileInfo
,
fileInfo
))
if
(
ShouldParseVideo
(
baseFileInfo
,
fileInfo
))
{
{
var
newFileName
=
GetNewFileName
(
fileInfo
);
var
newFileName
=
GetNewFileName
(
fileInfo
);
await
ParseVideoAsync
(
filePath
,
newFileName
,
folder
,
gpu
:
_options
.
UseGpu
,
crf
:
_options
.
Crf
);
}
_logger
.
LogInformation
(
$"
{
filePath
}
should parsed..."
);
else
if
(
shouldTakeAction
)
{
{
_logger
.
LogInformation
(
$"
{
filePath
}
don't have to be parsed..."
);
await
ParseVideoAsync
(
filePath
,
newFileName
,
folder
,
gpu
:
_options
.
UseGpu
,
crf
:
_options
.
Crf
);
}
else
{
_logger
.
LogInformation
(
$"
{
filePath
}
Runniung in dry run mode. Skip parsing..."
);
}
}
}
}
}
private
bool
ShouldParseVideo
(
string
baseFileInfo
,
FileInfo
fileInfo
)
private
bool
ShouldParseVideo
(
string
baseFileInfo
,
FileInfo
fileInfo
)
{
{
return
fileInfo
.
Length
>
20
*
MbToBytes
&&
var
largeEnough
=
fileInfo
.
Length
>
20
*
MbToBytes
;
(!
baseFileInfo
.
Contains
(
"Video: hevc"
)
||
!
fileInfo
.
Name
.
EndsWith
(
".mp4"
)
||
baseFileInfo
.
Contains
(
"creation_time"
));
var
isNotHevc
=
!
baseFileInfo
.
Contains
(
"Video: hevc"
);
var
isNotmp4
=
!
fileInfo
.
Name
.
EndsWith
(
".mp4"
);
var
containsPrivacyInfo
=
baseFileInfo
.
Contains
(
"creation_time"
);
if
(!
largeEnough
)
_logger
.
LogInformation
(
$"Don't have to parse
{
fileInfo
.
FullName
}
because it's too small:
{
fileInfo
.
Length
/
MbToBytes
}
MB. Minimum size is 20MB."
);
else
if
(
isNotHevc
)
_logger
.
LogInformation
(
$"Parse
{
fileInfo
.
FullName
}
because it is not HEVC!"
);
else
if
(
isNotmp4
)
_logger
.
LogInformation
(
$"Parse
{
fileInfo
.
FullName
}
because it is not mp4!"
);
else
if
(
containsPrivacyInfo
)
_logger
.
LogInformation
(
$"Parse
{
fileInfo
.
FullName
}
because it contains privacy info!"
);
else
_logger
.
LogInformation
(
$"
{
fileInfo
.
FullName
}
don't have to be parsed..."
);
return
largeEnough
&&
(
isNotHevc
||
isNotmp4
||
containsPrivacyInfo
);
}
}
private
string
GetNewFileName
(
FileInfo
fileInfo
)
private
string
GetNewFileName
(
FileInfo
fileInfo
)
...
@@ -80,7 +100,8 @@ namespace Anduin.Parser.FFmpeg
...
@@ -80,7 +100,8 @@ namespace Anduin.Parser.FFmpeg
if
(
gpu
)
if
(
gpu
)
{
{
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
);
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
}
else
{
{
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
sourceFilePath
}
"" -preset slow -codec:a copy -codec:v libx265 -crf
{
crf
}
""
{
targetFilePath
}
"""
,
folder
,
getOutput
:
false
);
await
_commandService
.
RunCommandAsync
(
"ffmpeg"
,
$@"-i ""
{
sourceFilePath
}
"" -preset slow -codec:a copy -codec:v libx265 -crf
{
crf
}
""
{
targetFilePath
}
"""
,
folder
,
getOutput
:
false
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Parser/Parser.csproj
+
1
−
1
View file @
9bf64d06
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<PropertyGroup>
<PropertyGroup>
<!--Build and code-->
<!--Build and code-->
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
<Version>0.0
.5
</Version>
<Version>
1.
0.0</Version>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>parser</AssemblyName>
<AssemblyName>parser</AssemblyName>
<RootNamespace>Anduin.Parser</RootNamespace>
<RootNamespace>Anduin.Parser</RootNamespace>
...
...
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