メインコンテンツへスキップ

動画の分散エンコードクラスタを自作・運用している話・45

    目次

    ノードの処理速度 

    ところで、ノードがどれくらいのスピードで処理をしたのか、知りたいと思いませんか?私は知りたいです。

    今回はこれを実装してみましょう。

    if (recieve_data[JOB_DATA.PROGRESS] == JOB_PROGRESS.FINISH)
    {
        // ノードの処理が完了
        var speed = remote.Job.FrameLength / passed_time;
        remote.Job.EndTime = now_time;
        remote.Job.finish = true;
        remote.Job = null;
        remote.State = REMOTE_STATE.NULL;
    
        task_status = $"{remote.Name} : {dst_file_name} Compelete. {passed_time:0.0}s {speed:0.0}fps";
    }
    public class JOB
    {
        public string Arg;
        public string DstPath;
        public bool finish;
        public int FrameLength;
        public DateTime StartTime;
        public DateTime EndTime;
    
        public JOB(string arg, string dst, int frame_length)
        {
            Arg = arg;
            DstPath = dst;
            FrameLength = frame_length;
            finish = false;
        }
    }
    public void CreateJobList(uint initial_split_num, uint min_frame_size)
    {
    
     ~省略~
    
        for (int i = 0; i < split_num; i++)
        {
            var start_frame = this.TotalFrame * i / split_num;
            var end_frame = this.TotalFrame * (i + 1) / split_num;
            var frame_length = end_frame - start_frame;
            var dst_path = $@"{this.TmpPath}\tmp_{i}.mp4";
    
     ~省略~
    
            this.JobList.Add(new JOB(data_string, dst_path, (int)frame_length));
        }
    }

    ジョブの完了時に、そのジョブを処理したスピードが「fps」(1秒当たりに処理したフレーム数)で表示されます。併せて、JOBクラスの初期化のタイミングで、自身のジョブの重さ(フレーム数)を保持するように変更しています。

    なんだか仕事をしてる感じが増してきますね。 

     
     
    私は自宅で動画エンコードクラスタを運用している日曜プログラマです。13年以上にわたる運用での気付きや自作クラスタへのフィードバックをまとめていきたいと思います。

    あなたへのおすすめ