Esempio n. 1
0
    def test_packager_process_command_should_return_fairplay_encryption_args_for_hls(
            self):
        config = self.output_settings
        config.update({
            "format": "hls",
            "encryption": {
                "content_id": "abcd",
                "key": "wfwefwe",
                "iv": "fedcba",
                "uri": "https://google.com"
            },
        })
        packager = ShakaPackager(config, "tests/nodes/data/")
        expected_args = [
            "packager",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=video,init_segment=tests/nodes/data//video_360p_init.mp4,segment_template=tests/nodes/data//video_360p_$Number$.mp4",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=audio,init_segment=tests/nodes/data//audio_init.mp4,segment_template=tests/nodes/data//audio_$Number$.mp4",
            "--segment_duration",
            "10",
            "--hls_playlist_type",
            "VOD",
            "--hls_master_playlist_output",
            "tests/nodes/data/video.m3u8",
            "--enable_raw_key_encryption",
            "--keys",
            "label=:key_id=fedcba:key=wfwefwe:iv=fedcba",
            "--protection_scheme",
            "cbcs",
            "--protection_systems",
            "Fairplay",
            "--hls_key_uri",
            "https://google.com",
        ]

        self.assertEqual(expected_args, packager.get_process_command())
Esempio n. 2
0
    def test_both_mpd_and_m3u8_should_be_generated_for_adaptive_format(self):
        packager = ShakaPackager(self.output_settings, "tests/nodes/data/")
        packager.start()
        packager._process.wait()

        self.assertTrue(os.path.isfile("tests/nodes/data/audio_init.mp4"))
        self.assertTrue(os.path.isfile("tests/nodes/data/video_360p_init.mp4"))
        self.assertTrue(os.path.isfile("tests/nodes/data/video.m3u8"))
        self.assertTrue(os.path.isfile("tests/nodes/data/video.mpd"))
Esempio n. 3
0
    def test_mpd_should_be_generated_for_hls_format(self):
        config = self.output_settings
        config["format"] = "dash"
        packager = ShakaPackager(config, "tests/nodes/data/")
        packager.start()
        packager._process.wait()

        self.assertTrue(os.path.isfile("tests/nodes/data/audio_init.mp4"))
        self.assertTrue(os.path.isfile("tests/nodes/data/video_360p_init.mp4"))
        self.assertTrue(os.path.isfile("tests/nodes/data/video.mpd"))
Esempio n. 4
0
    def add_packagers(self, ffmpeg_output_pipe):
        local_path = "{}/{}/{}".format(settings.TRANSCODED_VIDEOS_PATH,
                                       self.config.get("id"),
                                       self.config.get("output").get("name"))
        one_to_many_pipe_writer = OneToManyPipeWriter(
            input_pipe=ffmpeg_output_pipe)

        if self.config.get("format") in [
                JobTemplate.BOTH_HLS_AND_DASH, JobTemplate.HLS
        ]:
            hls_config = self.prepare_hls_config(self.config)
            one_to_many_pipe_writer.register_output_pipe(
                hls_config["output"]["pipe"])
            hls_output_path = local_path + settings.HLS_OUTPUT_PATH_PREFIX
            self._executors.append(ShakaPackager(hls_config, hls_output_path))
            self._executors.append(
                CloudUploader(
                    hls_output_path,
                    self.config.get("output")["url"] +
                    settings.HLS_OUTPUT_PATH_PREFIX))

        if self.config.get("format") in [
                JobTemplate.BOTH_HLS_AND_DASH, JobTemplate.DASH
        ]:
            dash_config = self.prepare_dash_config(self.config)
            dash_output_path = local_path + settings.DASH_OUTPUT_PATH_PREFIX
            one_to_many_pipe_writer.register_output_pipe(
                dash_config["output"]["pipe"])
            self._executors.append(ShakaPackager(dash_config,
                                                 dash_output_path))
            self._executors.append(
                CloudUploader(
                    dash_output_path,
                    self.config.get("output")["url"] +
                    settings.DASH_OUTPUT_PATH_PREFIX))

        one_to_many_pipe_writer.start()
Esempio n. 5
0
    def test_packager_command_should_return_command_to_package_output(self):
        config = self.output_settings
        config["format"] = "dash"
        packager = ShakaPackager(config, "tests/nodes/data/")
        expected_args = [
            "packager",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=video,init_segment=tests/nodes/data//video_360p_init.mp4,segment_template=tests/nodes/data//video_360p_$Number$.mp4",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=audio,init_segment=tests/nodes/data//audio_init.mp4,segment_template=tests/nodes/data//audio_$Number$.mp4",
            "--segment_duration",
            "10",
            "--mpd_output",
            "tests/nodes/data/video.mpd",
        ]

        self.assertEqual(expected_args, packager.get_process_command())
Esempio n. 6
0
    def test_packager_process_command_should_return_widevine_encryption_args_for_dash(
            self):
        config = self.output_settings
        config.update({
            "format": "dash",
            "encryption": {
                "content_id": "abcd",
                "signer": "lumberjack",
                "aes_signing_key": "abcdef",
                "aes_signing_iv": "fedcba",
                "key_server_url": "https://google.com",
            },
        })
        packager = ShakaPackager(config, "tests/nodes/data/")
        expected_args = [
            "packager",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=video,init_segment=tests/nodes/data//video_360p_init.mp4,segment_template=tests/nodes/data//video_360p_$Number$.mp4",
            "in=tests/ffmpeg/data/videoplayback.mp4,stream=audio,init_segment=tests/nodes/data//audio_init.mp4,segment_template=tests/nodes/data//audio_$Number$.mp4",
            "--segment_duration",
            "10",
            "--mpd_output",
            "tests/nodes/data/video.mpd",
            "--enable_widevine_encryption",
            "--key_server_url",
            "https://google.com",
            "--content_id",
            "abcd",
            "--signer",
            "lumberjack",
            "--aes_signing_key",
            "abcdef",
            "--aes_signing_iv",
            "fedcba",
        ]

        self.assertEqual(expected_args, packager.get_process_command())
Esempio n. 7
0
    def test_status_should_be_finished_on_completion(self):
        packager = ShakaPackager(self.output_settings, "tests/nodes/data/")
        packager.start()
        packager._process.wait()

        self.assertEqual(Status.Finished, packager.check_status())
Esempio n. 8
0
    def test_start_should_run_packager_in_a_thread(self):
        packager = ShakaPackager(self.output_settings, "tests/nodes/data/")
        packager.start()

        self.assertEqual(Status.Running, packager.check_status())