ffmpeghttp://www.maclife.com/taxonomy/term/13371/all
enTerminal 101: 3 Cool Uses for ffmpeghttp://www.maclife.com/article/columns/terminal_101_3_cool_uses_ffmpeg
<!--paging_filter--><p><em><img src="/files/u12635/terminal_101_teaser_35.png" width="150" height="150" class="graphic-right" />Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!<br /></em><br />Last week, we installed and talked about how to use <a href="http://www.maclife.com/article/columns/terminal_101_converting_videos" target="_blank">ffmpeg to convert videos</a> to various formats right from the terminal, without any additional software on your Mac, but this week, we’re going to take that a bit further by showing you 3 cool uses for ffmpeg. From grabbing images from the video, to separating the audio track, we’ll show that the ffmpeg tool is extremely useful.</p><h3>1. Grab a Still Picture from Video</h3><p>Grabbing a still photo from a video can be done with a screenshot, but if you want the full quality of the video, then ffmpeg can greatly oblige your request. <br /><br />If you want to extract all of the images form a video with ffmpeg, then use the following command:</p><pre>ffmpeg -i video.mp4 img%d.jpg </pre><p>This will create 25 images for every second of the video file. The output images will be in the same directory that you initiate the command from, and will be named image1.jpg, image2.jpg, etc. <br /><br />You can change the capture frame rate by specifying the number of frames you wish to capture per second of video by using the following command:</p><pre>ffmpeg -i video.mp4 -r 10 image%d.jpg </pre><p>Change the “10” above to be the number of images you wish captured for every second of video.</p><p><a class="thickbox" href="/files/u12635/ffmpeg_1_0.png"><img src="/files/u12635/ffmpeg_1_0.png" width="620" height="420" class="thickbox" /></a><br />Optionally, you can also tell the ffmpeg program to only extract the images between a certain time frame in the vieo. You’ll use the following command, along with the “-ss” and “-t” flags:</p><pre>ffmpeg -i video.mp4 -r 15 -ss 00:00:10 -t 00:00:20 img%d.jpg </pre><p>Here, the command will capture 15 images for every second of video, starting (-ss) on the 10th second and continuing for 20 seconds (-t).&nbsp;</p><h3>2. Separate the Audio Track</h3><p>Sometimes you may wish to separate the audio track from a video file without launching any additional tools on your Mac. <br /><br />We’ll use a tool called ffprobe to figure out what type of audio is used in the video that you wish to separate the audio track from. Type the following command:</p><pre>ffprobe video.avi</pre><p>Replace “video.avi” with the name of the video file you’d like to learn more information about. In the text that gets presented to the screen, locate the Metadata section that lists the audio format of the video file (highlighted part in the screenshot). This will list the audio format, and some other specifications.</p><p><a class="thickbox" href="/files/u12635/ffmpeg_2_0.png"><img src="/files/u12635/ffmpeg_2_0.png" width="620" height="435" class="thickbox" /></a><br /><br />Once you know the audio format in the video file, the command is simple to extract the audio from the video:</p><pre>ffmpeg -i video.avi -vn -acodec copy output.aac</pre><p>Replace “.aac” in “output.aac” with the format that was found during the ffprobe command. When you press enter, the audio file will be outputted to the working directory.</p><h3>3. Convert Audio Files to Another Format</h3><p>The ffmpeg tool can do more than just work with video files. You can convert (almost) any audio format into another format by running the following command:</p><pre>ffmpeg -i input.mp3 output.ogg </pre><p>Replace “input.mp3” with the original filename and extension that you wish to change the format of; and, replace “output.ogg” with the output filename and extension that the original file will be converted to. <br /><br /><em>Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, <a href="http://twitter.com/coryb" target="_blank">Cory Bohon on Twitter</a>.</em></p>http://www.maclife.com/article/columns/terminal_101_3_cool_uses_ffmpeg#commentsAudioColumnsconvertffmpegpictureTerminalTerminal 101videoVideosMacMon, 05 Nov 2012 04:16:24 +0000Cory Bohon15494 at http://www.maclife.comTerminal 101: Converting Videoshttp://www.maclife.com/article/columns/terminal_101_converting_videos
<!--paging_filter--><p><em><img src="http://www.maclife.com/files/u12635/terminal_101_teaser_34.png" width="150" height="150" class="graphic-right" />Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!</em><br /><br />Proving that the Terminal is great for many different tasks (not just those that are text-based), we’ll show you just how easy it can be to convert videos to various formats using the freely available <em>ffmpeg</em> command line program. With the fast <em>ffmpeg</em> program, you can convert between new and even archaic video formats with relative ease. Continue reading and we’ll show you how.</p><h3>Installing ffmpeg</h3><p>To install ffmpeg, you’ll need either <a href="http://www.maclife.com/article/columns/terminal_101_using_macports_and_homebrew" target="_blank">Mac Ports or Homebrew</a> as the ffmpeg program is not installed on Macs by default. Depending on the package manager you’ll be using, you’ll type one of the following commands into the terminal to start the installation process.</p><p><a class="thickbox" href="/files/u12635/ffmpeg_1.png"><img src="/files/u12635/ffmpeg_1.png" width="620" height="435" class="thickbox" /></a><br />For Homebrew, type:</p><pre>brew install ffmpeg </pre><p>For MacPorts, type:</p><pre>sudo port install ffmpeg </pre><p>The installation process will take a few minutes as the program is downloaded, built, and installed onto your Mac. If you get an error from Homebrew or MacPorts, you may need to update them by issuing one of the following commands. <br /><br />To update Homebrew, type:</p><pre>brew update </pre><p>To update MacPorts, type:</p><pre>sudo port selfupdate</pre><h3>Converting Between Video Formats</h3><p><a class="thickbox" href="/files/u12635/ffmpeg_2.png"><img src="/files/u12635/ffmpeg_2.png" width="620" height="435" class="thickbox" /></a></p><p>The ffmpeg program will be able to convert between wav, mpeg/mpg, avi, mov, mp3, mp4, and many more. For a full list of supported formats, type the following command into the terminal:</p><pre>ffmpeg -formats</pre><p>To convert one file into another, we’ll use the following basic syntax:</p><pre>ffmpeg -i file.avi newfile.mp4</pre><p>You’ll replace “file.avi” with the name and extension of the file that you will be inputting, and replace “newfile.mp4” with the name and extension of the file that you will be outputting.</p><p><a class="thickbox" href="/files/u12635/ffmpeg_3.png"><img src="/files/u12635/ffmpeg_3.png" width="620" height="435" class="thickbox" /></a><br /><br />The program will go to work, converting the video into your specified format. As the conversion process is going on, you’ll see new lines printed to the terminal with information on the encoding process. When done, the terminal will return command, and the outputted video file will be available in the same directory where the command was executed.</p><p><a class="thickbox" href="/files/u12635/ffmpeg_4.png"><img src="/files/u12635/ffmpeg_4.png" width="620" height="435" class="thickbox" /></a><br /><br /><em>Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, <a href="http://twitter.com/coryb" target="_blank">Cory Bohon on Twitter</a>.</em></p>http://www.maclife.com/article/columns/terminal_101_converting_videos#commentsaviColumnsconversionconvertffmpegformatsMacmp4MPEGTerminal 101videoMacMon, 29 Oct 2012 20:31:36 +0000Cory Bohon15440 at http://www.maclife.com