public void LoadFromTask(AudioOutputTask task) { if (task.AudioType == "mp3") { rbtMp3.Checked = true; } if (task.AudioType == "aac") { rbtAac.Checked = true; } if (task.AudioType == "ogg") { rbtOgg.Checked = true; } if (task.AudioType == "opus") { rbtOpus.Checked = true; } if (task.AudioType == "pcm") { rbtPcm.Checked = true; } nudBitrate.Value = task.Bitrate; edtExtraParam.Text = task.ExtraParam; edtChannelName.Text = task.ChannelName; edtVideoServerUrl.Text = task.ServerAddress; }
public AudioOutputTask(AudioOutputTask src) { AudioType = src.AudioType; Bitrate = src.Bitrate; ExtraParam = src.ExtraParam; ServerAddress = src.ServerAddress; ChannelName = src.ChannelName; }
public AudioOutputTask SaveToTask(AudioOutputTask audioOutputTask = null) { AudioOutputTask task = audioOutputTask; if (task == null) { task = m_Task; } if (rbtMp3.Checked) { task.AudioType = "mp3"; } if (rbtAac.Checked) { task.AudioType = "aac"; } if (rbtOgg.Checked) { task.AudioType = "ogg"; } if (rbtOpus.Checked) { task.AudioType = "opus"; } if (rbtPcm.Checked) { task.AudioType = "pcm"; } task.Bitrate = Convert.ToInt32(nudBitrate.Value); task.ExtraParam = edtExtraParam.Text; task.ChannelName = edtChannelName.Text; task.ServerAddress = edtVideoServerUrl.Text; return(task); }
public static string GenNormalAudioOutputPart(AudioOutputTask task) { string output = " -vn " + (task.Bitrate > 0 ? (" -b:a " + task.Bitrate + "k ") : ""); string serverUrl = task.ServerAddress.ToLower().Trim(); if (!serverUrl.Contains("http://")) { serverUrl = "http://" + serverUrl; } if (serverUrl.Last() == '/') { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } if (task.AudioType == "mp3") { output += " -acodec libmp3lame -reservoir 0 "; if (task.ExtraParam.Length > 0) { output += " " + task.ExtraParam + " "; } output += " -f mp3 "; output += serverUrl + "/" + task.ChannelName + "/" + task.AudioType; } else if (task.AudioType == "ogg") { output += " -acodec libvorbis "; if (task.ExtraParam.Length > 0) { output += " " + task.ExtraParam + " "; } output += " -f ogg "; output += serverUrl + "/" + task.ChannelName + "/" + task.AudioType; } else if (task.AudioType == "opus") { output += " -acodec libopus "; if (task.ExtraParam.Length > 0) { output += " " + task.ExtraParam + " "; } output += " -f opus "; output += serverUrl + "/" + task.ChannelName + "/" + task.AudioType; } else if (task.AudioType == "pcm") { output += " -acodec pcm_u8 -ac 1 "; if (task.ExtraParam.Length > 0) { output += " " + task.ExtraParam + " "; } string sampleRate = ""; if (task.ExtraParam.Contains("-ar ")) { var extraParamParts = task.ExtraParam.Split(' '); bool foundAR = false; foreach (var item in extraParamParts) { var currentPart = item.Trim(); if (currentPart.Length <= 0) { continue; } if (foundAR) { sampleRate = currentPart; } else { foundAR = currentPart == "-ar"; if (foundAR) { continue; } } if (sampleRate.Length > 0) { break; } } } output += " -f u8 "; output += serverUrl + "/" + task.ChannelName + "/" + task.AudioType + (sampleRate.Length > 0 ? ("/" + sampleRate) : ""); } else if (task.AudioType == "aac") { output += " -codec:a libfdk_aac "; if (task.ExtraParam.Length > 0) { output += " " + task.ExtraParam + " "; } output += " -f adts "; output += serverUrl + "/" + task.ChannelName + "/" + task.AudioType; } else { return(""); } return(output); }