Since Azure Media Service is being retired next year, I was thinking to try different approach to encode a video to MP4 and this approach includes Azure Function. The flow would be like this
BlobInputStream
by calling blobClient.openInputStream()
on BlobClient
.byte[]
from BlobInputStream
.FFMPEG
.(This is where my confusion is how to do this).byte[]
, create InputStream
from byte[].upload(InputStream data)
on BlobClinet
.In theory sounds simple but the problem I am running into here is JAVE2 and other similar libraries accepts java.io.File
object for input and output but azure-storage-blob
library does not exposes any api to get File
object. Now option left is to open inputstream to get byte[] but then how to encode a byte array.
Update: Input file size is max 100MB.
I accomplished this with Java azure function and JAVE2 library. I got the SAS Url of source file, then fed that to MultimediaObject
Sample Code:
private File encoded = null;
MultimediaObject multimediaObject = new MultimediaObject(new URL(blobSasUrl));
VideoAttributes video = new VideoAttributes();
video.setCodec(LIBX264_CODEC);
video.setFrameRate(FRAME_RATE);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setOutputFormat(ENCODE_FORMAT);
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(multimediaObject, encoded, attrs);