mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-20 04:39:30 -06:00
Fixed some issues with ffmpeg/move file
This commit is contained in:
Binary file not shown.
@@ -37,7 +37,16 @@ namespace FileFlows.BasicNodes.File
|
||||
else
|
||||
dest = Path.Combine(dest, new FileInfo(args.FileName).Name);
|
||||
|
||||
var destDir = new FileInfo(dest).DirectoryName;
|
||||
|
||||
var fiDest = new FileInfo(dest);
|
||||
var fiWorkingFile = new FileInfo(args.WorkingFile);
|
||||
if (fiDest.Extension != fiWorkingFile.Extension)
|
||||
{
|
||||
dest = dest.Replace(fiDest.Extension, fiWorkingFile.Extension);
|
||||
fiDest = new FileInfo(dest);
|
||||
}
|
||||
|
||||
var destDir = fiDest.DirectoryName;
|
||||
if (Directory.Exists(destDir) == false)
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
@@ -50,6 +59,7 @@ namespace FileFlows.BasicNodes.File
|
||||
{
|
||||
if (System.IO.File.Exists(dest))
|
||||
System.IO.File.Delete(dest);
|
||||
args.Logger.ILog($"Moving file: \"{args.WorkingFile}\" to \"{dest}\"");
|
||||
System.IO.File.Move(args.WorkingFile, dest, true);
|
||||
|
||||
if (DeleteOriginal && args.WorkingFile != args.FileName)
|
||||
@@ -68,7 +78,6 @@ namespace FileFlows.BasicNodes.File
|
||||
|
||||
while (task.IsCompleted == false)
|
||||
{
|
||||
|
||||
long currentSize = 0;
|
||||
var destFileInfo = new FileInfo(dest);
|
||||
if (destFileInfo.Exists)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -18,18 +18,22 @@ namespace FileFlows.VideoNodes
|
||||
|
||||
private FFMpegEncoder Encoder;
|
||||
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, string ffmpegParameters)
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, string ffmpegParameters, string extension = "mkv", string outputFile = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
extension = "mkv";
|
||||
|
||||
this.args = args;
|
||||
Encoder = new FFMpegEncoder(ffmpegExe, args.Logger);
|
||||
Encoder.AtTime += AtTimeEvent;
|
||||
|
||||
string output = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + ".mkv");
|
||||
args.Logger.DLog("New Temp file: " + output);
|
||||
if (string.IsNullOrEmpty(outputFile))
|
||||
outputFile = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + "." + extension);
|
||||
|
||||
bool success = Encoder.Encode(args.WorkingFile, output, ffmpegParameters);
|
||||
bool success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters);
|
||||
args.Logger.ILog("Encoding succesful: " + success);
|
||||
if (success)
|
||||
args.SetWorkingFile(output);
|
||||
args.SetWorkingFile(outputFile);
|
||||
Encoder.AtTime -= AtTimeEvent;
|
||||
Encoder = null;
|
||||
return success;
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace FileFlows.VideoNodes
|
||||
[TextArea(1)]
|
||||
public string CommandLine { get; set; }
|
||||
|
||||
[DefaultValue("mkv")]
|
||||
[Text(2)]
|
||||
public string Extension { get; set; }
|
||||
|
||||
public override string Icon => "far fa-file-video";
|
||||
|
||||
private NodeParameters args;
|
||||
@@ -34,8 +38,14 @@ namespace FileFlows.VideoNodes
|
||||
if (string.IsNullOrEmpty(ffmpegExe))
|
||||
return -1;
|
||||
|
||||
if (string.IsNullOrEmpty(Extension))
|
||||
Extension = "mkv";
|
||||
|
||||
string outputFile = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + "." + Extension);
|
||||
|
||||
string cmd = CommandLine.Replace("{WorkingFile}", "\"" + args.WorkingFile + "\"")
|
||||
.Replace("{TempDir}", "\"" + args.TempPath + Path.DirectorySeparatorChar + "\"");
|
||||
.Replace("{Output}", outputFile)
|
||||
.Replace("{output}", outputFile);
|
||||
|
||||
if (Encode(args, ffmpegExe, CommandLine) == false)
|
||||
return -1;
|
||||
|
||||
@@ -24,6 +24,10 @@ namespace FileFlows.VideoNodes
|
||||
[Text(4)]
|
||||
public string Language { get; set; }
|
||||
|
||||
[DefaultValue("mkv")]
|
||||
[Text(5)]
|
||||
public string Extension { get; set; }
|
||||
|
||||
public override string Icon => "far fa-file-video";
|
||||
|
||||
private NodeParameters args;
|
||||
@@ -122,7 +126,7 @@ namespace FileFlows.VideoNodes
|
||||
|
||||
string ffArgsLine = string.Join(" ", ffArgs);
|
||||
|
||||
if (Encode(args, ffmpegExe, ffArgsLine) == false)
|
||||
if (Encode(args, ffmpegExe, ffArgsLine, Extension) == false)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
|
||||
Binary file not shown.
@@ -17,6 +17,8 @@
|
||||
"VideoEncode":{
|
||||
"Description":"A generic video encoding node, this lets you customize how to encode a video file using ffmpeg.\n\nOutput 1: Video was processed\nOutput 2: No processing required",
|
||||
"Fields":{
|
||||
"Extension":"Extension",
|
||||
"Extension-Help":"The file extension to use on the newly created file",
|
||||
"VideoCodec":"Video Codec",
|
||||
"VideoCodec-Help":"The video codec the video should be in, for example hevc, h264",
|
||||
"VideoCodecParameters":"Video Codec Parameters",
|
||||
@@ -43,8 +45,10 @@
|
||||
"FFMPEG":{
|
||||
"Description":"The node lets you run any FFMPEG command you like. Giving you full control over what it can do.\n\nFor more information refer to the FFMPEG documentation",
|
||||
"Fields":{
|
||||
"Extension":"Extension",
|
||||
"Extension-Help":"The file extension to use on the newly created file",
|
||||
"CommandLine":"Command Line",
|
||||
"CommandLine-Help":"The command line to run with FFMPEG.\n'{WorkingFile}': the working file of the flow\n'{TempDir}': The temp directory, including trailing directory separator, where files are generally created during the flow."
|
||||
"CommandLine-Help":"The command line to run with FFMPEG.\n'{WorkingFile}': the working file of the flow\n'{Output}': The output file that will be passed as the last parameter to FFMPEG including the extension defined above."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ Remove-Item Builds -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
$revision = (git rev-list --count --first-parent HEAD) -join "`n"
|
||||
|
||||
|
||||
$json = "[`n"
|
||||
|
||||
Get-ChildItem -Path .\ -Filter *.csproj -Recurse -File -Name | ForEach-Object {
|
||||
@@ -21,7 +20,11 @@ Get-ChildItem -Path .\ -Filter *.csproj -Recurse -File -Name | ForEach-Object {
|
||||
$json += "`t},`n"
|
||||
|
||||
# build an instance for FileFlow local code
|
||||
# dotnet build $_ /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary --output:../FileFlows/Server/Plugins
|
||||
dotnet build $_ /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary --output:../FileFlows/Server/Plugins/$name/$version
|
||||
Remove-Item ../FileFlows/Server/Plugins/$name/$version/Plugin.dll -ErrorAction SilentlyContinue
|
||||
Remove-Item ../FileFlows/Server/Plugins/$name/$version/*.deps.json -ErrorAction SilentlyContinue
|
||||
Remove-Item ../FileFlows/Server/Plugins/$name/$version/ref -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
# build instance to be published to repo
|
||||
dotnet build $_ /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary --output:Builds/$name
|
||||
|
||||
@@ -37,7 +40,3 @@ $json = $json.Substring(0, $json.lastIndexOf(',')) + "`n"
|
||||
$json += ']';
|
||||
|
||||
Set-Content -Path 'plugins.json' -Value $json
|
||||
|
||||
Remove-Item ../FileFlows/Server/Plugins/Plugin.dll -ErrorAction SilentlyContinue
|
||||
Remove-Item ../FileFlows/Server/Plugins/*.deps.json -ErrorAction SilentlyContinue
|
||||
Remove-Item ../FileFlows/Server/Plugins/ref -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[
|
||||
{
|
||||
"Name": "BasicNodes",
|
||||
"Version": "0.0.1.2",
|
||||
"Version": "0.0.1.3",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true"
|
||||
},
|
||||
{
|
||||
"Name": "VideoNodes",
|
||||
"Version": "0.0.1.2",
|
||||
"Version": "0.0.1.3",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user