Intro
When I tried playing videos what were gotten from web applications, I could play them only after finishing downloading.
This time, I will try playing streaming videos again.
WebM
Actually, I can play streaming just by using the WebM videos I created last time.
PlayVideo.cshtml
<!DOCTYPE html>
<html lang="en">
<head>
<title>Play Video</title>
<meta charset="utf-8">
</head>
<body>
<video controls muted autoplay>
<!-- Play published static files -->
<source src="/video/sample.webm" type="video/webm">
</video>
</body>
</html>
Play on Unity applications
I also can play on Unity applications by "VideoPlayer".
It only can play specific video and audio codec for WebM.
- Video Codec: VP8
- Audio Codec: Vorbis
Convert to WebM
To do this, I want to convert mp4 files to WebM files.
This time I use FFmpeg.
It converts video files with options.
I think the easiest way is adding "-lossless 1".
ffmpeg -i "./wwwroot/video/sample.mp4" -c:a libvorbis -lossless 1 ./wwwroot/video/sample_vp8_mp4_lossless.webm
But the converted file size becomes more than 10 times larger.
So I
ffmpeg -i "./wwwroot/video/sample.mp4" -c:v libvpx -c:a libvorbis -crf 10 -b:v 100M -g 300 ./wwwroot/video/sample_vp8_mp4.webm
- -c:v => Video codec
- -c:a => Audio codec
- -crf => For a constant quality mode(range 4-63)
- -b:v => For setting bit rate on average(I set 100MBit/s). If I set this value larger, the quality will become higher. But the file size also will become larger.
-g => GOP size(add 10 intra frames per second at 30fps)
Top comments (0)