<?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: Quinn Salas</title>
    <description>The latest articles on DEV Community by Quinn Salas (@darkhist).</description>
    <link>https://dev.to/darkhist</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%2F129182%2Fa6b66b76-0fb1-4a37-be88-d666760b7f68.jpeg</url>
      <title>DEV Community: Quinn Salas</title>
      <link>https://dev.to/darkhist</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/darkhist"/>
    <language>en</language>
    <item>
      <title>Joining OpenLoop 🎉</title>
      <dc:creator>Quinn Salas</dc:creator>
      <pubDate>Mon, 04 Jan 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/darkhist/joining-openloop-317p</link>
      <guid>https://dev.to/darkhist/joining-openloop-317p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;originally posted &lt;a href="https://darkhist.me/blog"&gt;on my blog&lt;/a&gt;  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So excited to share that I'm joining the bright people &lt;a href="https://twitter.com@openloophealth"&gt;@openloop&lt;/a&gt; to help connect medical professionals to hospitals&lt;/p&gt;

&lt;p&gt;Looking forward to making, breaking, and learning new things&lt;/p&gt;

&lt;p&gt;Happy New Year / Be Well&lt;/p&gt;

&lt;p&gt;darkhist&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating Music Videos with FFmpeg</title>
      <dc:creator>Quinn Salas</dc:creator>
      <pubDate>Mon, 05 Aug 2019 20:35:10 +0000</pubDate>
      <link>https://dev.to/darkhist/creating-music-videos-with-ffmpeg-40g2</link>
      <guid>https://dev.to/darkhist/creating-music-videos-with-ffmpeg-40g2</guid>
      <description>&lt;p&gt;This post was originally published on &lt;a href="https://qsalas.me/blog"&gt;my blog&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;After developing an interest in lo-fi hip-hop music videos on YouTube, I wanted to learn how I could create my own. You know the kind, infinitely-looping GIFs from iconic anime films accompanied by lo-fi beats to relax/study to. I had some audio files and a collection of GIFs, but I didn’t know how to combine them. Then, I found FFmpeg!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;What's FFmpeg?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the &lt;a href="https://ffmpeg.org/"&gt;FFmpeg website&lt;/a&gt;, FFmpeg is "a complete, cross-platform solution to record, convert and stream audio and video". Today, we'll be using it to create a music video from a GIF and an MP3!&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Before we get started, I'd like to point out that I'm using a MacBook Pro running OSX Mojave 10.14.5. If you're using a different OS, you can install FFmpeg by &lt;a href="https://ffmpeg.org/download.html"&gt;visiting their Download page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Today, we'll be using Homebrew, the popular package manager for OSX, to install FFmpeg. &lt;/p&gt;

&lt;p&gt;Open your Terminal to get started!&lt;/p&gt;

&lt;p&gt;If you don't have Homebrew, you can get it by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/bin/ruby &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you've installed Homebrew, you can get FFmpeg by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;ffmpeg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the install fails with the strange error, "Xcode alone is not sufficient on Mojave", run the suggested command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xcode-select &lt;span class="nt"&gt;--install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and install the Command Line Developer Tools when prompted. Then, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and follow the installation guide. Finally, re-run the FFmpeg install command.&lt;/p&gt;

&lt;p&gt;To verify that FFmpeg has been installed correctly, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which ffmpeg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/local/bin/ffmpeg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating the Video
&lt;/h2&gt;

&lt;p&gt;Now that we have FFmpeg, we can get started!&lt;/p&gt;

&lt;p&gt;Make sure you have a GIF and MP3 file saved in the same folder on your computer. I put my files in a &lt;code&gt;Documents/music&lt;/code&gt; folder, but you can save them wherever you'd like.&lt;/p&gt;

&lt;p&gt;Navigate into the folder where your files are using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;path/to/your/files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case, this would look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;Documents/music
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we can use the following command to create our music video!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-i&lt;/span&gt; song.mp3 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-stream_loop&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-i&lt;/span&gt; cool-gif.gif &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-codec&lt;/span&gt;:v libx264 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-preset&lt;/span&gt; slow &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-tune&lt;/span&gt; animation &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-codec&lt;/span&gt;:a aac &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-pix_fmt&lt;/span&gt; yuv420p &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-shortest&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
mv.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;song.mp3&lt;/code&gt; and &lt;code&gt;cool-gif.gif&lt;/code&gt; with the names of your files!&lt;/p&gt;

&lt;p&gt;I named my output file &lt;code&gt;mv.mp4&lt;/code&gt;, but you can name yours whatever you'd like. After the video is created, it will be automatically saved to the current folder.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Okay, now we have our awesome music video, but what is FFmpeg actually doing?...&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Command Breakdown
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ffmpeg&lt;/code&gt;: Invokes the FFmpeg program&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-i [file]&lt;/code&gt; : Indicates that the specified file will be used as an input&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-stream_loop -1&lt;/code&gt;: Sets the number of times an input should be looped. In our case, we want our GIF to loop forever, so we set the loop count to -1&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-codec:v libx264&lt;/code&gt;: Specifies that we want to use the libx264 library to compress our GIF with the H.264 codec. H.264 is a fancy video compression tool, used to shrink the file size of a video while retaining as much quality as possible. H.264 uses cool compression techniques like chroma subsampling and motion compensation, which we won't get into today, but if you're interested in learning more, I highly recommend &lt;a href="https://sidbala.com/h-264-is-magic/"&gt;this blog post by Sid Bala&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-preset slow&lt;/code&gt;: This setting changes the video encoding speed, which changes the compression of our video. Video encoding is a CPU-intensive task, so a slower encoding speed takes longer, but will give us a higher quality video. Feel free to explore other preset options!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-tune animation&lt;/code&gt;: This option changes the video encoding settings based on the type of input we're using. In my case, I used a GIF from an anime, so &lt;code&gt;animation&lt;/code&gt; seemed like the best choice&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more information about the H.264 codec, or to explore other preset and tuning options, see the H.264 Encoding Guide in the Resouces section below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-codec:a aac&lt;/code&gt;: Specifies that we'd like to use AAC for audio encoding. AAC is a very popular audio encoder, and generally achieves better sound quality compared to MP3 files&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pix_fmt yuv420p&lt;/code&gt;: Specifies that the YUV pixel format should be used for our output video. YUV is a special color space, similar to RGB, and allows our video to be played with QuickTime and other video players. If you'd like to learn more about YUV, the &lt;a href="https://en.wikipedia.org/wiki/YUV"&gt;Wikipedia Page&lt;/a&gt; is a great place to start&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-shortest&lt;/code&gt;: Tells FFmpeg to finish encoding as soon as the shortest input encoding is finished. This ensures that the duration of the music video matches the duration of the input audio&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mv.mp4&lt;/code&gt;: The name of the output file&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ffmpeg.org/ffmpeg.html"&gt;FFmpeg Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://trac.ffmpeg.org/wiki/Encode/H.264"&gt;H.264 Encoding Guide&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;After working with FFmpeg, I learned more about audio and video encoding, pixel formats, and more! I hope you did too! It was really cool to explore audio and video encoding while making something fun. Thanks for reading! If you enjoyed this post, &lt;a href="https://twitter.com/QuinnSalas"&gt;let me know on Twitter&lt;/a&gt; :~)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks to Greg Harris for reading a draft of this post&lt;/em&gt;&lt;/p&gt;

</description>
      <category>audio</category>
      <category>video</category>
      <category>ffmpeg</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
