Advertisement
foosda

ffmpeg Starter Guide

Aug 27th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. Installing and configuring ffmpeg:
  2.  
  3. This walkthrough will do a better job than me to explain how to install and configure ffmpeg, so just follow it
  4. https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg
  5.  
  6.  
  7. Table of Contents:
  8.  
  9. 1. Basic Command Prompt Navigation
  10. 2. Making Co-op Videos
  11.  
  12.  
  13. 1. Command Prompt Navigation
  14. ffmpeg is a CLI, or command line interface. If you're not familiar with what that means, understand that almost every computer program you've interacted with is has a GUI, or graphical user interface. That means it can be interacted with almost entirely just the mouse. In a CLI, everything you do will be through commands typed with your keyboard. In a Windows environment, that interface will usually be the Command Prompt.
  15.  
  16. If you're on windows 10, the shortcut to open the command prompt is "win-key", type "cmd", then "enter."
  17. It'll open up the command prompt screen usually on whichever currently logged in user's main folder, i.e. C:\Users\yourusernamehere
  18. ffmpeg, if you installed it correctly according to the instructions above, will work if you call it with just an "ffmpeg" command in this command prompt, but unless you have the videos you're planning to work on in the folder it says you're in, you'll have to navigate to that folder where they are, or move them to that folder if you're too lazy to move around the file system with command prompt.
  19. To change a directory (folder), just type the address into the prompt with a "cd" command preceding it.
  20. Example: if I start in "C:\users\andrew", and I want to get to my default downloads folder for my user account, I can just type "cd downloads."
  21. Example 2: if you want to go to another directory (folder), you can just type the whole address in the prompt.
  22. "cd c:\users\andrew\desktop\coopvideos\blah\blah\blah"
  23. If your files are in a different drive than your windows installation, you'll need to change the drive before using a cd command.
  24. Example: if I start in C:, and want to switch to E:, the command is just
  25. "E:"
  26. Once you're in the correct directory, (the folder with the files you want to work on) continue with whatever ffmpeg commands you like.
  27.  
  28. 2. Co-op Videos
  29. I'll be using sloaters' and cheaty's co-op any% pb video to explain the entire process since they're both different heights so I can show how to deal with it.
  30.  
  31. A. Obtain both local recordings of the videos, either having one person send the other their video, or using streamlink or youtube-dl to download the stream vod.
  32. Example: Using streamlink with the command "streamlink twitch.tv/sloatershighlight best -o sany.mp4," and similar for cheaty's highlight, I download the vods.
  33. B. Use avidemux or virtualdub to determine the starting frame of each video to within a hundredth of a second (rounded).
  34. Example: Using avidemux, (opening each file in avidemux and scrolling to the start [the first frame where the missile disappears], you can drag through the timeline on the bottom by left clicking and dragging, and you can use the arrow keys for fine frame control) I determined that the start times of each are:
  35. sloaters' video in his highlight starts at 20.667 seconds, rounded up to 20.67
  36. cheaty's video in his highlight starts at 15.117 seconds, rounded up to 15.12
  37. C. if both videos are the same height, skip this step, otherwise it'll look funky (unless you don't mind, I guess)
  38. Example: Just using the information from avidemux (under File -> Information when the file is loaded), I determined that the heights of the videos are:
  39. sloats video is 720 pixels high
  40. cheaty's video is 864 pixels high
  41. D. cutting the videos to have them line up properly: using the -ss (slow seek, it accurately tells ffmpeg where to start the edited video) and -to arguments to cut the video, unless you use some sort of processing instead of -codec copy it will default cut to the nearest reference frame instead of the exact frame you tell it to. an easy way to force ffmpeg to reencode it is to just add a -crf "X" argument, where "X" is any number between 0 and 51, the lower a number being a higher quality finished product at the cost of larger file size. I STRONGLY recommend you not go below 18 and probably not above 30. I generally do 5-10 seconds before the start time of each video, so just do some quick math to have each video start at the correct time will work fine. There are a LOT of options about how to do this without losing quality or any other such thing. Decide which video will have the audio for the combined file. The video that you decide to not keep audio will require a "-an" argument.
  42. Example: The syntax for the -ss and -to arguments are in hh:mm:ss.xx formats, so using those starting times I found earlier, the fact that they need to be re-encoded (I use "-crf 30" here for that but there are other options) and the fact that I like cheaty's audio better, I know each video needs to be edited with these commands:
  43. sloaters vid: ffmpeg -i sany.mp4 -ss 00:00:15.67 -to 1:00:00 -crf 30 -an sanyedit.mp4
  44. cheaty vid: ffmpeg -i cany.mp4 -ss 00:00:10.12 -to 1:00:00 -crf 30 canyedit.mp4
  45. (this is an odd circumstance because cheaty cut his highlight so its not as long as sloaters' highlight, so the "-to" value is just there to tell ffmpeg to continue the reencode for the rest of the video. ordinarily I would like to do the math to ensure both of the videos will last the whole length of the combined video)
  46. F. Finally we need to combine the videos into a single file with them stacked on top of each other, this is accomplished with the "-filter_complex vstack=inputs=2" argument. this aligns both videos to stack one on top of the other, the first input you write in the ffmpeg command will be on top.
  47. Example: With both of those encodes complete, the only thing left is to combine them. The ffmpeg command will be:
  48. ffmpeg -i sanyedit.mp4 -i canyedit.mp4 -filter_complex vstack=inputs=2 s&c.mp4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement