Encoder SDK 4 - толчок к точке публикации - PullRequest
2 голосов
/ 12 ноября 2011

Я кодирую приложение в c #, используя EC4 SP2 SDK.

Я хочу опубликовать свой файл в точке публикации медиасервера.Я искал и нашел 2 примера, касающихся установки и авторизации на точках публикации, но либо из старых sdk, либо не работают (и предназначены для консоли).в основном мое приложение не кодирует ничего, как будто ему нечего кодировать.В контрольном режиме degub я вижу правильные свойства для исходного файла и для сервера.

Процесс кодирования занимает 0secs для обработки.Я проверил журналы событий сервера и получаю предупреждение "система безопасности получила и запрос на авторизацию, который не может быть декодирован".Я просто не знаю, что делать дальше.Любая помощь будет оценена.

это кусок кода:

 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;
    }

Ответы [ 4 ]

2 голосов
/ 12 ноября 2011

Прогресс:

Мне удалось пройти проверку подлинности (по крайней мере, получить положительное событие аудита) на сервере.

Я изменил с этого:

//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.

Теперь я просто имею дело с отсутствием исключения выходного формата.На это.

1 голос
/ 07 марта 2012

Как насчет использования 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;
}
0 голосов
/ 11 сентября 2012

К сожалению, мне не хватает представителя, чтобы комментировать, поэтому я должен написать это как ответ.

Из-за того, что вы запускаете живую работу, для потоковой передачи не следует вызывать job.StopEncoding ()сразу после StartEncoding.Я думаю, что обычно вы используете событие, чтобы остановить кодирование.Если вы начинаете кодирование и сразу же его прекращаете, то логично, что у вас нет или только очень маленький вывод.

0 голосов
/ 23 февраля 2012

Я изменил ваш код на следующий, и, кажется, работает хорошо. Я полагаю, ваша проблема в том, что вы удалили экземпляр класса LiveJob. Вы должны сохранить экземпляр до того, как он закончит кодирование всего потока. Так что измените использующую часть и удалите 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;
    }
...