 OK, first thing on the command line, let's download a file. Wget is a program to get a web page. Web page, get. And we pass as a parameter a URL. You need to know the URL. I know some. And well, do I? Maybe I'll just copy and paste from the web browser, so I don't make a mistake. Wget some URL, a HTML file, in this case a PDF file. All it would do is download that file and save it on my hard disk. Yep, take some time to get started. Print some status information and says, 100% complete. I downloaded the Bitcoin lecture slides from one of our earlier workshops. And if we do an LS, we should see bitcoin.pdf there. So very simple. Download a particular file from a website with Wget. Useful if you want to include inside scripts. Maybe your script relies on some web page or some program on a web server. You can download it automatically in the script. Useful for other things, so automatically downloading many web pages. I will not do it. I don't have the exact syntax. But there are many options for Wget which will allow it to download a HTML file, automatically look for all the links inside that file, and download those links. And then download those links and so on. So it can act like a spider and download many web pages automatically. We may see an example towards the end. Let's download another one while we're here. Which one? Internet privacy. So we have two PDFs. I've got two PDFs. Let's do something with those PDFs. Let's combine them. PDFTK is a program that does, I say, basic manipulation of PDF files, combining, splitting, a few other operations. PDFTK, the two files, it's going to wrap around. And then take those two files and concatenate them. So the operator is cat. And output, a new file. PDFTK, the two files that we want to combine, concatenate. And then we tell PDFTK to cat. Cat is short for concatenate. Concatenate the two files. And output to some new file, new.PDF. It should just return to the prompt. No output if there are no errors. Now, open the new file. I will not do it here, but you can do it from your desktop. Or to start the PDF viewer, evince, evince new.PDF. Evince is the PDF viewer on our operating system. Instead of Acrobat Reader, we have evince. Press Enter. I will not press Enter because I'm logged into another computer. It won't work. But you can. Evince, new.PDF, it should open up your PDF Reader. And it should contain the lecture slides for both of those topics. One concatenated after the other. Evince. Evince is a PDF Reader. So you may have Acrobat Reader. You have, what else, Foxit Reader. Evince is another one. I'll let you look at this PDF. I will not. Just a couple of other examples with PDF.TK before we move away from that. The man paid for PDF.TK is quite short, but very good. Let's give a couple. A equals, we can use some labels for files. A is our internet privacy options PDF. B is our Bitcoin PDF. So we don't have to refer to their full names. I can refer to A and B. Concatenate the two. Take the first page of file A, A1. The first to the second page of file A, A1 to 2. Rotate them. Which direction? West. 90 degrees to the west. That's what W means. Rotate 90 degrees to the west. And take, this is just an example. It's not very useful. The first two pages of file B, rotate them to the east and output some other PDF. So here, just illustrating that we can select the individual pages from those input PDFs. We can use shortcuts. Say A equals this input PDF. B equals Bitcoin.PDF. Cat means combine the two. But don't combine all of them. For file A, take pages 1 to 2. W means rotate those pages 90 degrees to the west. That way. Count a clockwise. And for file B, take the first two pages and rotate them 90 degrees to the east. And then output a new file. And then you look in the new file and just check if it did it work. I will not open it. You need a space PDF.TK at the start. Oh. Sorry, let me show the command at the top so it's a bit clearer. The PDF toolkit combines and selects pages from those two input PDFs. Open it up and just check. Press Enter. Press Enter. Oh, you're on someone else's screen. Okay, you're right. I'm confused. Good. Why would you want to manipulate PDF files on the command line? Again, if you want to automate things. One example I've used it for is I scan in everyone's exam. Thousands of pages to scans. And then use PDF.TK to separate them out per student because every student's exam has the same number of pages. Rotate the pages or if you scan the front pages first and then scan the back pages second, then PDF.TK can combine them, shuffle them correctly, can do other things that are useful if you have scans or if you need to automatically process different PDF files. I will not go through any more examples. There's a few more on the website. It can do things like if you look at the man page for PDF.TK, the man page is quite good. Merge PDF documents, split them, rotate, decrypt, if there's a password in some cases, not all cases, encrypt, fill in PDF forms, again in some cases. Some PDF files actually forms where you can type stuff into them. Apply a watermark, a background watermark over the top of a PDF and a few other things. Extract some data from those PDF files. Let's move beyond PDF and let's go to video. I know you've all been waiting to watch the video on your desktop. I'm gonna delete my PDF files. I don't need them. RM for delete or remove. Be careful when you delete things. That is, again, there's no trash or recycle bin. It's gone. I shouldn't tell you this, but RM has a recursive option. RM minus uppercase R. Means delete this and the subdirectories. So RM minus uppercase R star means delete everything in this directory and all its subdirectories and all its subdirectories and so on. Don't do that. Especially start from the top directory, the root and delete all its subdirectories. That is, delete the entire file system. Don't do that. Videos. I've downloaded and I think you all have it on your computer, a movie, Tears of Steel. Let's do some processing on this movie and we're gonna use software called FFmpeg. FFmpeg is a standalone program for processing video and also provides libraries which many other programs use. So many websites, if they have some video processing, may use the FFmpeg library and many other programs that display video may use the FFmpeg libraries. To get the things that we want in our demo, I had to install FFmpeg and compile it from the source code. So I had to set it up to do the things that we want. So that's a bit of a time consuming task. It's not too hard. That's why you see this FFmpeg build directory. It contains the code after the compilation and the bin directory contains the actual executables for FFmpeg. Let's use it to first look at the, well, why don't you play it? You can use FFmpeg to play video files but normally we use it to process them. There are many media players. One that you have on your computer is VLC, correct? VLC, try it. VLC is just as a media player which also uses the FFmpeg libraries. See if the video plays on your computer. You probably don't have audio. And those speakers, if you bring your headphones, you can listen as well. We will not watch it all. Let me just set up while you're watching. Okay, so you can watch the video. It's a full movie, well, it's a full short movie. But let's do some processing on it. And in fact, to process videos, you need to know a little bit about what is a video. So that makes things a little bit more confusing. Let's have a look. First thing we'll do is look at some information about that file. Let's use FFpro, which is a part of FFmpeg but just gives us info about the file. And then the file name, Tears of Steel, FFpro. Press Enter and you'll see a whole lot of output. Mine's scrolled through again. FFpro, followed by the file name. At the top, you cannot see it on my screen, but at the top it shows some information about the version of FFmpeg. Not so useful for us. Then it shows, I think, from here onwards, input, it shows something about the file. And the things that we're gonna focus on is if you go to the bottom, we have two streams. Remember, video or movie is not just video. It's video plus audio. And they're separate streams. So it says there are two streams inside this file. One is a video stream. Stream zero, zero is a video stream. And it uses a codec which converts the video information into binary called H264 and some other color information. And the resolution of the video, 1280 by 534, 24 frames per second and some other information. The second stream is audio, so the soundtrack, using the codec AAC to convert the sound into binary as some sampling frequency of 44,000 Hertz, using stereo audio, so two channels. So it tells us something about the streams inside this file. What's the format of this file? Again, what is the format of this file? MKV, so the format or sometimes called a container. That's the structure in which we include the streams. So this is MKV or Matroska is the name. So the extension MKV, that's the format of the file. But inside this file, there are in fact two streams, an audio and a video stream and they use different codecs. That is the video codec is H264 and the audio codec AAC. It's confusing sometimes that we often need to distinguish between the format, usually from the file extension, but not always, but the format and the codecs used for the streams inside that file. We'll come up as we go. All right, so we know information about the file. Let's do something with it. How long is the movie? Did it say somewhere? Duration, it's a short movie, 12 minutes, 14 seconds. So we know the duration. Let's split it and just grab maybe 20 seconds from that movie. So we use FFMpeg. We want to start, so the movie starts at time zero. We want to cut part of that movie, let's say starting at time 50. And I just did this yesterday as an example, so we'll repeat it. S dash SS, let's go to the top. So if you're looking on the screen, you can see it easier. SS is the start time. Let's get it right. Zero hours, what have I done wrong? Zero hours, zero minutes, 50 seconds. So start 50 seconds into the movie. The input file is our movie file, tears of steel. Don't get confused with the other one which is a stereo audio only file. And duration that we want to take of this file minus T is 20 seconds. Just so we get a short part of the movie. That is, I want to grab just from time 50 seconds to time one minute 10 seconds of the movie and put it into another file. Maybe you want to make a clip or something. And we're going to take the input file and videos and audio files use a particular codec to convert that into binary. Convert the original input into binary, the codec. This one we saw use H264. We take the input file, which uses H264, and the output file that we want to create, we want to use the same codec. We don't want to change it. Later we will change. So we'll just copy. So when we specify the video codec, we use the same as the input. So it's a V codec copy. And the audio codec, we will not change. We will copy from the input. So these parameters are telling us how to create the output and then the name of the output file. Tears of steel, whatever you want to call the file. TOS. MKV, not MKS. Try, press enter. If I got it all right. This may take a second or so. If there's an error, it usually prints a color coded message on this terminal red or something. So if you don't see red, you're okay. So it really just processes the file and cuts for 20 seconds out of that movie from the 12 minutes down to 20 seconds. So we now have another file. We can probe the new one. FF probe on the output file. And we see what? The duration is now 20 seconds. Same video codec, same audio codec. You can play it if you like, just to check. You should have just 20 seconds of video. I will not play it on my computer because I'm logged into another one. If you see red, then there's a syntax error. I'll show it again, the command, just so it's clear. That was the command I used. Dash v codec, dash a codec, mk, mkv, not mpk. Unable to find, so check the syntax exactly here. Minus v codec, minus v codec. It's very confusing, the syntax sometimes and some of these options. Run, just run ffmpeg by itself. Just ffmpeg. This computer, 29, doesn't have the latest update. Try this one, or this one. I don't know why, but maybe I didn't update that one correctly. Work, or maybe path. Okay, we'll fix it here. Okay, now I think you're fixed. Okay, the path was wrong. So it didn't convert anything, it just cut in this case. It's quite fast, less than a second to do that. Conversion, maybe more time consuming. Who's messing with my terminal? Let's convert, very easy to convert. We will convert just the small 20 second clip. Conversion in some cases may be very slow. You need to decode and encode and that may be slow, especially on these old computers that are three or four years old. We're getting new ones next month, okay? So do what you like with them today. We're gonna re, get new ones next month. But let's convert and we'll just do it on the short 20 second clip. Input minus i. And then specify the output. But what do we, so I wanna convert my mkv encoded or my mkv format file, which has H264 video and AAC audio. I wanna convert it into a different format. Well, let's try. What's another format? Anyone? mkv, mp4? Try mp4. So that's it. If this works, we'll see. Take this input file and produce this output file. And in many cases, ffmpeg will check the output extension and determine automatically what format you want, mp4, and what codec to use. Sometimes you must specify the exact codec, but in the most common cases, it works automatic. Should run, it may take a while, okay? Do it only on the short file. This is on the 20 second clip. Done. A few seconds. If you do it on the 12 minute clip movie, you'll be waiting a long time. Let's probe that file, the output file, just to check what we got. ffprobe, our tos.mp4. The input, the format now is listed as all of these. They're all related or I think all the same, but it's mp4 format. I did that. The video stream, H264, so I think it's the same codec. There may be some different parameters, but it was re-encoded. And the audio, AAC. So in fact, it's using the same audio and video codec, but just a different container. And that's common with videos. That is, the video and audio are encoded the same, but the container file, the one that combines them together is different. mp4 versus mkv. And in fact, converting between them is not too hard in that case. Let's convert a couple of others. Any other containers? Older style videos? AVI, AVI. I've tried WebM, it's a web format. Optimized for some web streaming or web pages. WebM, AVI, mp4, mkv, are different formats. Some will be faster than others. Some require different algorithms to encode the video, which are faster than others. This one's doing about 10 frames per second. It's quite slow. So really, if you wanna convert videos, you need to know something about what containers mean or what formats are, and also the codecs used for video and audio to choose the right one. Have a look at the file sizes. Compare the file sizes and maybe even run FF Probe on each of those just to see the different codecs used. So my mkv. A nice option for LS is LS minus H. H for human-friendly. The sizes are human-friendly. So normally the sizes are given in bytes. If you include the minus H option, you get them in megabytes, gigabytes, kilobytes, and so on. A little bit easier to read. mkv, 6.6 meg, mp4, 3 meg, AVI, 1.9, WebM, 732k. Different codecs produce different quality video and audio, and as a result, you get different size files. Generally, the smaller the size, the lower the quality. But not always. Some codecs can produce the same quality with smaller sizes. And FFmpeg supports many different formats and codecs. Let's compare two. The mkv original file used H.264 as the video codec, AAC as the audio codec. The WebM container or format used VP8 as video and Vaubus as audio. So it had to re-encode the audio and video using different codecs, different algorithms. If you wanna see the codecs and formats supported by FFmpeg, FFmpeg minus formats, will show you all the containers like AVI, mkv, mp4, and all the ones that supports. And there are many. Some very old, some hardly ever used, but it supports many different formats. Some you'll recognize. And codecs are the way that audio and video are encoded and decoded. You can see the list of codecs it supports, including mp3, the ones we saw, the VP8, H.264, H.265, and many others. I will not show it, you can have a look. What about, is that a question? Questions? You may ask. Let's extract the audio from the movie. Extract just the audio stream from that movie. Remember, there are two streams. If we do an FF probe of our original clip, the 22nd clip, video stream using H.264, audio stream using AAC. Maybe we just want audio for some reason. FFmpeg, input, our mkv file, video, none, or null. So the shortcut there is minus VN. We don't want the video as output. Audio output, copy. Okay, so we'll take the movie as input. Two streams, video stream, we don't want to copy. So minus VN saying null for the video stream. Audio codec, copy from the input. That is used the same codec for the audio. And then you specify the output file name. Maybe TOS, audio, dot, dot what? What extension should we use? mp3, are we using the mp3 codec? What was the input codec? The audio codec was AAC, okay? mp3 is another codec. AAC is a different one. There are many different audio codecs. It's not mp3. Well, you don't see it very often. What about AAC? Yep, next command we will. So just repeat that command. It happens quite quick. Take the input file, minus VN, null video, no video. I don't want video. Audio codec, copy, and the output file. The next thing is, okay, what if you do want mp3? Let's repeat that command, but also convert at the same time. So again, same input. VN, audio codec, mp3. And with mp3, you can have different quality. How do we specify quality in mp3? Sometimes you may have heard of different quality mp3 files. What's the measure? Bit rate, so you may have 128 kilobits per second, 256. Let's do a simple one, 64 kilobits per second. Sorry, minus AB, I'll get it on the same line. Minus AB, audio bit rate to be 64K. And now an mp3 extension. So take our input video, don't grab the video. Take the input movie, I'll call it. Don't grab the video. The audio codec, convert it to mp3 and use audio bit rate 64 kilobits per second. And done, and you can check and see if it plays. See it mapped the AAC input audio to mp3 output audio. Bit rate, 63.9 kilobits per second. And of course with different codecs and different bit rates you'll get different file sizes and different quality. So quite easy to extract the audio from a movie and convert it to a particular format that you desire. Of course we can also convert, what have we got? We could take the AAC as input and convert it to a different format. I don't know. WMA, okay. So similar way that we can convert videos, we can convert audio only files. Take the audio file, input audio file output and usually FFMPEG will determine based upon the file extension what codec to use. So here I selected WMA, the Windows Media Audio. And it runs I hope and then so the command I used to create a different audio output. In some codecs you may need to specify options. So with mp3 I specify the audio bit rate. The default may have been I think was 128 but I set it to 64. So depending on what you want as an output there are many different options that FFMPEG provides. And that's when it gets complex. This command is easy, input file, output file. If it works good but if you want to do something a little bit more peculiar then you need to maybe learn some of the options which become more complex and which I don't know. So you'll need to read the main page. What's next? Any questions on video? We're going through quite fast. Again, the intention is that you will be aware that FFMPEG exists, PDFTK exists, WGET exists and maybe if you need it for your task to learn a little bit more about them in your own time to use them for what you need it for. We cannot teach you everything. Questions? We have a plan to finish at three. I'll be here but maybe we'll just do one more thing and then we can do as you wish. But any requests for this last one more thing? Any requests, what we want to do regarding to so we can keep converting audio and video, we can, what have we missed? Scroll down. Screencasts, record audio from microphone. And we don't have a microphone. I do, you don't. Let's try the last thing as a screencast.