How to Get Started Using FFmpeg for Transcoding

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone its Nick coming to you live again from Mountain View California today I want to tell you about one of my favorite open-source command-line utilities for transcoding and working with audio and video media files called ffmpeg so ffmpeg is kind of our Swiss Army tool that we'll be using for transcoding various assets so the first thing that's a little tricky is kind of getting installed correctly so it does have a lot of external dependencies and I will link below in the video description links on how to get everything installed and set up correctly the second thing is once you have ffmpeg installed and you can run from your command line the first thing to learn about ffmpeg is using the - I flag so with - I you can specify as an input file and it will tell you all kinds of information about that file now what I dislike about ffmpeg is that it always dumps config information about how it was built so what we can do is use the hide banner flag and that will prevent this banner from always being displayed now what's great about using - I an - hide banner together is given a video file we can see information such as what's the duration of it but then for the various streams that are within the file what kind of codecs they use so the first thing to note is that the file extension the file extension is kind of a misnomer on a file doesn't actually changing the file extension doesn't change the underlying container that's used nor the codecs that are used for the various streams so a container is what's important is kind of metadata how the bits are packed and the codecs encode how the audio or video streams are so for instance on this file we can see that stream 0 is the video codec and stream 1 is the audio codec and what those codecs are so if we want to figure out what codecs are installed ffmpeg supports we can use the - codecs flag and I like to pet pipe this into less and so it'll print a really neat little table that kind of shows us whether or not codec is a video codec or an audio codec and then whether or not we can decode from a given codec as if that codec was an input and if we can re encode into the the new codec in that process of decoding from one codec and Riaan coding into another we call those two together transcoding so this will tell us whether or not we have these dependencies installed correctly and if you're missing something that you think you should have double check you may have to reinstall a rebuild a fan peg or some of its dependencies so the easiest thing to do is let's say that we want to just transcode a file so given say an MOV file we want to convert to WebM that we can play it in a bunch of web browsers simplest thing is - hide banner - I then put filename move and then the final argument is just the output file name dot WebM in ffmpeg smart enough - from the file extension guess the container and guessed same defaults for the audio and video codec while that's transcoding we can see from the stream mapping output what the input of stream 0 the input codec being h.264 and the output video codec for that stream being vp9 and for the input audio codec being AAC and the output audio codec being opus so let's say now that we want to have finer grained control and explicitly control what the output video and audio codecs are we can use the - C : V flag followed by the name of the output codec for video or the - C : a flag to change the output codec for audio so this gives us fine green control over say for instance we're not happy with vp9 as the video codec in opus as the audio coppa the audio codec we have finer grain control and we can specify it note we actually want vp8 a little bit older codec we want vp8 for video and Vorbis for audio for instance now let's say that you have of a move file that's h.264 and AAC but you want it to be in an mp4 container rather than a move container what we can do to speed up the process is tell ffmpeg that we want to copy the input streams byte for byte and just change kind of the metadata of the container so we can use the - C : V and specify the value copy and - C : a and specify copy as well and this is much faster because it's not actually doing transcoding instead it's kind of stripping these two streams out of the input move container and dumping them into an mp4 output container finally the last thing that I think is really useful is ffmpeg has a really powerful stream multiplexer so the - map command followed by the input stream and then colon separated and followed by the output stream number lets us kind of rearrange exactly how we want our streams to be ordered in an output or what we could do for instance is given a video file that has audio attached we could say we want to strip out audio which is the example that I'm doing here so the map command is really powerful if you have a file that came from someone else and maybe it's a little bloated you can trim down the file size a little bit by stripping out some of the streams that you don't need or you can add additional streams maybe different languages or stuff like that so the - map command is really powerful and if you want to learn more about ffmpeg it has a couple of command line flags there's - H to learn kind of the basics - H long it prints out a lot of output and - H full which prints out a lot of information for working with ffmpeg so it's a really great tool I recommend it kind of today we went over the basics of just seeing how to get started and we should have kind of the basics that we need from transcoding from here on out thanks and let me know what you thought of the video see you next time
Info
Channel: Mozilla Hacks
Views: 26,806
Rating: undefined out of 5
Keywords: FFmpeg (Software), Transcoding (Software Genre), Video Production (Industry)
Id: 1ymYwSQFodU
Channel Id: undefined
Length: 6min 33sec (393 seconds)
Published: Fri Nov 13 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.