public VideoOutputTask SaveToTask(VideoOutputTask videoOutputTask = null)
        {
            VideoOutputTask task = videoOutputTask;

            if (task == null)
            {
                task = m_Task;
            }

            if (rbtMpeg1.Checked)
            {
                task.VideoType = "mpeg";
            }
            if (rbtH264.Checked)
            {
                task.VideoType = "h264";
            }
            if (cbbResolution.SelectedIndex >= 0)
            {
                task.Resolution = cbbResolution.Items[cbbResolution.SelectedIndex].ToString();
            }

            task.FPS           = Convert.ToInt32(nudFps.Value);
            task.Bitrate       = Convert.ToInt32(nudBitrate.Value);
            task.PixelFormat   = edtPixelFormat.Text;
            task.ExtraParam    = edtExtraParam.Text;
            task.ChannelName   = edtChannelName.Text;
            task.ServerAddress = edtVideoServerUrl.Text;

            return(task);
        }
        public void LoadFromTask(VideoOutputTask task)
        {
            if (task.VideoType == "mpeg")
            {
                rbtMpeg1.Checked = true;
            }
            if (task.VideoType == "h264")
            {
                rbtH264.Checked = true;
            }
            for (var i = 0; i < cbbResolution.Items.Count; i++)
            {
                if (cbbResolution.Items[i].ToString() == task.Resolution)
                {
                    cbbResolution.SelectedIndex = i;
                    break;
                }
            }
            nudFps.Value           = task.FPS;
            nudBitrate.Value       = task.Bitrate;
            edtPixelFormat.Text    = task.PixelFormat;
            edtExtraParam.Text     = task.ExtraParam;
            edtChannelName.Text    = task.ChannelName;
            edtVideoServerUrl.Text = task.ServerAddress;

            btnAttach.Visible = rbtMpeg1.Checked;
        }
Beispiel #3
0
        public static string GenVideoOutputPart(VideoOutputTask task)
        {
            string output = " -s " + task.Resolution
                            + (task.FPS > 0 ? (" -r " + task.FPS) : "")
                            + (task.Bitrate > 0 ? (" -b:v " + 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.VideoType == "mpeg")
            {
                output += " -codec:v mpeg1video -bf 0 ";
                if (task.ExtraParam.Length > 0)
                {
                    output += " " + task.ExtraParam + " ";
                }
                output += " -f mpegts ";
                output += serverUrl + "/" + task.ChannelName + "/" + task.VideoType + "/" + task.Resolution
                          + (task.FPS > 0 ? ("x" + task.FPS) : "")
                          + (task.Bitrate > 0 ? ("" + '@' + task.Bitrate + "kbps") : "")
                ;
            }
            else if (task.VideoType == "h264")
            {
                output += " -an -vcodec libx264 -tune zerolatency -pass 1 -coder 0 -bf 0 -flags -loop -wpredp 0 ";
                if (task.PixelFormat.Length > 0)
                {
                    output += " -pix_fmt " + task.PixelFormat;
                }
                if (task.ExtraParam.Length > 0)
                {
                    output += " " + task.ExtraParam + " ";
                }
                output += " -f h264 ";
                output += serverUrl + "/" + task.ChannelName + "/" + task.VideoType + "/" + task.Resolution
                          + (task.FPS > 0 ? ("x" + task.FPS) : "")
                          + (task.Bitrate > 0 ? ("" + '@' + task.Bitrate + "kbps") : "")
                ;
            }
            else
            {
                return("");
            }

            return(output);
        }
Beispiel #4
0
 public VideoOutputTask(VideoOutputTask src)
 {
     VideoType     = src.VideoType;
     Resolution    = src.Resolution;
     FPS           = src.FPS;
     Bitrate       = src.Bitrate;
     PixelFormat   = src.PixelFormat;
     ExtraParam    = src.ExtraParam;
     ServerAddress = src.ServerAddress;
     ChannelName   = src.ChannelName;
 }