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
bfaa98a4
There was an error fetching the commit references. Please try again later.
Commit
bfaa98a4
authored
2 years ago
by
Anduin Xue
Browse files
Options
Downloads
Patches
Plain Diff
Add logging.
parent
23b2014f
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
+8
-2
8 additions, 2 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
with
8 additions
and
2 deletions
src/Parser.FFmpeg/FFmpegEntry.cs
+
8
−
2
View file @
bfaa98a4
using
Aiursoft.Parser.Core
;
using
Aiursoft.Parser.Core
;
using
Aiursoft.Parser.FFmpeg.Services
;
using
Aiursoft.Parser.FFmpeg.Services
;
using
Microsoft.Extensions.Logging
;
namespace
Aiursoft.Parser.FFmpeg
namespace
Aiursoft.Parser.FFmpeg
{
{
public
class
FFmpegEntry
:
IEntryService
public
class
FFmpegEntry
:
IEntryService
{
{
private
readonly
ILogger
<
FFmpegEntry
>
_logger
;
private
readonly
FFmpegOptions
_options
;
private
readonly
FFmpegOptions
_options
;
private
readonly
CommandService
_commandService
;
private
readonly
CommandService
_commandService
;
public
FFmpegEntry
(
public
FFmpegEntry
(
ILogger
<
FFmpegEntry
>
logger
,
FFmpegOptions
options
,
FFmpegOptions
options
,
CommandService
commandService
)
CommandService
commandService
)
{
{
_logger
=
logger
;
_options
=
options
;
_options
=
options
;
_commandService
=
commandService
;
_commandService
=
commandService
;
}
}
public
async
Task
OnServiceStartedAsync
(
string
path
,
bool
shouldTakeAction
)
public
async
Task
OnServiceStartedAsync
(
string
path
,
bool
shouldTakeAction
)
{
{
_logger
.
LogTrace
(
"Enumerating files under path: "
+
path
);
var
videos
=
Directory
.
EnumerateFiles
(
path
,
"*.*"
,
SearchOption
.
AllDirectories
)
var
videos
=
Directory
.
EnumerateFiles
(
path
,
"*.*"
,
SearchOption
.
AllDirectories
)
.
Where
(
v
=>
.
Where
(
v
=>
v
.
EndsWith
(
".webm"
)
||
v
.
EndsWith
(
".webm"
)
||
...
@@ -28,6 +33,7 @@ namespace Aiursoft.Parser.FFmpeg
...
@@ -28,6 +33,7 @@ namespace Aiursoft.Parser.FFmpeg
foreach
(
var
file
in
videos
)
foreach
(
var
file
in
videos
)
{
{
_logger
.
LogTrace
(
"Parsing video file: "
+
file
);
await
Parse
(
file
,
coder
:
_options
.
UseGPU
?
"hevc_nvenc"
:
"libx265"
);
await
Parse
(
file
,
coder
:
_options
.
UseGPU
?
"hevc_nvenc"
:
"libx265"
);
}
}
}
}
...
@@ -46,7 +52,7 @@ namespace Aiursoft.Parser.FFmpeg
...
@@ -46,7 +52,7 @@ namespace Aiursoft.Parser.FFmpeg
var
newFileName
=
$"
{
fileInfo
.
Directory
}{
Path
.
DirectorySeparatorChar
}{
bareName
}
_265.mp4"
;
var
newFileName
=
$"
{
fileInfo
.
Directory
}{
Path
.
DirectorySeparatorChar
}{
bareName
}
_265.mp4"
;
if
(
shouldParse
)
if
(
shouldParse
)
{
{
Console
.
WriteL
in
e
(
$"
{
filePath
}
WILL be parsed
!
"
);
_logger
.
LogWarn
in
g
(
$"
{
filePath
}
WILL be parsed
, with codec:
{
coder
}
, crf is
{
_options
.
CRF
}
"
);
File
.
Delete
(
newFileName
);
File
.
Delete
(
newFileName
);
await
_commandService
.
RunCommand
(
"ffmpeg"
,
$@"-i ""
{
filePath
}
"" -codec:a copy -codec:v
{
coder
}
-crf
{
_options
.
CRF
}
""
{
newFileName
}
"""
,
folder
,
getOutput
:
false
);
await
_commandService
.
RunCommand
(
"ffmpeg"
,
$@"-i ""
{
filePath
}
"" -codec:a copy -codec:v
{
coder
}
-crf
{
_options
.
CRF
}
""
{
newFileName
}
"""
,
folder
,
getOutput
:
false
);
...
@@ -63,7 +69,7 @@ namespace Aiursoft.Parser.FFmpeg
...
@@ -63,7 +69,7 @@ namespace Aiursoft.Parser.FFmpeg
}
}
else
else
{
{
Console
.
WriteLine
(
$"
{
filePath
}
don't have to be parsed..."
);
_logger
.
LogInformation
(
$"
{
filePath
}
don't have to be parsed..."
);
}
}
}
}
}
}
...
...
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