<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: toshusai</title>
    <description>The latest articles on DEV Community by toshusai (@toshusai).</description>
    <link>https://dev.to/toshusai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F760517%2Fba218c9c-51f1-4878-9a84-f310cbdec1a7.png</url>
      <title>DEV Community: toshusai</title>
      <link>https://dev.to/toshusai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toshusai"/>
    <language>en</language>
    <item>
      <title>How to create a video editor that works in your browser.</title>
      <dc:creator>toshusai</dc:creator>
      <pubDate>Sat, 27 Nov 2021 06:47:52 +0000</pubDate>
      <link>https://dev.to/toshusai/how-to-create-a-video-editor-that-works-in-your-browser-5akh</link>
      <guid>https://dev.to/toshusai/how-to-create-a-video-editor-that-works-in-your-browser-5akh</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Recently, browser features such as SharedArrayBuffer and WebAssembly are increasing. Video and video converter &lt;a href="https://github.com/Kagami/ffmpeg.js"&gt;ffmpeg also works in browsers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Therefore, I tried to create a video editing software that works on a browser experimentally.&lt;/p&gt;

&lt;p&gt;You can try the demo from here.&lt;br&gt;
&lt;a href="https://vega.toshusai.net/"&gt;https://vega.toshusai.net/&lt;/a&gt;&lt;br&gt;
source&lt;br&gt;
&lt;a href="https://github.com/toshusai/vega"&gt;https://github.com/toshusai/vega&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic Idea
&lt;/h2&gt;

&lt;p&gt;Using basic below materials.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;images&lt;/li&gt;
&lt;li&gt;video&lt;/li&gt;
&lt;li&gt;audio&lt;/li&gt;
&lt;li&gt;text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to display these materials on the screen, a container for information such as playback position, length, and screen position is called a strip.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lUPYjhcy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vx4f5p239txrfshn5lh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lUPYjhcy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vx4f5p239txrfshn5lh.png" alt="Strips" width="658" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Convert these strips into the final video in a way that suits each material.&lt;/p&gt;

&lt;p&gt;FFmpeg inputs are &lt;code&gt;video&lt;/code&gt;, &lt;code&gt;image sequences&lt;/code&gt; or &lt;code&gt;audio&lt;/code&gt;.&lt;br&gt;
If you want to add text, you have to generate image included text.&lt;/p&gt;
&lt;h3&gt;
  
  
  Video
&lt;/h3&gt;

&lt;p&gt;So, convert all the images/videos to image sequence once and pass them to ffmpeg. used &lt;a href="https://github.com/mrdoob/three.js/"&gt;three.js&lt;/a&gt; for the renderer. Three.js can handle image as Texture, also video as VideoTexture.&lt;/p&gt;

&lt;p&gt;The image capture step uses &lt;a href="https://github.com/spite/ccapture.js/"&gt;ccapture&lt;/a&gt; to ensure that the playback frame is converted to an image. All frame images to webm video.&lt;/p&gt;
&lt;h3&gt;
  
  
  Audio
&lt;/h3&gt;

&lt;p&gt;Next, Merge image sequence and audio. This is ffmpeg part.&lt;/p&gt;

&lt;p&gt;For video, get a specific range of audio from the video.&lt;br&gt;
For audio, cut the audio.&lt;/p&gt;

&lt;p&gt;Finally, use &lt;code&gt;filter_compex&lt;/code&gt; to combine all the audio in strip time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  -i _vega_video.webm -i video.mp3 -i audio.mp4
  -filter_complex [2:a]adelay=5715|5715[out2];[1:a]adelay=260|260[out1];[out1][out2]amix=inputs=2[out]
  -map [out]:a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the overall flow diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cUHGvpqI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nry9otwunuct3lt5ffrt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cUHGvpqI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nry9otwunuct3lt5ffrt.png" alt="architecture" width="645" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks Open Source Softwares/Libraries
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript Framework

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nuxt/nuxt.js"&gt;Nuxt.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/vuejs/vue"&gt;Vue.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Video/Audio Converter

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/ffmpegwasm/ffmpeg.wasm"&gt;ffmpeg.wasm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ffmpeg.org/"&gt;FFmpeg&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Capture canvas

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/spite/ccapture.js/"&gt;CCapture.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/thenickdude/webm-writer-js/"&gt;WebM video encoder&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;3D library (as Renderer)

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mrdoob/three.js/"&gt;three.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Audio visualization

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/katspaugh/wavesurfer.js/"&gt;wavesufer.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Monospace font

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/edihbrandon/RictyDiminished"&gt;RictyDimished&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Icons

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/templarian/MaterialDesign"&gt;Material Design Icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/adobe/spectrum-css-workflow-icons"&gt;Spectrum CSS Workflow Icons&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Design System

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/toshusai/spectrum-vue"&gt;Spectrum Vue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/adobe/spectrum-css"&gt;Spectrum CSS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Documentation

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/docsifyjs/docsify/"&gt;Docsify&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Test Asset

&lt;ul&gt;
&lt;li&gt;Audio&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ondoku3.com/"&gt;ondoku3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Video&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.bigbuckbunny.org"&gt;Blender Foundation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Image&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kenney.nl/"&gt;Kenney&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also created a UI components to use for this. If you like / are interested, check this out too.&lt;br&gt;
&lt;a href="https://github.com/toshusai/spectrum-vue"&gt;https://github.com/toshusai/spectrum-vue&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>typescript</category>
      <category>nuxt</category>
    </item>
  </channel>
</rss>
