<?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: Flower Rain Studio</title>
    <description>The latest articles on DEV Community by Flower Rain Studio (@flower-rain-studiofl).</description>
    <link>https://dev.to/flower-rain-studiofl</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4119716%2Fce05ecf4-f6b6-4627-a75e-c68d6d434c36.png</url>
      <title>DEV Community: Flower Rain Studio</title>
      <link>https://dev.to/flower-rain-studiofl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flower-rain-studiofl"/>
    <language>en</language>
    <item>
      <title>Building a browser-local photo slideshow exporter with Canvas and MediaRecorder</title>
      <dc:creator>Flower Rain Studio</dc:creator>
      <pubDate>Thu, 10 Sep 2026 17:49:19 +0000</pubDate>
      <link>https://dev.to/flower-rain-studiofl/building-a-browser-local-photo-slideshow-exporter-with-canvas-and-mediarecorder-4gem</link>
      <guid>https://dev.to/flower-rain-studiofl/building-a-browser-local-photo-slideshow-exporter-with-canvas-and-mediarecorder-4gem</guid>
      <description>&lt;p&gt;Turning a set of photos into a video does not require a server upload pipeline. A browser can draw frames to a canvas, combine that canvas stream with audio, and record the result locally with MediaRecorder.&lt;/p&gt;

&lt;p&gt;This is the approach behind &lt;a href="https://photo2reel.com/" rel="noopener noreferrer"&gt;Photo2Reel&lt;/a&gt;, a small free slideshow maker. The useful constraint was deliberate: selected photos and audio must stay in the browser, with no account, remote rendering queue, or watermark.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rendering loop
&lt;/h2&gt;

&lt;p&gt;Each photo is decoded in the browser and drawn into a 1280 × 720 canvas. The renderer calculates the active slide from elapsed time rather than scheduling a separate timer for every image. That keeps the preview and exported sequence on the same timeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;captureStream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;recorder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MediaRecorder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mimeType&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;drawFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elapsedMs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;slide&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;findSlide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elapsedMs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;durations&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;drawCover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;slide&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;drawFrame&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important detail is cover drawing. Landscape photos can fill the frame. Portrait photos should be placed against a background rather than stretched; otherwise a local tool produces the same distorted output people dislike in quick slideshow apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding music without sending it anywhere
&lt;/h2&gt;

&lt;p&gt;For uploaded audio, an &lt;code&gt;AudioContext&lt;/code&gt; connects the media element to a &lt;code&gt;MediaStreamAudioDestinationNode&lt;/code&gt;. Its audio track is added to the canvas video track before recording. For short built-in tones, the same destination can receive generated oscillator audio instead.&lt;/p&gt;

&lt;p&gt;The exported blob is created only after &lt;code&gt;MediaRecorder&lt;/code&gt; emits its final data. Object URLs provide the download link and are revoked when a new render begins, which avoids retaining large files through repeated previews.&lt;/p&gt;

&lt;h2&gt;
  
  
  Export formats are a capability check
&lt;/h2&gt;

&lt;p&gt;There is no single browser-safe video MIME type. The recorder first checks candidates with &lt;code&gt;MediaRecorder.isTypeSupported()&lt;/code&gt;, typically preferring WebM codecs and falling back to MP4 only when the browser exposes it. The download extension must match the selected MIME type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mimeType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;video/webm;codecs=vp9,opus&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;video/webm;codecs=vp8,opus&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;video/webm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;video/mp4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MediaRecorder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isTypeSupported&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also means the browser does the computational work. Big images or long sequences should be tested in smaller batches first, especially on mobile devices.&lt;/p&gt;

&lt;p&gt;The complete front-end source is available on &lt;a href="https://github.com/wuyuwuyan3013/photo2reel-browser-slideshow-exporter" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. The live tool is useful for checking the result on an actual device, but the central idea is portable: Canvas plus MediaRecorder is enough for a private, browser-local photo-to-video workflow.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>opensource</category>
      <category>privacy</category>
    </item>
  </channel>
</rss>
