Skip to content

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
Support 'Copy Audio' and 'qaac' for .avs input.
  • Loading branch information
inSight-mk1 committed Sep 29, 2017
1 parent ea7fd2e commit 8ed7a4d
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 26 deletions.
Binary file modified ExpertVideoToolbox.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion ExpertVideoToolbox/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.9")]
[assembly: AssemblyFileVersion("0.1.0.120")]
[assembly: AssemblyFileVersion("0.1.0.130")]
134 changes: 109 additions & 25 deletions ExpertVideoToolbox/cmdCodeGenerator/cmdCode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MediaInfoLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -30,6 +31,8 @@ class cmdCode
private string outputFolderPath;
private string outputAudioFormat;

private string avsVideoPath;

public cmdCode(string fp, taskSetting t, string ofp)
{
this.filePath = fp;
Expand All @@ -49,47 +52,127 @@ public int taskType()
return ONLYVIDEO;
} else if (String.Equals(this.ts.audioEncoder, "复制音频流"))
{
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.filePath);
duration = MI.Get(StreamKind.Audio, 0, 69);
this.outputAudioFormat = MI.Get(StreamKind.Audio, 0, "Format");
if (String.IsNullOrWhiteSpace(duration))
// 判断是否为avs文件

string ext = this.getFileExtName(this.filePath);
if (String.Equals(ext, "avs", StringComparison.CurrentCultureIgnoreCase))
{
return ONLYVIDEO;
} else
string[] avsLines = File.ReadAllLines(this.filePath);
for (int i = 0; i < avsLines.Length; i++)
{
int startIdx = avsLines[i].IndexOf("Source(\"");
int endIdx;
if (startIdx != -1)
{
endIdx = avsLines[i].IndexOf("\")");
startIdx += 8;
this.avsVideoPath = avsLines[i].Substring(startIdx, endIdx - startIdx);
break;
}
}
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.avsVideoPath);
duration = MI.Get(StreamKind.Audio, 0, 69);
this.outputAudioFormat = MI.Get(StreamKind.Audio, 0, "Format");
if (String.IsNullOrWhiteSpace(duration))
{
return ONLYVIDEO;
}
else
{
if (CheckBoxCompatibility(this.outputAudioFormat, this.ts.outputFormat))
{
return COPYAUDIO;
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
}
}
else
{
if (CheckBoxCompatibility(this.outputAudioFormat, this.ts.outputFormat))
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.filePath);
duration = MI.Get(StreamKind.Audio, 0, 69);
this.outputAudioFormat = MI.Get(StreamKind.Audio, 0, "Format");
if (String.IsNullOrWhiteSpace(duration))
{
return COPYAUDIO;
return ONLYVIDEO;
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
}
if (CheckBoxCompatibility(this.outputAudioFormat, this.ts.outputFormat))
{
return COPYAUDIO;
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
}
}
} else
{
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.filePath);
duration = MI.Get(StreamKind.Audio, 0, 69);
if (String.IsNullOrWhiteSpace(duration))
// 判断是否为avs文件

string ext = this.getFileExtName(this.filePath);
if (String.Equals(ext, "avs", StringComparison.CurrentCultureIgnoreCase))
{
return ONLYVIDEO;
string[] avsLines = File.ReadAllLines(this.filePath);
for (int i = 0; i < avsLines.Length; i++)
{
int startIdx = avsLines[i].IndexOf("Source(\"");
int endIdx;
if (startIdx != -1)
{
endIdx = avsLines[i].IndexOf("\")");
startIdx += 8;
this.avsVideoPath = avsLines[i].Substring(startIdx, endIdx - startIdx);
break;
}
}
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.avsVideoPath);
duration = MI.Get(StreamKind.Audio, 0, 69);
if (String.IsNullOrWhiteSpace(duration))
{
return ONLYVIDEO;
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
MediaInfo MI = new MediaInfo();
string duration;
MI.Open(this.filePath);
duration = MI.Get(StreamKind.Audio, 0, 69);
if (String.IsNullOrWhiteSpace(duration))
{
return ONLYVIDEO;
}
else
{
this.outputAudioFormat = "aac";
return SUPPRESSAUDIO;
}
}
}
}

public string cmdCodeGenerate(int mode, int vmode = 0)
{
string fp = this.filePath;
string audioSource = String.IsNullOrEmpty(this.avsVideoPath) ? fp : this.avsVideoPath;

string qaacPath = System.Windows.Forms.Application.StartupPath + "\\tools\\qaac\\qaac.exe";
string ffmpegPath = System.Windows.Forms.Application.StartupPath + "\\tools\\ffmpeg\\ffmpeg.exe";
Expand Down Expand Up @@ -138,7 +221,8 @@ public string cmdCodeGenerate(int mode, int vmode = 0)

break;
case AUDIOCOPY:
code = "\"" + ffmpegPath + "\"" + " -i " + "\"" + fp + "\"" + " -vn -sn -async 1 -c:a copy -y -map 0:a:0 " + "\"" + audioTempPath + "\"";
code = "\"" + ffmpegPath + "\"" + " -i " + "\"" + audioSource
+ "\"" + " -vn -sn -async 1 -c:a copy -y -map 0:a:0 " + "\"" + audioTempPath + "\"";
break;
case MUXER:
if (String.Equals(ts.outputFormat, "mp4", StringComparison.CurrentCultureIgnoreCase))
Expand Down Expand Up @@ -183,7 +267,7 @@ public string cmdCodeGenerate(int mode, int vmode = 0)
if (String.Equals(this.ts.audioEncoder, "qaac", StringComparison.CurrentCultureIgnoreCase)
|| String.Equals(this.ts.audioEncoder, "复制音频流", StringComparison.CurrentCultureIgnoreCase))
{
code = "\"" + ffmpegPath + "\"" + " -i " + "\"" + fp + "\"" + " -vn -sn -v 0 -async 1 -c:a pcm_s16le -f wav pipe:|" + "\"" + qaacPath + "\"" + " - --ignorelength";
code = "\"" + ffmpegPath + "\"" + " -i " + "\"" + audioSource + "\"" + " -vn -sn -v 0 -async 1 -c:a pcm_s16le -f wav pipe:|" + "\"" + qaacPath + "\"" + " - --ignorelength";
if (string.Equals(this.ts.audioProfile, "HE-AAC"))
{
code += " --he";
Expand Down

0 comments on commit 8ed7a4d

Please sign in to comment.