I want to encode my videos using ffmpeg and I create a 10MB MP4 file. Then I want to upload it on Azure media service as an asset. Then I want to stream it via Streaming Origin and apply CDN on that origin. I do not want to use ENCODING job from media services. So the problem is that after uploading an asset I see a URL which contains BLOB direct URL where I can stream. But I want to apply STREAMING Origin on this url without encoding job. Which I don't think is possible. What is the solution to that.
Here is the example
CASE 1 - Just uploaded and published
Let's say that I uploaded an mp4 file song on azure portal and i see the url like this
https://fiautomationblobstore.blob.core.windows.net/asset-ea4748ff-0300-80c3-1fe8-f1e525056262/_enr.mp4?sv=2012-02-12&sr=c&si=6c0d7963-8eb9-4568-af27-454e1d09220e&sig=xP0xuk6BTh%2Bbrzgtur%2BJZypr%2FLE505%2Bp%2FQ3xB%2B%2Blj0E%3D&st=2015-07-08T00%3A12%3A06Z&se=2115-06-14T00%3A12%3A06Z
If I publish this it works but of course this is coming directly from the blob storage URL "fiautomationblobstore.blob.core.windows.net"
CASE 2 - uploaded and encoded and published
Where if I encoded another video then published the url was like this
http://tmediasvc.streaming.mediaservices.windows.net/bcdcb0c3-c02a-4148-8e71-4d59caa5b205/enr.ism/Manifest
notice the "tmediasvc.streaming.mediaservices.windows.net" part its streaming origin.
How I can make first file coming from my streaming service "tmediasvc.streaming.mediaservices.windows.net" without applying ENCODING. I want to do this for 2 reasons.
1. I have applied encoding by ffmpeg before uploading
2. The size in second case grows from 16 MB to 100MB strangely. And this is because of very few options on media encoding in azure and i am not sure why there is no option for 360p/480p or less. its all above 720p which is weird. So encoding a file from 16BM to 100MB is Extremely wierd.
Thanks for the help in advance.
Have you tried just uploading it to blob storage, then returning that URL? This way it will not apply any sort of formatting to the original file.
Or am I misunderstanding the question?
Related
I am trying to achieve uploading an MP4 video to Azure Media services; making it available for streaming via a streaming URL, as well as more importantly and specifically to this question: upload .VTT captions to be shown within the video.
I have worked on integrating the code within this tutorial, more specifically the EncodeAndStreamFiles sample app (described in the document) as a DotNetCore API.
I have managed to retrieve a list of streaming URLs for the Video, and the stream works well (the video is playable).
The next step is uploading a .VTT caption (or subtitle). Unfortunately, I have not found any official documentation from Microsoft regarding this subject. This Stack Overflow question is the only useful information I found. Based on the answers to the question; I am uploading the caption within the same blob container as the video's output asset and referring to it by editing the video's streaming URL (replacing the last part).
So if the video's streaming URL is this:
https://azuremediaservicename-euwe.streaming.media.azure.net/2e262dca-23d9-453d-be00-6a7e60167ab7/HR%20documents.ism/manifest(format=m3u8-aapl)
Then the caption's streaming URL would be:
https://azuremediaservicename-euwe.streaming.media.azure.net/2e262dca-23d9-453d-be00-6a7e60167ab7/HR%20documents.vtt
I am trying to display the video and the caption using the advanced options within this tool. The caption appears within the options, but the actual words don't appear on screen.
I have 2 questions -
Is the uploading of the Caption as part of the blob container, the correct way to upload captions? Or is there a better way (perhaps via the SDK) that I haven't run into yet?
If the answer to 1. is Yes, how should the streaming URL for the caption be generated? Is the example shown above correct?
If you want to store the VTT file in the same storage container than the asset, and make it available as download, then you need to change the predefined policy to
StreamingPolicyName = PredefinedStreamingPolicy.DownloadAndClearStreaming
in line https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials/blob/master/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs#L403
This approach works for clear content but not for protected (DRM) content. For protected content, you should use a separate container (or asset) for the subtitles files.
We have setup that converts raw videos into HLS format (.m3u8 and .ts files) and organises them into a directory inside a s3 bucket. Each directory inside the bucket represents one video. Since s3 doesn't really have the concept of directory in its implementation, it does not allow us to get a signed url to read the content of the directory to feed into the video player.
I tried signing the URL for the .m3u8 file alone with getObject, but since tries to fetch the parts of the video to play, it will be thrown with an 403 by s3. Using cloudfront is not an option for us at this stage.
Is there a better and secure way to handle the streaming from s3 without making the entire bucket public?
For anybody still looking for similar solution, You can't get signed url for a directory or wildcard using s3 alone. The better way to do it is to have the CloudFront in front of s3 and use CloudFront Signed URLs/Cookies with Custom Policies which allows to use wildcards when signing.
Example from AWS Docs:
{
"Statement": [
{
"Resource":"http://d111111abcdef8.cloudfront.net/training/*",
"Condition":{
"DateLessThan":{"AWS:EpochTime":1357034400}
}
}
]
}
More on that is explained here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html
Even though we did not wanted to use CloudFront initially, we ended up using it since that seemed like the only feasible option at the time and developers from AWS also recommended the same.
If you are okay with building custom solution, you can build a lambda that acts like an authorizer and validated the wildcards on top of s3.
I have a website created using Node Express, this website serves functionality where user can upload an image and it will be stored locally in server folder and the path will be saved in database.
The problem is the images size is taking too much space on the server disk, so i need to use cdn as a storage for those images and to show the image to the user. The problem is i don't know what is the proper end-to-end flow to store this image to cdn.
The end-to-end flow means the customer upload the picture , the server save it, and can be used again when the user need to see it.
My thought is, when the user uploaded the image, then the server save it first locally, the image path, there will be cron running to store the image to CDN, at the end the image stored in the server will be deleted after success store the image to CDN.
Is that the correct way? or there are any other way to do this?
you can do something like this
store images on a cheap storage for long term like s3. this serve as source of truth.
configure cdn to use the s3 url or your server as source => you don't neeed to upload to cdn.
bonus: create an image resizer service to sit in front of the source and configure cdn to use the image resizer service as source. this way, it will reduce the load to your resizer service
In addition to the Tran answer, you can perform some optimizations.
For example, converting to WebP image format which can reduce the size.
Also, you can look at Image CDNs available which are optimized for images. Following article can be helpful for you
https://imagekit.io/blog/what-is-image-cdn-guide/
I uploaded a 295437KB file to Azure private Blob. I connected Azure Verizon Premium CDN via an app service that streams it from the Blob. The file returned is truncated, at different lengths, less than the full file length. Several 10s of MB shorter.
I have checked the file size on the Blob (correct) and also tested the call that retrieves it from the App Service (correct).
So it appears to be on the CDN side. Is there some timeout or request limit I can set on the CDN to alleviate this?
Here is an example of a CDN call that truncates the file:
https://holojem-prod-files-cdn.azureedge.net/artifacts/11/283/332/0008%20Watch%20This%20Video.mp4?DYiNiOt7Q_9xGaZhscklXmcn0tlpDU649hQUD2n7WzgxfirhVQyzwch2-szLjDmUjAshEfe2ZsQ6ejEDR46QvHVKf5WneWFAz1vOQppOPfcBq3KCS11mZ3LpnfFGEzR9RtnsvKyvVSadMXuFy8cLPLYiy4S2boiJ0S-YhQdODqFY7_MbeiJB
And here is the underlying API (mine) that the CDN points to:
I get the full video if I hit that. It is 295,437 KB.
http://holojem-prod-cdn-api.azurewebsites.net/artifacts/11/283/332/0008%20Watch%20This%20Video.mp4?DYiNiOt7Q_9xGaZhscklXmcn0tlpDU649hQUD2n7WzgxfirhVQyzwch2-szLjDmUjAshEfe2ZsQ6ejEDR46QvHVKf5WneWFAz1vOQppOPfcBq3KCS11mZ3LpnfFGEzR9RtnsvKyvVSadMXuFy8cLPLYiy4S2boiJ0S-YhQdODqFY7_MbeiJB
Interestingly, the results are not consistent. When I hit the origin directly a second time from Postman, I got a file of 260,276 KB
When I downloaded from the origin in Chrome, I got 260,744 the first time and 262,144 KB the second time.
The origin is an ASPNET Core Web API
According to your CDN url, I found the CDN have compressed the file when I downloaded it.
You could run fiddler to catch the request as below:
According to this article : To check whether your files are being returned compressed, you need to use a tool like Fiddler or your browser's developer tools. Check the HTTP response headers returned with your cached CDN content. If there is a header named Content-Encoding with a value of gzip, bzip2, or deflate, your content is compressed.
So I suggest you could firstly check the compress setting in your azure portal.
More details, you could refer to this article.
Update:
According to your two url, I have download both video. I found the website's size is a little more than the CDN's video.
The result is as below:
I have also compare the difference between these two file by using mediainfo --fullscan.
Just the Overall bit rate not the same.
One is 17.7 Mbps, another oen is 17.6 Mbps. There are both two minutes.
So I guess may be something wrong with your website to get the blob stream code.I suggest you could recheck it. If you still face the same issue, I suggest you could post some relevant code and the blob video url for us to reproduce the issue.
I uploaded a video to Azure Media Services, and clicked the "publish" button. That gave me a publish URL.
I then used the Azure Media Player (http://amp.azure.net/libs/amp/latest/docs/samples.html) to embed my video content on a page.
The problem I'm having is that the video is choppy to start. Perhaps it's the encoding of the video, but I want to make sure, if I want to stream a video, using the media player or anything else, do I just use the "Publish URL"? OR is there a different way of requesting video content to "smooth stream"?
Yes. You use the publish URL for VOD and you have a few url parameters to change the type of streaming if needed. Default is smooth streaming.
Smooth Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest
HLS Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest(format=m3u8-aapl)
MPEG Dash Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest(format=mpd-time-csf)
See what works best for you
You can also test on this page and try the advanced settings
http://amsplayer.azurewebsites.net/azuremediaplayer.html
The Azure Media Services test page has changed since the last post. The new URL is:
https://ampdemo.azureedge.net/azuremediaplayer.html