Пример #1
0
        private void Parse()
        {
            // ISO IEC 13818 seite 58 (pdf)

            _Descs.Clear();
            _Streams.Clear();
            _PcrPid = 0;

            int len = SectionSize - 4; // 4 byte CRC am Ende abziehen.
            int i   = 8;               // start der Daten.

            _PcrPid |= SectionData[i++] << 8;
            _PcrPid |= SectionData[i++];
            _PcrPid &= 0x1fff;

            int piLen = 0;

            piLen |= SectionData[i++] << 8;
            piLen |= SectionData[i++];
            piLen &= 0x0fff;
            // Ende der Daten:
            piLen += i;

            while (i < piLen)
            {
                DescriptorBase desc = DescriptorFactory.CreateDescriptor(SectionData, i);
                _Descs.Add(desc);

                i += desc.Length;
            }

            while (i < len)
            {
                ElementaryStream es = new ElementaryStream(SectionData, i);
                _Streams.Add(es);

                i += es.Length;
            }
        }
Пример #2
0
    public Job CreateJobWithStaticOverlay(
        string projectId, string location, string inputUri, string overlayImageUri, string outputUri)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parent = new LocationName(projectId, location);

        // Build the job config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 550000,
                FrameRate    = 60,
                HeightPixels = 360,
                WidthPixels  = 640
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec      = "aac",
            BitrateBps = 64000
        };

        // Create the overlay image. Only JPEG is supported. Image resolution is based on output
        // video resolution. To respect the original image aspect ratio, set either x or y to 0.0.
        // This example stretches the overlay image the full width and half of the height of the
        // output video.
        Overlay.Types.Image overlayImage = new Overlay.Types.Image
        {
            Uri        = overlayImageUri,
            Alpha      = 1,
            Resolution = new Overlay.Types.NormalizedCoordinate
            {
                X = 1,
                Y = 0.5
            }
        };

        // Create the starting animation (when the overlay appears). Use the values x: 0 and y: 0 to
        // position the top-left corner of the overlay in the top-left corner of the output video.
        Overlay.Types.Animation animationStart = new Overlay.Types.Animation
        {
            AnimationStatic = new Overlay.Types.AnimationStatic
            {
                Xy = new Overlay.Types.NormalizedCoordinate
                {
                    X = 0,
                    Y = 0
                },
                StartTimeOffset = Duration.FromTimeSpan(TimeSpan.FromSeconds(0))
            }
        };


        // Create the ending animation (when the overlay disappears). In this example, the overlay
        // disappears at the 10-second mark in the output video.
        Overlay.Types.Animation animationEnd = new Overlay.Types.Animation
        {
            AnimationEnd = new Overlay.Types.AnimationEnd
            {
                StartTimeOffset = Duration.FromTimeSpan(TimeSpan.FromSeconds(10))
            }
        };

        // Create the overlay and add the image and animations to it.
        Overlay overlay = new Overlay
        {
            Image      = overlayImage,
            Animations = { animationStart, animationEnd }
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key         = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key         = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key               = "sd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        Input input = new Input
        {
            Key = "input0",
            Uri = inputUri
        };

        Output output = new Output
        {
            Uri = outputUri
        };

        JobConfig jobConfig = new JobConfig
        {
            Inputs            = { input },
            Output            = output,
            ElementaryStreams = { elementaryStream0, elementaryStream1 },
            MuxStreams        = { muxStream0 },
            Overlays          = { overlay }
        };

        // Build the job.
        Job newJob = new Job
        {
            InputUri  = inputUri,
            OutputUri = outputUri,
            Config    = jobConfig
        };

        // Call the API.
        Job job = client.CreateJob(parent, newJob);

        // Return the result.
        return(job);
    }
    public Job CreateJobWithSetNumberImagesSpritesheet(
        string projectId, string location, string inputUri, string outputUri)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parent = new LocationName(projectId, location);

        // Build the job config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps = 550000,
                FrameRate = 60,
                HeightPixels = 360,
                WidthPixels = 640
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec = "aac",
            BitrateBps = 64000
        };

        // Generates a 10x10 spritesheet of small images from the input video.
        // To preserve the source aspect ratio, you should set the
        // SpriteWidthPixels field or the SpriteHeightPixels field, but not
        // both (the API will automatically calculate the missing field). For
        // this sample, we don't care about the aspect ratio so we set both
        // fields.
        SpriteSheet smallSpriteSheet = new SpriteSheet
        {
            FilePrefix = SmallSpritesheetFilePrefix,
            SpriteHeightPixels = 32,
            SpriteWidthPixels = 64,
            ColumnCount = 10,
            RowCount = 10,
            TotalCount = 100
        };

        // Generates a 10x10 spritesheet of larger images from the input video.
        // input video. To preserve the source aspect ratio, you should set the
        // SpriteWidthPixels field or the SpriteHeightPixels field, but not
        // both (the API will automatically calculate the missing field). For
        // this sample, we don't care about the aspect ratio so we set both
        // fields.
        SpriteSheet largeSpriteSheet = new SpriteSheet
        {
            FilePrefix = LargeSpritesheetFilePrefix,
            SpriteHeightPixels = 72,
            SpriteWidthPixels = 128,
            ColumnCount = 10,
            RowCount = 10,
            TotalCount = 100
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key = "sd",
            Container = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        Input input = new Input
        {
            Key = "input0",
            Uri = inputUri
        };

        Output output = new Output
        {
            Uri = outputUri
        };

        JobConfig jobConfig = new JobConfig
        {
            Inputs = { input },
            Output = output,
            ElementaryStreams = { elementaryStream0, elementaryStream1 },
            MuxStreams = { muxStream0 },
            SpriteSheets = { smallSpriteSheet, largeSpriteSheet }
        };

        // Build the job.
        Job newJob = new Job();
        newJob.InputUri = inputUri;
        newJob.OutputUri = outputUri;
        newJob.Config = jobConfig;

        // Call the API.
        Job job = client.CreateJob(parent, newJob);

        // Return the result.
        return job;
    }
Пример #4
0
    public Job CreateJobWithAnimatedOverlay(
        string projectId, string location, string inputUri, string overlayImageUri, string outputUri)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parent = new LocationName(projectId, location);

        // Build the job config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 550000,
                FrameRate    = 60,
                HeightPixels = 360,
                WidthPixels  = 640
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec      = "aac",
            BitrateBps = 64000
        };

        // Create the overlay image. Only JPEG is supported. Image resolution is based on output
        // video resolution. This example uses the values x: 0 and y: 0 to maintain the original
        // resolution of the overlay image.
        Overlay.Types.Image overlayImage = new Overlay.Types.Image
        {
            Uri        = overlayImageUri,
            Alpha      = 1,
            Resolution = new Overlay.Types.NormalizedCoordinate
            {
                X = 0,
                Y = 0
            }
        };

        // Create the starting animation (when the overlay starts to fade in). Use the values x: 0.5
        // and y: 0.5 to position the top-left corner of the overlay in the center of the output
        // video.
        Overlay.Types.Animation animationFadeIn = new Overlay.Types.Animation
        {
            AnimationFade = new Overlay.Types.AnimationFade
            {
                FadeType = Overlay.Types.FadeType.FadeIn,
                Xy       = new Overlay.Types.NormalizedCoordinate
                {
                    X = 0.5,
                    Y = 0.5
                },
                StartTimeOffset = Duration.FromTimeSpan(TimeSpan.FromSeconds(5)),
                EndTimeOffset   = Duration.FromTimeSpan(TimeSpan.FromSeconds(10))
            }
        };

        // Create the ending animation (when the overlay starts to fade out). The overlay will start
        // to fade out at the 12-second mark in the output video.
        Overlay.Types.Animation animationFadeOut = new Overlay.Types.Animation
        {
            AnimationFade = new Overlay.Types.AnimationFade
            {
                FadeType = Overlay.Types.FadeType.FadeOut,
                Xy       = new Overlay.Types.NormalizedCoordinate
                {
                    X = 0.5,
                    Y = 0.5
                },
                StartTimeOffset = Duration.FromTimeSpan(TimeSpan.FromSeconds(12)),
                EndTimeOffset   = Duration.FromTimeSpan(TimeSpan.FromSeconds(15))
            }
        };

        // Create the overlay and add the image and animations to it.
        Overlay overlay = new Overlay
        {
            Image      = overlayImage,
            Animations = { animationFadeIn, animationFadeOut }
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key         = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key         = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key               = "sd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        Input input = new Input
        {
            Key = "input0",
            Uri = inputUri
        };

        Output output = new Output
        {
            Uri = outputUri
        };

        JobConfig jobConfig = new JobConfig
        {
            Inputs            = { input },
            Output            = output,
            ElementaryStreams = { elementaryStream0, elementaryStream1 },
            MuxStreams        = { muxStream0 },
            Overlays          = { overlay }
        };

        // Build the job.
        Job newJob = new Job
        {
            InputUri  = inputUri,
            OutputUri = outputUri,
            Config    = jobConfig
        };

        // Call the API.
        Job job = client.CreateJob(parent, newJob);

        // Return the result.
        return(job);
    }
    public JobTemplate CreateJobTemplate(
        string projectId, string location, string templateId)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parentLocation = new LocationName(projectId, location);

        // Build the job template config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 550000,
                FrameRate    = 60,
                HeightPixels = 360,
                WidthPixels  = 640
            }
        };

        VideoStream videoStream1 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 2500000,
                FrameRate    = 60,
                HeightPixels = 720,
                WidthPixels  = 1280
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec      = "aac",
            BitrateBps = 64000
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key         = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key         = "video_stream1",
            VideoStream = videoStream1
        };

        ElementaryStream elementaryStream2 = new ElementaryStream
        {
            Key         = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key               = "sd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        MuxStream muxStream1 = new MuxStream
        {
            Key               = "hd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream1", "audio_stream0" }
        };

        JobConfig jobConfig = new JobConfig
        {
            ElementaryStreams = { elementaryStream0, elementaryStream1, elementaryStream2 },
            MuxStreams        = { muxStream0, muxStream1 }
        };

        JobTemplate newJobTemplate = new JobTemplate
        {
            Config = jobConfig
        };

        // Call the API.
        JobTemplate jobTemplate = client.CreateJobTemplate(parentLocation, newJobTemplate, templateId);

        return(jobTemplate);
    }
Пример #6
0
    public Job CreateJobWithConcatenatedInputs(
        string projectId, string location, string inputUri1, TimeSpan startTimeInput1, TimeSpan endTimeInput1, string inputUri2, TimeSpan startTimeInput2, TimeSpan endTimeInput2, string outputUri)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parent = new LocationName(projectId, location);

        // Build the job config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 550000,
                FrameRate    = 60,
                HeightPixels = 360,
                WidthPixels  = 640
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec      = "aac",
            BitrateBps = 64000
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key         = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key         = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key               = "sd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        Input input1 = new Input
        {
            Key = "input1",
            Uri = inputUri1
        };

        Input input2 = new Input
        {
            Key = "input2",
            Uri = inputUri2
        };

        EditAtom atom1 = new EditAtom
        {
            Key             = "atom1",
            StartTimeOffset = Duration.FromTimeSpan(startTimeInput1),
            EndTimeOffset   = Duration.FromTimeSpan(endTimeInput1),
            Inputs          = { input1.Key }
        };

        EditAtom atom2 = new EditAtom
        {
            Key             = "atom2",
            StartTimeOffset = Duration.FromTimeSpan(startTimeInput2),
            EndTimeOffset   = Duration.FromTimeSpan(endTimeInput2),
            Inputs          = { input2.Key }
        };

        Output output = new Output
        {
            Uri = outputUri
        };

        JobConfig jobConfig = new JobConfig
        {
            Inputs            = { input1, input2 },
            EditList          = { atom1, atom2 },
            Output            = output,
            ElementaryStreams = { elementaryStream0, elementaryStream1 },
            MuxStreams        = { muxStream0 }
        };

        // Build the job.
        Job newJob = new Job
        {
            OutputUri = outputUri,
            Config    = jobConfig
        };

        // Call the API.
        Job job = client.CreateJob(parent, newJob);

        // Return the result.
        return(job);
    }
    public Job CreateJobFromAdHoc(
        string projectId, string location, string inputUri, string outputUri)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parent = new LocationName(projectId, location);

        // Build the job config.
        VideoStream videoStream0 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 550000,
                FrameRate    = 60,
                HeightPixels = 360,
                WidthPixels  = 640
            }
        };

        VideoStream videoStream1 = new VideoStream
        {
            H264 = new VideoStream.Types.H264CodecSettings
            {
                BitrateBps   = 2500000,
                FrameRate    = 60,
                HeightPixels = 720,
                WidthPixels  = 1280
            }
        };

        AudioStream audioStream0 = new AudioStream
        {
            Codec      = "aac",
            BitrateBps = 64000
        };

        ElementaryStream elementaryStream0 = new ElementaryStream
        {
            Key         = "video_stream0",
            VideoStream = videoStream0
        };

        ElementaryStream elementaryStream1 = new ElementaryStream
        {
            Key         = "video_stream1",
            VideoStream = videoStream1
        };

        ElementaryStream elementaryStream2 = new ElementaryStream
        {
            Key         = "audio_stream0",
            AudioStream = audioStream0
        };

        MuxStream muxStream0 = new MuxStream
        {
            Key               = "sd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream0", "audio_stream0" }
        };

        MuxStream muxStream1 = new MuxStream
        {
            Key               = "hd",
            Container         = "mp4",
            ElementaryStreams = { "video_stream1", "audio_stream0" }
        };

        Input input = new Input
        {
            Key = "input0",
            Uri = inputUri
        };

        Output output = new Output
        {
            Uri = outputUri
        };

        JobConfig jobConfig = new JobConfig
        {
            Inputs            = { input },
            Output            = output,
            ElementaryStreams = { elementaryStream0, elementaryStream1, elementaryStream2 },
            MuxStreams        = { muxStream0, muxStream1 }
        };

        // Build the job.
        Job newJob = new Job
        {
            Config    = jobConfig,
            InputUri  = inputUri,
            OutputUri = outputUri
        };

        // Call the API.
        Job job = client.CreateJob(parent, newJob);

        // Return the result.
        return(job);
    }