<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Videos – IMG.LY Blog</title><description>Posts tagged Videos on the IMG.LY blog.</description><link>https://img.ly/blog/tag/videos/</link><language>en-us</language><image><url>https://img.ly/apple-touch-icon.png</url><title>Videos – IMG.LY Blog</title><link>https://img.ly/blog/tag/videos/</link></image><atom:link href="https://img.ly/blog/tag/videos/rss.xml" rel="self" type="application/rss+xml"/><generator>Astro</generator><lastBuildDate>Fri, 26 Jun 2026 15:01:04 GMT</lastBuildDate><ttl>60</ttl><item><title>How to Stream Videos Using Javascript and HTML5</title><link>https://img.ly/blog/how-to-stream-videos-using-javascript-and-html5/</link><guid isPermaLink="true">https://img.ly/blog/how-to-stream-videos-using-javascript-and-html5/</guid><description>Learn how to stream videos right in your browser using only JavaScript and HTML5 APIs.</description><pubDate>Mon, 29 Aug 2022 20:36:00 GMT</pubDate><content:encoded>&lt;p&gt;If you would tell someone from the early 2000s what you’re about to do, they would be amazed and would give everything to understand how you did it. Because back then HTML was much simpler and didn’t even support video playback. So to stream your video inside of your browser you were forced to use some third-party services like Flash or Silverlight. Now we have HTML5 and new versions of JavaScript, and by combining these two new technologies you’ll end up with results that rival native applications. Streaming video inside of your web application nowadays is a breeze.&lt;/p&gt;
&lt;h2 id=&quot;the-video-tag&quot;&gt;The &lt;code&gt;&amp;#x3C;video&gt;&lt;/code&gt; tag&lt;/h2&gt;
&lt;p&gt;You can easily start streaming your own video by using only one tag in HTML5. I’m talking about the &lt;code&gt;&amp;#x3C;video&gt;&lt;/code&gt; tag. It embeds a fully-fledged media player in the document and similar to the &lt;code&gt;img&lt;/code&gt; tag accepts a path to the media we want to play inside the &lt;code&gt;src&lt;/code&gt; attribute as well as accepting parameters for &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In addition, there are video-specific properties such as whether the video should loop or autoplay and whether to display the default browser controls.&lt;/p&gt;
&lt;p&gt;To handle the case of browsers not supporting the &lt;code&gt;video&lt;/code&gt; tag you can provide fallback content inside the &lt;code&gt;&amp;#x3C;video&gt;&amp;#x3C;/video&gt;&lt;/code&gt; tags.&lt;/p&gt;
&lt;iframe src=&quot;https://codesandbox.io/embed/fast-rgb-03tbl5?fontsize=14&amp;#x26;hidenavigation=1&amp;#x26;theme=dark&quot; title=&quot;fast-rgb-03tbl5&quot; allow=&quot;accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking&quot; sandbox=&quot;allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts&quot;&gt;&lt;/iframe&gt;
&lt;h2 id=&quot;combining-with-javascript&quot;&gt;Combining with JavaScript&lt;/h2&gt;
&lt;p&gt;You can also combine this simple video streaming in HTML with JavaScript and make it more professional and be able to control your streaming manually. When you get an element from the DOM of a &lt;code&gt;video&lt;/code&gt; tag, the object that you get exposes various methods and attributes which can be used for manipulating media content. Firstly, we need to access the DOM and declare an object which will be used for our manipulations. Now we can use &lt;code&gt;myVideo&lt;/code&gt; to programmatically pause, change the playback rate and current time of the video.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; myVideo&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; document.&lt;/span&gt;&lt;span&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&apos;#video1&apos;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;//pause the video&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;myVideo.&lt;/span&gt;&lt;span&gt;pause&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;//Change the speed of playback&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;myVideo.playbackRate &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; 3.0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;//Change current time&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;myVideo.currentTime &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; 4&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, most videos that we see on the web today such as YouTube, Twitch, or any other social media display much more complex behaviors than just changing playback speed or pausing the video. On YouTube, you can change the quality of your video, add subtitles, or even add features like autoplay if you have several other videos queued up and don’t want to switch it manually.&lt;/p&gt;
&lt;p&gt;All those services actually still use a video tag. But instead of streaming a video file through the “src” attribute inside of your tag, they use powerful tools such as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API&quot;&gt;Media Source Extensions&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP&quot;&gt;other adaptive streaming API&lt;/a&gt; that will help stream your video more efficiently.&lt;/p&gt;
&lt;h2 id=&quot;what-are-media-source-extensions-mse&quot;&gt;What are Media Source Extensions (MSE)&lt;/h2&gt;
&lt;p&gt;Media Source Extensions is a W3C specification that allows JavaScript to send streams to media codecs within Web browsers that support HTML5 video and audio that most browsers implement today. In other words, it allows JavaScript to generate streams and facilitate a variety of use cases like adaptive streaming and time-shifting live streams. It’s quite an advanced solution if you want to make your video playback more customizable and professional. MSE gives us finer grained control over how much and how often content is fetched, and some control over memory usage details, such as when buffers are evicted.&lt;/p&gt;
&lt;p&gt;Wrap your resource via the Media Source Extensions API instead of dealing with the URL directly (We’ll talk more closely about it a little bit later).&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; sizes=&quot;(min-width: 2000px) 2000px, 100vw&quot; data-astro-image=&quot;constrained&quot; data-astro-image-pos=&quot;center&quot; width=&quot;2000&quot; height=&quot;709&quot; src=&quot;https://img.ly/_astro/MediaSource_fyAaQ.webp&quot; srcset=&quot;/_astro/MediaSource_Z23x9ON.webp 640w, /_astro/MediaSource_1myAEA.webp 750w, /_astro/MediaSource_pO5aO.webp 828w, /_astro/MediaSource_1MlG3T.webp 1080w, /_astro/MediaSource_1cjHTR.webp 1280w, /_astro/MediaSource_GJoDh.webp 1668w, /_astro/MediaSource_fyAaQ.webp 2000w&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;this-specification-was-designed-with-the-following-goals&quot;&gt;This specification was designed with the following goals:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Let JavaScript create a media stream regardless of how the media is fetched.&lt;/li&gt;
&lt;li&gt;Leverage the browser cache as much as possible.&lt;/li&gt;
&lt;li&gt;Provide requirements for byte stream format specifications.&lt;/li&gt;
&lt;li&gt;Minimize the need for media parsing in JavaScript.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As I mentioned, we are still using HTML5 video tags, and even more surprising is that we’ll still use the “src” attribute. Only this time, instead of adding a link to the video, add a link to the MediaSource object.&lt;/p&gt;
&lt;p&gt;If you’re a little bit confused, then don’t worry, I’ll explain everything. To enable this type of use case, the W3C has defined a static method &lt;code&gt;URL.createObjectURL&lt;/code&gt;. You can use this API to create a URL that directly points to a JavaScript object created on the client, rather than actually pointing to an online resource.&lt;/p&gt;
&lt;p&gt;You can see how it works in this example:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; videoTag&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; document.&lt;/span&gt;&lt;span&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&apos;my-video&apos;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// creating the MediaSource, just with the &quot;new&quot; keyword, and the URL for it&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; myMediaSource&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; new&lt;/span&gt;&lt;span&gt; MediaSource&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; URL&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;createObjectURL&lt;/span&gt;&lt;span&gt;(myMediaSource);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// attaching the MediaSource to the video tag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;videoTag.src &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; url;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that you have a MediaSource, what should you do? That’s not the only MSE specification. It also defines another concept, Source Buffers.&lt;/p&gt;
&lt;h2 id=&quot;source-buffers&quot;&gt;*&lt;strong&gt;*Source Buffers**&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The SourceBuffer interface &lt;strong&gt;represents a chunk of media to be passed into an HTMLMediaElement and played via a MediaSource object.&lt;/strong&gt; To put the video directly into the MediaSource for playback, you’ll need Source Buffers. MediaSource contains one or more instances of it. Each is associated with a content type, such as &lt;code&gt;Audio&lt;/code&gt;, &lt;code&gt;Video&lt;/code&gt;, or both of them at the same time. Source buffers are all associated with a single MediaSource and are used in JavaScript to add video data directly to HTML5 video tags. Separating video and audio allows managing them separately on the server. Doing so has several advantages such as control over your traffic and increasing performance. This is how it works:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// -- Create a MediaSource and attach it to the video (We already learned about that) --&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; videoTag&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; document.&lt;/span&gt;&lt;span&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&apos;my-video&apos;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; myMediaSource&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; new&lt;/span&gt;&lt;span&gt; MediaSource&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; URL&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;createObjectURL&lt;/span&gt;&lt;span&gt;(myMediaSource);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;videoTag.src &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; url;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// 1. add source buffers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; audioSourceBuffer&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; myMediaSource.&lt;/span&gt;&lt;span&gt;addSourceBuffer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &apos;audio/mp4; codecs=&quot;mp4a.40.2&quot;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; videoSourceBuffer&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; myMediaSource.&lt;/span&gt;&lt;span&gt;addSourceBuffer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &apos;video/mp4; codecs=&quot;avc1.64001e&quot;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// 2. download and add our audio/video to the SourceBuffers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// for the audio SourceBuffer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;fetch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&apos;&amp;#x3C;http://server.com/audio.mp4&gt;&apos;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;response&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    // The data has to be a JavaScript ArrayBuffer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    return&lt;/span&gt;&lt;span&gt; response.&lt;/span&gt;&lt;span&gt;arrayBuffer&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;audioData&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    audioSourceBuffer.&lt;/span&gt;&lt;span&gt;appendBuffer&lt;/span&gt;&lt;span&gt;(audioData);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// the same for the video SourceBuffer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;fetch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&apos;&amp;#x3C;http://server.com/video.mp4&gt;&apos;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;response&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    // The data has to be a JavaScript ArrayBuffer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    return&lt;/span&gt;&lt;span&gt; response.&lt;/span&gt;&lt;span&gt;arrayBuffer&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;videoData&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    videoSourceBuffer.&lt;/span&gt;&lt;span&gt;appendBuffer&lt;/span&gt;&lt;span&gt;(videoData);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;adaptive-streaming&quot;&gt;*&lt;strong&gt;*Adaptive Streaming**&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Many video players have an “auto quality” feature that automatically selects quality based on network speed. If you have a slow internet connection then you’ll end up watching a video in the lowest resolution (probably 360p or even lower), on the other hand, if the connection is good then the video will be in the highest resolution (probably 1080p or even higher). It depends on how many options the specific video has. In addition, your hardware capability is also taken into account.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; sizes=&quot;(min-width: 1920px) 1920px, 100vw&quot; data-astro-image=&quot;constrained&quot; data-astro-image-pos=&quot;center&quot; width=&quot;1920&quot; height=&quot;929&quot; src=&quot;https://img.ly/_astro/StreamingVideo_Z283hMX.webp&quot; srcset=&quot;/_astro/StreamingVideo_ZR8DDM.webp 640w, /_astro/StreamingVideo_1MDLQg.webp 750w, /_astro/StreamingVideo_2m6JDQ.webp 828w, /_astro/StreamingVideo_20Qkbx.webp 1080w, /_astro/StreamingVideo_Z1U1FVk.webp 1280w, /_astro/StreamingVideo_Z1iNCGF.webp 1668w, /_astro/StreamingVideo_Z283hMX.webp 1920w&quot;&gt;&lt;/p&gt;
&lt;p&gt;On the server side, we create different segments for every quality we want to support. For example, we would put the following files on our server:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;./video/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  ├── ./360p/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     ├── video_0.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     ├── video_1.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     └── video_2.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	├── ./720p/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     ├── video_0.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     ├── video_1.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  |     └── video_2.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  └── ./1080p/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        ├── video_0.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        ├── video_1.mp4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        └── video_2.mp4&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The web player then automatically selects the correct video file to load when the network or CPU state changes. This is entirely done in JavaScript. For video segments, it could, for example, look as follows:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * We first derive the desired quality from the bandwidth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * Then pass it to the pushVideoSegment()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * which fetches each segment with the desired quality in turn and returns a promise&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;**/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; pushVideoSegment&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;nb&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;wantedQuality&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; const&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; &quot;&amp;#x3C;http://my-server/video/&gt;&quot;&lt;/span&gt;&lt;span&gt; +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; wantedQuality &lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt; &quot;/segment&quot;&lt;/span&gt;&lt;span&gt; +&lt;/span&gt;&lt;span&gt; nb &lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt; &quot;.mp4&quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;return&lt;/span&gt;&lt;span&gt; fetch&lt;/span&gt;&lt;span&gt;(url)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;((&lt;/span&gt;&lt;span&gt;response&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;=&gt;&lt;/span&gt;&lt;span&gt; response.&lt;/span&gt;&lt;span&gt;arrayBuffer&lt;/span&gt;&lt;span&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;arrayBuffer&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; videoSourceBuffer.&lt;/span&gt;&lt;span&gt;appendBuffer&lt;/span&gt;&lt;span&gt;(arrayBuffer);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * Translate an estimated bandwidth to the right audio&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * quality as defined on server-side.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * &lt;/span&gt;&lt;span&gt;@param&lt;/span&gt;&lt;span&gt; {number}&lt;/span&gt;&lt;span&gt; bandwidth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; * &lt;/span&gt;&lt;span&gt;@returns&lt;/span&gt;&lt;span&gt; {string}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt; fromBandwidthToQuality&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;bandwidth&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; return&lt;/span&gt;&lt;span&gt; bandwidth &lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;span&gt; 320e3&lt;/span&gt;&lt;span&gt; ?&lt;/span&gt;&lt;span&gt; &quot;360p&quot;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &quot;720p&quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// first estimate the bandwidth. Most often, this is based on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;// the time it took to download the last segments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; bandwidth&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; estimateBandwidth&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; quality&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; fromBandwidthToQuality&lt;/span&gt;&lt;span&gt;(bandwidth);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;pushVideoSegment&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;, quality)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(() &lt;/span&gt;&lt;span&gt;=&gt;&lt;/span&gt;&lt;span&gt; pushVideoSegment&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;, quality))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; .&lt;/span&gt;&lt;span&gt;then&lt;/span&gt;&lt;span&gt;(() &lt;/span&gt;&lt;span&gt;=&gt;&lt;/span&gt;&lt;span&gt; pushVideoSegment&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;, quality));&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Congratulations, you’ve learned multiple ways how to stream a video file into your browser. We have explored several tools that are helping you not just change some video parameters by using vanilla JS and HTML, and also Media Source Extensions (MSE) that are helping all developers around the world to build professional web players which you’re using yourself, such as YouTube, Twitch, TikTok and many others.&lt;/p&gt;
&lt;p&gt;If you want to give your users the ability to also edit videos within your mobile application check out our &lt;a href=&quot;https://img.ly/products/video-sdk/&quot;&gt;Video Editor SDK&lt;/a&gt; offering features such as trimming, transforms, video composition and more. It’s fully customizable to match the look and feel of your app and the most performant solution on the market.&lt;/p&gt;
&lt;p&gt;Looking for more video capabilities? Check out our solutions for &lt;a href=&quot;https://img.ly/use-cases/story-reels-short-video-creation/&quot;&gt;Short Video Creation&lt;/a&gt;, and &lt;a href=&quot;https://img.ly/products/video-sdk-mobile/&quot;&gt;Camera SDK&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;If you have questions, feedback or comments reach out to us on &lt;a href=&quot;https://twitter.com/imgly&quot;&gt;Twitter&lt;/a&gt;.&lt;/p&gt;</content:encoded><dc:creator>Mark</dc:creator><media:content url="https://blog.img.ly/2022/08/stream-videos-using-Javascript-and-HTML5.png" medium="image"/><category>How-To</category><category>Tech</category><category>Video Editing</category><category>Videos</category><category>Tutorial</category></item><item><title>May the Force Trim be with you: A New Feature in VE.SDK</title><link>https://img.ly/blog/new-force-trim-function-for-videoeditor-sdk/</link><guid isPermaLink="true">https://img.ly/blog/new-force-trim-function-for-videoeditor-sdk/</guid><description>Set the minimum and maximum duration of videos with our latest update.</description><pubDate>Tue, 14 Dec 2021 15:01:31 GMT</pubDate><content:encoded>&lt;p&gt;It has been a fantastic year for video editing – the &lt;a href=&quot;https://img.ly/blog/video-composition-audio-support/&quot;&gt;video composition tool and audio support&lt;/a&gt; enhanced our VideoEditor SDK offerings, enabling developers to bring more high-quality features right into your products and apps. Today, we deliver another feature to enhance your developer experience.&lt;/p&gt;
&lt;h2 id=&quot;force-trim&quot;&gt;Force Trim&lt;/h2&gt;
&lt;p&gt;The VideoEditor SDK trim tool allows your users to determine the start and end frame of a video clip, and thus change the duration of their footage. Now you are also able to &lt;strong&gt;enforce a minimum and maximum duration&lt;/strong&gt; of videos.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Set a minimum and/or a maximum duration for users.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; sizes=&quot;(min-width: 1086px) 1086px, 100vw&quot; data-astro-image=&quot;constrained&quot; data-astro-image-pos=&quot;center&quot; width=&quot;1086&quot; height=&quot;1139&quot; src=&quot;https://img.ly/_astro/min-max-length-videos-app-1_30n9P.webp&quot; srcset=&quot;/_astro/min-max-length-videos-app-1_Z2qfAdT.webp 640w, /_astro/min-max-length-videos-app-1_ZikVdt.webp 750w, /_astro/min-max-length-videos-app-1_1qCbwr.webp 828w, /_astro/min-max-length-videos-app-1_ZftVuf.webp 1080w, /_astro/min-max-length-videos-app-1_30n9P.webp 1086w&quot;&gt;&lt;/p&gt;
&lt;p&gt;Additionally, the update allows configuring the &lt;strong&gt;startup behavior&lt;/strong&gt; of your editor. Possible values are &lt;code&gt;always&lt;/code&gt;, &lt;code&gt;ifNeeded&lt;/code&gt;, and &lt;code&gt;silent&lt;/code&gt; (the default).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;always&lt;/code&gt; will always automatically present the composition tool or the trim tool after opening the editor and force your users to change the length of the video(s).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ifNeeded&lt;/code&gt; will only present&lt;br&gt;
 a) the composition tool, if your initial composition is longer than the maximum duration or shorter than the minimum duration, or&lt;br&gt;
 b) the trim tool, if your initial video is longer than the maximum duration.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;silent&lt;/code&gt; will automatically trim the video to the maximum duration without opening any tool.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Find the right set-up for your use-case in our official &lt;strong&gt;documentation&lt;/strong&gt; for &lt;a href=&quot;https://img.ly/docs/vesdk/ios/guides/trim/force-trim/?utm_source=imgly&amp;#x26;utm_medium=blog&amp;#x26;utm_campaign=releasenotes&quot;&gt;iOS&lt;/a&gt; and &lt;a href=&quot;https://img.ly/docs/vesdk/android/features/trim#how-to-enforce-a-minimum-or-maximum-video-length/?utm_source=imgly&amp;#x26;utm_medium=blog&amp;#x26;utm_campaign=releasenotes&quot;&gt;Android&lt;/a&gt;. Once the trim tool is part of your subscription, you are ready to enhance your user experience.&lt;/p&gt;
&lt;h3 id=&quot;frameworks&quot;&gt;Frameworks&lt;/h3&gt;
&lt;p&gt;Of course, our &lt;a href=&quot;https://img.ly/docs/vesdk/quickstarts/?utm_source=imgly&amp;#x26;utm_medium=blog&amp;#x26;utm_campaign=announcements&quot;&gt;wrappers&lt;/a&gt; for &lt;strong&gt;Flutter, Cordova&lt;/strong&gt; and &lt;strong&gt;React Native&lt;/strong&gt; have been updated to support force trim.&lt;/p&gt;
&lt;h3 id=&quot;built-to-build&quot;&gt;Built to Build&lt;/h3&gt;
&lt;p&gt;Force Trim will come in handy for use cases, such as social media stories and posts, that have been popularly limited to bite size 15 or 60 seconds by widely loved apps – see TikTok or Instagram. Adopting a ready-to-use solution like &lt;a href=&quot;https://img.ly/products/video-sdk/&quot;&gt;VideoEditor SDK&lt;/a&gt; will set you straight onto your path of creating equally beautiful apps by saving you resources and streamlining your process.&lt;/p&gt;
&lt;h3 id=&quot;a-sleek-user-experience&quot;&gt;A Sleek User Experience&lt;/h3&gt;
&lt;p&gt;Newly in is the interactive and animated timeline, that now elegantly adjusts to the trimming process.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Runs like butter: an interactive and animated timeline&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; sizes=&quot;(min-width: 1280px) 1280px, 100vw&quot; data-astro-image=&quot;constrained&quot; data-astro-image-pos=&quot;center&quot; width=&quot;1280&quot; height=&quot;720&quot; src=&quot;https://img.ly/_astro/video-editor-SDK-timeline-trim_Zq9FTB.webp&quot; srcset=&quot;/_astro/video-editor-SDK-timeline-trim_hFCNo.webp 640w, /_astro/video-editor-SDK-timeline-trim_v09gO.webp 750w, /_astro/video-editor-SDK-timeline-trim_Z1NV0b.webp 828w, /_astro/video-editor-SDK-timeline-trim_Zgg9YQ.webp 1080w, /_astro/video-editor-SDK-timeline-trim_Zq9FTB.webp 1280w&quot;&gt;&lt;/p&gt;
&lt;p&gt;Aware of how time-consuming and costly app development can be for you, our team is committed to delivering more features to enhance your developer experience. &lt;strong&gt;Feel free to reach out to us on &lt;a href=&quot;https://twitter.com/imgly&quot;&gt;Twitter&lt;/a&gt; with any questions, comments, or suggestions!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thank you for reading, and happy development!&lt;/p&gt;</content:encoded><dc:creator>Neslihan</dc:creator><media:content url="https://blog.img.ly/2021/12/trim-videos-app-videoapp.png" medium="image"/><category>Release Notes</category><category>Video Editor</category><category>App Development</category><category>Social Media</category><category>Videos</category><category>Company</category></item><item><title>The future is Video, the future is now!</title><link>https://img.ly/blog/the-future-is-video-the-future-is-now-f5b3911023f6/</link><guid isPermaLink="true">https://img.ly/blog/the-future-is-video-the-future-is-now-f5b3911023f6/</guid><description>Introducing VideoEditor SDK for iOS and Android</description><pubDate>Tue, 13 Aug 2019 00:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://img.ly/products/video-sdk/&quot;&gt;VideoEditor SDK&lt;/a&gt; expands the powerful tools and features of &lt;a href=&quot;https://img.ly/products/photo-sdk/&quot;&gt;PhotoEditor SDK&lt;/a&gt; into the realm of mobile video creation, empowering you to seamlessly integrate a cinematic experience into your mobile applications.With an intuitive and elegant UI, an extensive filter gallery, advanced adjustment tools, and crops for social aspect ratios you’ll gift your users with the ability to create engaging and professional-looking videos on the fly.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/embed/FDuwEtBf8N8?feature=oembed&quot;&gt;https://www.youtube.com/embed/FDuwEtBf8N8?feature=oembed&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Video is one of the most effective means of communication in our era. According to &lt;a href=&quot;https://blog.hubspot.com/marketing/state-of-video-marketing-new-data&quot;&gt;Hubspot&lt;/a&gt;, the usage and consumption of video content continue to grow and still haven’t reached their saturation point. Video is changing the way we interact on a daily basis, and it’s here to stay.&lt;/p&gt;
&lt;p&gt;Although most videos are shot spontaneously and then posted instantly, even slight editing can have a tremendous effect on the content’s impact. VideoEditor SDK lets your users create professional-looking footage without having to rely on external apps while using your solution. The SDK is packed with intuitive yet powerful tools that allow for the creation of an endless variety of stunning visual effects. All tools come with an instant preview and can be tailored to fit your app perfectly.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;trimming--transformation-keeping-itrelevant&quot;&gt;Trimming &amp;#x26; Transformation: Keeping it relevant&lt;/h2&gt;
&lt;p&gt;The Trimming tool helps your users to keep their content on point and to get rid of unnecessary, boring, or unwanted parts with ease. Furthermore, the SDK is equipped with a Transform tool kit that unifies cropping, flipping, and rotating operations. Featuring various preset video aspect ratios most popular for Instagram (1:1), YouTube (16:9) or other platforms like Snapchat (9:16), the tool lets your users present their content in the most appropriate format.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;video-grading-the-hollywood-look-andfeel&quot;&gt;Video grading: The Hollywood look and feel&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://img.ly/products/video-sdk/&quot;&gt;VideoEditor SDK&lt;/a&gt; ships with over 60 video filters that let your users achieve a cinematic look for their videos with a single tap. Additionally, the Adjustment section holds a variety of handy tools to tweak and fine-tune video content ranging from basic operations like brightness and contrast to more sophisticated options like exposure and gamma. Through instant preview, your users can directly see how their changes affect the final video.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;captioning-and-assets-compelling-storytelling&quot;&gt;Captioning and Assets: Compelling storytelling&lt;/h2&gt;
&lt;p&gt;Video is a narrational medium and VideoEditor SDK provides all necessary functions for your users to quickly turn their footage into engaging and attention-grabbing stories. They can customize their videos with captions using the Text tool or add a stunning typography design with the Text Design tool that automatically merges input text with designer-grade typography layouts.&lt;/p&gt;
&lt;p&gt;On top of that, the SDK ships with various asset libraries for your users to personalize their content with Stickers, Frames, or Overlays to create something they’ll love to share.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;learn-more-about-videoeditor-sdk-and-delight-your-users-with-powerful-video-editing-capabilities&quot;&gt;Learn more about &lt;a href=&quot;https://img.ly/products/video-sdk/&quot;&gt;VideoEditor SDK&lt;/a&gt; and delight your users with powerful video editing capabilities.&lt;/h2&gt;</content:encoded><dc:creator>Felix</dc:creator><media:content url="https://blog.img.ly/2020/04/image-30.png" medium="image"/><category>Videos</category><category>iOS</category><category>Android</category><category>App Development</category><category>Video Editing</category><category>Tech</category><category>How-To</category><category>Learning</category></item></channel></rss>