static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("MP4ToSmoothStream <asset-id>");
                return -1;
            }

            string accountName = Environment.GetEnvironmentVariable("ACCOUNT_NAME");
            string accountKey = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
            CloudMediaContext cloudMediaContext = new CloudMediaContext(accountName, accountKey);

            string assetId = args[0];
            IAsset asset = cloudMediaContext.FindAssetById(assetId);

            IJob job = cloudMediaContext.Jobs.Create(string.Format("Convert {0} to Smooth Stream", asset.Name));

            IMediaProcessor processor = cloudMediaContext.GetMediaProcessor("Windows Azure Media Encoder");

            ITask task = job.Tasks.AddNew("MP4 to Smooth Stream Conversion",
                processor,
                "H264 Smooth Streaming 720p", // Task Preset. Amend as required.
                Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.ProtectedConfiguration);

            task.InputAssets.Add(asset);

            task.OutputAssets.AddNew(string.Format("Smooth Stream for {0}", asset.Name),
                AssetCreationOptions.None);

            job.Submit();

            Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", job.Id, job.Name, job.State, job.RunningDuration, job.LastModified);

            return 0;
        }
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("MP4ToHLS <asset-id>");
                return -1;
            }

            string accountName = Environment.GetEnvironmentVariable("ACCOUNT_NAME");
            string accountKey = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
            CloudMediaContext cloudMediaContext = new CloudMediaContext(accountName, accountKey);

            string assetId = args[0];
            IAsset asset = cloudMediaContext.FindAssetById(assetId);

            IJob job = cloudMediaContext.Jobs.Create(string.Format("Convert {0} to HLS Asset", asset.Name));

            IMediaProcessor processor = cloudMediaContext.GetMediaProcessor("Windows Azure Media Encoder");

            ITask task = job.Tasks.AddNew("MP4 to HLS",
                processor,
                "H264 Adaptive Bitrate MP4 Set SD 16x9",
                Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.ProtectedConfiguration);

            task.InputAssets.Add(asset);

            task.OutputAssets.AddNew(string.Format("HLS for {0}", asset.Name),
                AssetCreationOptions.None);

            job.Submit();

            Console.WriteLine(job.Id);
            Console.WriteLine("Once job is complete, retrieve StreamingURL and append (format=m3u8-aapl)");
            return 0;
        }
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("DecryptAsset <asset-id>");
                return -1;
            }

            string accountName = Environment.GetEnvironmentVariable("ACCOUNT_NAME");
            string accountKey = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
            CloudMediaContext cloudMediaContext = new CloudMediaContext(accountName, accountKey);

            string assetId = args[0];
            IAsset asset = cloudMediaContext.FindAssetById(assetId);

            IJob job = cloudMediaContext.Jobs.Create(string.Format("Decrypt {0}", asset.Name));

            IMediaProcessor decryptProcessor = cloudMediaContext.GetMediaProcessor("Storage Decryption");

            ITask decryptTask = job.Tasks.AddNew(string.Format("Decrypt {0}", asset.Name),
                    decryptProcessor,string.Empty,
                    Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.None);

            decryptTask.InputAssets.Add(asset);

            decryptTask.OutputAssets.AddNew(string.Format("{0} decrypted", asset.Name),
                AssetCreationOptions.None);

            job.Submit();

            Console.WriteLine(job.Id);

            return 0;
        }
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("ToMP4 <asset-id>");
                return -1;
            }

            string accountName = Environment.GetEnvironmentVariable("ACCOUNT_NAME");
            string accountKey = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
            CloudMediaContext cloudMediaContext = new CloudMediaContext(accountName, accountKey);

            string assetId = args[0];
            IAsset asset = cloudMediaContext.FindAssetById(assetId);

            IJob job = cloudMediaContext.Jobs.Create(string.Format("Convert {0} to MP4", asset.Name));

            IMediaProcessor processor = cloudMediaContext.GetMediaProcessor("Windows Azure Media Encoder");

            ITask task = job.Tasks.AddNew("MP4 Conversion",
                processor,
                //"H.264 256k DSL CBR",
                "H264 Adaptive Bitrate MP4 Set 720p",
                Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.None);

            task.InputAssets.Add(asset);

            task.OutputAssets.AddNew(string.Format("MP4 for {0}", asset.Name),
                AssetCreationOptions.None);

            job.Submit();

            Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", job.Id, job.Name, job.State, job.RunningDuration, job.LastModified);

            return 0;
        }