编码器 SDK 4 - 推送到发布点

发布于 2024-12-15 05:59:34 字数 2077 浏览 1 评论 0原文

我正在使用 EC4 SP2 SDK 用 C# 编写一个应用程序。

我想将我的文件发布到媒体服务器发布点。我搜索并找到了 2 个有关在发布点上进行设置和身份验证的示例,但要么来自较旧的 sdk,要么不起作用(并且适用于控制台)。基本上我的应用程序不编码任何内容,就好像它没有什么可编码的一样。 当处于调试模式 checkpont 时,我可以看到源文件和服务器的正确属性。

编码过程需要 0 秒来处理。我检查了服务器事件的日志,并收到警告“安全系统已收到无法解码的身份验证请求”。我只是不知道比这更进一步的分手。任何帮助将不胜感激。

这是一段代码:

 private void broadcastSourceFileToMediaServer2()
    {             
        using (LiveJob job = new LiveJob())
        {
            String filetoencode = @"c:\temp\niceday.wmv";

            LiveFileSource filesource = job.AddFileSource(filetoencode);
            filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
            job.ActivateSource(filesource);
            job.ApplyPreset(LivePresets.VC1Broadband4x3);

            //don't know which one is good to use 
            job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
            _myUserName = "indes";
            _pw = PullPW("indes");              

            Uri url = new Uri("http://192.168.1.74:8080/live");
            PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
            pubpoint.PublishingPoint = url;

            pubpoint.UserName = _myUserName;
            pubpoint.Password = _pw;

            job.PublishFormats.Add(pubpoint);       

            job.PreConnectPublishingPoint();

            job.StartEncoding();
            statusBox.Text = job.NumberOfEncodedSamples.ToString();

            job.StopEncoding();
            job.Dispose();
        }
  }




    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

 static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }

I'm coding an application in c# using EC4 SP2 SDK.

I want to publish my file to a media server publishing point. I've searched and found 2 examples regarding seting up and auth on publishing points, but either are from older sdk's or do not work (and are for console). basicly my application doesn't encode nothing, as if it had nothing to encode.
When in degub mode checkpont i can see the correct properties for the source file and for the server.

The encoding process takes 0secs to process. I checked the logs on the server events and i get a warning "the security system has received and auth request that could not be decoded". I just havo no knowledge to break up further than this. Any help would be appreciated.

this is the piece of code:

 private void broadcastSourceFileToMediaServer2()
    {             
        using (LiveJob job = new LiveJob())
        {
            String filetoencode = @"c:\temp\niceday.wmv";

            LiveFileSource filesource = job.AddFileSource(filetoencode);
            filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
            job.ActivateSource(filesource);
            job.ApplyPreset(LivePresets.VC1Broadband4x3);

            //don't know which one is good to use 
            job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
            _myUserName = "indes";
            _pw = PullPW("indes");              

            Uri url = new Uri("http://192.168.1.74:8080/live");
            PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
            pubpoint.PublishingPoint = url;

            pubpoint.UserName = _myUserName;
            pubpoint.Password = _pw;

            job.PublishFormats.Add(pubpoint);       

            job.PreConnectPublishingPoint();

            job.StartEncoding();
            statusBox.Text = job.NumberOfEncodedSamples.ToString();

            job.StopEncoding();
            job.Dispose();
        }
  }




    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

 static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

终难遇 2024-12-22 05:59:34

进展:

我设法在服务器上进行身份验证(至少获得积极的审核事件)。

我从这个更改

//don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

为:

        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = @"mediaservername\user";
        _pw = PullPW("user_password");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

如果您在一侧看到是否必须在用户名之前包含域(域或计算机名)。这改变了服务器上失败的审核事件,因此我可以消除手动凭据 pubpoint.username 和 pubpoint.Password。

现在我正在处理缺少输出格式异常。继续吧。

Progresses:

I managed to authenticate (at least get a positive audit event) on the server.

I changed from this:

//don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

To this:

        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = @"mediaservername\user";
        _pw = PullPW("user_password");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

If you see on one side if had to include the domain (either domain or computername) before username. this changed the failed audit events on the server, so i could eliminate the manual credentials pubpoint.username and pubpoint.Password.

Now I'm just dealing with a lack of output format exception. On to it.

君勿笑 2024-12-22 05:59:34

使用 SMOOTH Streaming 怎么样,我设法让我的项目继续进行,但除了看下面具有 PUBLISH 开关类型的部分之外,我没有得到更多。忽略文件部分

internal bool StartStream()
{
    Busy = true;
    // Instantiates a new job for encoding
    //  

    //***************************************Live Stream Archive******************************
    if (blnRecordFromFile)
    {

        // Sets up publishing format for file archival type
        FileArchivePublishFormat fileOut = new FileArchivePublishFormat();



        //  job.ApplyPreset(LivePresets.VC1512kDSL16x9);

        // Gets timestamp and edits it for filename
        string timeStamp = DateTime.Now.ToString();
        timeStamp = timeStamp.Replace("/", "-");
        timeStamp = timeStamp.Replace(":", ".");

        // Sets file path and name
        string path = "C:\\output\\";
        string filename = "Capture" + timeStamp + ".ismv";
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);

        fileOut.OutputFileName = Path.Combine(path, filename);

        // Adds the format to the job. You can add additional formats as well such as
        // Publishing streams or broadcasting from a port
        job.PublishFormats.Add(fileOut);

    }
    //******************************END OF Stream PORTION****************************************

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //*************************************** Process Files or Live Stream******************************
    if (blnRecordFromFile)
    {
        job.ApplyPreset(LivePresets.VC1IISSmoothStreaming720pWidescreen);

        job = new LiveJob();
        // Verifies all information is entered
        if (string.IsNullOrWhiteSpace(sourcePath) || string.IsNullOrWhiteSpace(destinationPath))
            return false;

        job.Status += new EventHandler<EncodeStatusEventArgs>(StreamStatus);

        LiveFileSource fileSource;
        try
        {
            // Sets file to active source and checks if it is valid
            fileSource = job.AddFileSource(sourcePath);
        }
        catch (InvalidMediaFileException)
        {
            return false;
        }

        // Sets to loop media for streaming
        //   fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;

        // Makes this file the active source. Multiple files can be added 
        // and cued to move to each other at their ends
        job.ActivateSource(fileSource);
    }
    //******************************END OF FILE PORTION****************************************


    // Sets up variable for fomat data
    switch (publishType)
    {
        case Output.Archive:
            // Verifies destination path exists and if not creates it
            try
        {
            if (!Directory.Exists(destinationPath))
                Directory.CreateDirectory(destinationPath);
        }
            catch (IOException)
            {
                return false;
            }

            FileArchivePublishFormat archiveFormat = new FileArchivePublishFormat();

            // Gets the location of the old extention and removes it
            string filename = Path.GetFileNameWithoutExtension(sourcePath);

            // Sets the archive path and file name
            archiveFormat.OutputFileName = Path.Combine(destinationPath, filename + ".ismv");
            job.PublishFormats.Add(archiveFormat);
        break;

        case Output.Publish:
            // Setups streaming of media to publishing point 
            job = new LiveJob();

            // Aquires audio and video devices
            Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
            EncoderDevice video = devices.Count > 0 ? devices[0] : null;
            for (int i = 0; i < devices.Count; ++i)
                //  devices[i].Dispose();
                devices.Clear();

            devices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
            EncoderDevice audio = devices.Count > 0 ? devices[0] : null;
            for (int i = 1; i < devices.Count; ++i)
                devices[i].Dispose();
            devices.Clear();

            // Checks for a/v devices
            if (video != null && audio != null)
            {


                //job.ApplyPreset(Preset.FromFile(@"C:\Tempura\LivePreset3.xml"));
                job.ApplyPreset(LivePresets.H264IISSmoothStreamingLowBandwidthStandard);
                job.OutputFormat.VideoProfile.SmoothStreaming = true;
                deviceSource = job.AddDeviceSource(video, audio);

                // Make this source the active one
                job.ActivateSource(deviceSource);
            }
            else
            {
                error = true;
            }

            PushBroadcastPublishFormat publishFormat = new PushBroadcastPublishFormat();
            try
        {
            // checks the path for a valid  publishing point
            publishFormat.PublishingPoint = new Uri(destinationPath);

        }
            catch (UriFormatException)
            {
                return false;
            }

            // Adds the publishing format to the job

            try
        {




            // job.ApplyPreset(LivePresets.VC1IISSmoothStreaming480pWidescreen);
            job.PublishFormats.Add(publishFormat);
            job.PreConnectPublishingPoint();
        }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

        break;
        default:
        return false;
    }
    job.StartEncoding();

    return true;
}

How about using SMOOTH Streaming, I managed to get my project going but I didn't get much more beyond Look below, to the part that has the PUBLISH switch type. ignore the file portion

internal bool StartStream()
{
    Busy = true;
    // Instantiates a new job for encoding
    //  

    //***************************************Live Stream Archive******************************
    if (blnRecordFromFile)
    {

        // Sets up publishing format for file archival type
        FileArchivePublishFormat fileOut = new FileArchivePublishFormat();



        //  job.ApplyPreset(LivePresets.VC1512kDSL16x9);

        // Gets timestamp and edits it for filename
        string timeStamp = DateTime.Now.ToString();
        timeStamp = timeStamp.Replace("/", "-");
        timeStamp = timeStamp.Replace(":", ".");

        // Sets file path and name
        string path = "C:\\output\\";
        string filename = "Capture" + timeStamp + ".ismv";
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);

        fileOut.OutputFileName = Path.Combine(path, filename);

        // Adds the format to the job. You can add additional formats as well such as
        // Publishing streams or broadcasting from a port
        job.PublishFormats.Add(fileOut);

    }
    //******************************END OF Stream PORTION****************************************

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //*************************************** Process Files or Live Stream******************************
    if (blnRecordFromFile)
    {
        job.ApplyPreset(LivePresets.VC1IISSmoothStreaming720pWidescreen);

        job = new LiveJob();
        // Verifies all information is entered
        if (string.IsNullOrWhiteSpace(sourcePath) || string.IsNullOrWhiteSpace(destinationPath))
            return false;

        job.Status += new EventHandler<EncodeStatusEventArgs>(StreamStatus);

        LiveFileSource fileSource;
        try
        {
            // Sets file to active source and checks if it is valid
            fileSource = job.AddFileSource(sourcePath);
        }
        catch (InvalidMediaFileException)
        {
            return false;
        }

        // Sets to loop media for streaming
        //   fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;

        // Makes this file the active source. Multiple files can be added 
        // and cued to move to each other at their ends
        job.ActivateSource(fileSource);
    }
    //******************************END OF FILE PORTION****************************************


    // Sets up variable for fomat data
    switch (publishType)
    {
        case Output.Archive:
            // Verifies destination path exists and if not creates it
            try
        {
            if (!Directory.Exists(destinationPath))
                Directory.CreateDirectory(destinationPath);
        }
            catch (IOException)
            {
                return false;
            }

            FileArchivePublishFormat archiveFormat = new FileArchivePublishFormat();

            // Gets the location of the old extention and removes it
            string filename = Path.GetFileNameWithoutExtension(sourcePath);

            // Sets the archive path and file name
            archiveFormat.OutputFileName = Path.Combine(destinationPath, filename + ".ismv");
            job.PublishFormats.Add(archiveFormat);
        break;

        case Output.Publish:
            // Setups streaming of media to publishing point 
            job = new LiveJob();

            // Aquires audio and video devices
            Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
            EncoderDevice video = devices.Count > 0 ? devices[0] : null;
            for (int i = 0; i < devices.Count; ++i)
                //  devices[i].Dispose();
                devices.Clear();

            devices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
            EncoderDevice audio = devices.Count > 0 ? devices[0] : null;
            for (int i = 1; i < devices.Count; ++i)
                devices[i].Dispose();
            devices.Clear();

            // Checks for a/v devices
            if (video != null && audio != null)
            {


                //job.ApplyPreset(Preset.FromFile(@"C:\Tempura\LivePreset3.xml"));
                job.ApplyPreset(LivePresets.H264IISSmoothStreamingLowBandwidthStandard);
                job.OutputFormat.VideoProfile.SmoothStreaming = true;
                deviceSource = job.AddDeviceSource(video, audio);

                // Make this source the active one
                job.ActivateSource(deviceSource);
            }
            else
            {
                error = true;
            }

            PushBroadcastPublishFormat publishFormat = new PushBroadcastPublishFormat();
            try
        {
            // checks the path for a valid  publishing point
            publishFormat.PublishingPoint = new Uri(destinationPath);

        }
            catch (UriFormatException)
            {
                return false;
            }

            // Adds the publishing format to the job

            try
        {




            // job.ApplyPreset(LivePresets.VC1IISSmoothStreaming480pWidescreen);
            job.PublishFormats.Add(publishFormat);
            job.PreConnectPublishingPoint();
        }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

        break;
        default:
        return false;
    }
    job.StartEncoding();

    return true;
}
酒几许 2024-12-22 05:59:34

遗憾的是,我没有足够的代表来发表评论,所以我必须将其写为答案。

由于您正在开始实时作业,为了进行流式传输,您不应在 StartEncoding 之后立即调用 job.StopEncoding() 。我想通常你会使用一个事件来停止编码。如果您开始编码并立即停止它,那么您没有输出或只有非常小的输出是合乎逻辑的。

Sadly I dont have enough rep to comment, so I have to write it as an answer.

Due to you are starting a live job, in order to stream you should not call job.StopEncoding() right after StartEncoding. I think usually you would use an event to stop the encoding. If you start encoding and immediately stop it, it is only logical you have no, or only a very small output.

谜兔 2024-12-22 05:59:34

我将您的代码更改为以下内容,看起来效果很好。我猜你的问题是你处置了 LiveJob 类的实例。在完成整个流的编码之前,您必须使实例保持活动状态。因此更改 using 部分并删除 StopEncoding 和 Dispose 就可以了。

    private void broadcastSourceFileToMediaServer2()
    {
        LiveJob job = new LiveJob();
        String filetoencode = @"c:\temp\niceday.wmv";

        LiveFileSource filesource = job.AddFileSource(filetoencode);
        filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
        job.ActivateSource(filesource);
        job.ApplyPreset(LivePresets.VC1Broadband4x3);

        //don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

        job.PublishFormats.Add(pubpoint);       

        job.PreConnectPublishingPoint();

        job.StartEncoding();
        statusBox.Text = job.NumberOfEncodedSamples.ToString();
    }

    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

    static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }

I changed your code to the following and it seems work well. I guess your problem is that you disposed the instance of LiveJob class. You have to keep the instance alive before it finished encoding the whole stream. So change the using part and remove the StopEncoding and Dispose will be OK.

    private void broadcastSourceFileToMediaServer2()
    {
        LiveJob job = new LiveJob();
        String filetoencode = @"c:\temp\niceday.wmv";

        LiveFileSource filesource = job.AddFileSource(filetoencode);
        filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
        job.ActivateSource(filesource);
        job.ApplyPreset(LivePresets.VC1Broadband4x3);

        //don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

        job.PublishFormats.Add(pubpoint);       

        job.PreConnectPublishingPoint();

        job.StartEncoding();
        statusBox.Text = job.NumberOfEncodedSamples.ToString();
    }

    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

    static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文