Advertisement
sanitysama

ffmpeg webm creation cheatsheet

Jun 24th, 2015
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. create a batch file to launch both ffmpeg and a cheatsheet if you have trouble remembering switches or prefer to use notepad as a scratchpad:
  2. start notepad "C:\webm cheatsheet.txt"
  3. cmd /k "cd /d C:\Program Files\ffmpeg\bin && cls"
  4.  
  5. # dump subs. dumps full subtitle file.
  6. ffmpeg -i "file.mkv" -an -vn -c:s copy C:\sub.ass
  7. ## hardsubbing
  8. ## 1) dump subs at the input timecode, trimming the subtitle file to just the portion that you want
  9. ffmpeg -ss 10:00:30 -i input.mkv -t 20 -vn -an -c:s copy C:\sub.ass
  10. ## 2) encode the video with input subtitle file location set
  11. ffmpeg -ss 10:00:30 -i input.mkv -t 20 -c:v libvpx -b:v 1M -an -vf subtitle=C:\sub.ass C:\output.webm
  12. # 2-pass encoding
  13. ffmpeg -i FILE.EXT -c:v libvpx -pass 1 -f webm null
  14. ffmpeg -i FILE.EXT -c:v libvpx -pass 2 -f webm C:\bokunopico_2pass.webm
  15. # gif > webm
  16. ffmpeg -i "" -c:v libvpx -crf 4 -b:v 500K C:\.webm
  17. # dump meta
  18. ffmpeg -i input_file -f ffmetadata C:\metadata.txt
  19. # add meta
  20. ffmpeg -i input_file -i C:\metadata.txt -map_metadata 1 output_file
  21. # some switches
  22. -i "C:\path\file.avi" : input file
  23. -ss : timecode to seek to and start encoding at (see seeking mode examples below)
  24. -t : duration of output video in seconds
  25. -to : timecode to stop encoding at. used with -ss. cannot be used when -t is set. unreliable. use -t
  26. -f : output format. not necessary to set most of the time.
  27. -framerate : frames per second. low framerates [1-5] make the video impossible to accurately seek through.
  28. -fs : sets an output filesize value in bytes. video will stop encoding at this value, cutting your clip short if necessary.
  29. -sn -an -vn : ignore subs/audio/video
  30. -mb_threshold : does something
  31. -crf 0 : 4-63 lower is better quality
  32. -qmin 0 -qmax 50 : variable quality. unnecessary.
  33. -threads : for multi-threaded processors. if you do not know what to set this value to, do not use it. can lead to bluescreens.
  34. -c:v libvpx : sets video codec. webm codec is libvpx
  35. -b:v [n][KM] : video bitrate. value in bits/kilobits/megabits. ex: 1/1K/1M. bitrate formula for a 3MB target filesize: -b:v 3*8388608/N*0.975 (replace N with runtime in seconds)
  36. -c:a libvorbis : audio codec. unused for 4chan webms
  37. -b:a:nnn
  38. -vf scale=-1:480 : sets the scale. [width]:[height]. -1 will automatically calculate its value based on the other value (preserves aspect ratio)
  39. -vf crop=w:h:x:y : -vf crop=1280:544:0:88 protip: screenshot your video and edit it in paint to find these co-ordinates if you must crop
  40. -vf subtitles=sub.ssa : sets subtitle source. if no path is set it is relative to location of ffmpeg.exe
  41. -metadata author="%artist%"
  42. -metadata title="%album%" : some forks of 4chanx can extract metadata. always fill this in with the source name or link to where you found it.
  43. -y : yes to overwrite file prompt (useful when tweaking bitrates)
  44.  
  45. #chaining crop/scale/subtitle commands. simply use a comma
  46. -vf crop=1280:544:0:88,scale=-1:480
  47.  
  48. #accurate seeking mode (slow)
  49. ffmpeg -i "file.avi" -ss 00:10:00 etc etc
  50.  
  51. #quick seeking mode (eliminates an initial pause while encoding as ffmpeg has trouble seeking through long, large video files)
  52. ffmpeg -ss 00:10:00 -i "file.avi" etc etc
  53.  
  54. protip: windows users can shift+right-click a file > copy as path to get a full path to the file, quotes included, copied to the clipboard.
  55. protip: use CTRL+G in MPC-HC to copy millisecond-accurate timecodes.
  56.  
  57. #blank command. fill this in and get started making those weebums.
  58. ffmpeg -i -vf scale=-1:480 -c:v libvpx -b:v 3*8388608/*0.975 -metadata title="" -an -y -threads 8 C:\.webm
  59.  
  60. #music blank (used for creating sound webms. can accept images instead of video as source)
  61. ffmpeg -i [video/image path goes here] -vf scale=-1:240 -i [audio path goes here] -c:v libvpx -b:v 100k -c:a libvorbis -b:a 128k -y -threads 8 C:\.webm
  62.  
  63. #album preview blank (i use this to create album crossfades from within foobar2k. i won't explain how to create the crossfade here)
  64. ffmpeg -framerate 7 -loop 1 -i -c:v libvpx -i -c:a libvorbis -b:a 96k -b:v 90k -vf scale=-1:512 -shortest -threads 8 -y "C:\ preview.webm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement