Advertisement
Braingame

How to make webms

Dec 16th, 2017
1,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. This is a small collection of posts, regarding the creation of webms, that I posted on /gif/ over the course of the last few weeks. Each of them was a reply to a certain problem/question, but I tried to keep them as generic as possible.
  2.  
  3.  
  4. Overall:
  5. ~~~~~~~~
  6.  
  7. There's a ton of information out there on how to make webms with VP8/Vorbis codecs. You just need to look for it.
  8. Start with getting a pre-compiled ffmpeg.exe (because I somewhat doubt you'd have trouble finding out how to make webms, when you're able to compile it yourself). For Windows us the version from https://gitgud.io/nixx/WebMConverter (since the current builds advertised by ffmpeg on zeranoe.com don't have the libvorbis library included)
  9.  
  10. >https://pastebin.com/4ipnGRND
  11. The absolute basics of using ffmpeg to make webms
  12. >https://wiki.installgentoo.com/index.php/WebM
  13. More extensive overview over the basics
  14. >https://postimg.org/image/5fr19jeqf/
  15. Step by step guide on how to make webms (very detailed)
  16. >https://trac.ffmpeg.org/wiki/Encode/VP8
  17. The different ways to adjust the bitrate with the VP8 encoder
  18. >https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio
  19. Basic guide how to encode audio with ffmpeg
  20. >https://ffmpeg.org/ffmpeg-codecs.html#libvorbis
  21. Available options for vorbis
  22. >https://ffmpeg.org/ffmpeg-codecs.html#libvpx
  23. Available options for VP8
  24.  
  25. You can also use the ffmpeg documentation to look up available filters, etc. Since it's also pretty popular you'll often find a solution online if you encounter a problem.
  26.  
  27. If that's too much work for you, then don't just download the ffmpeg.exe from the first link, but the whole thing. It's the successor of "Webm for retards" and includes a GUI for ffmpeg. It allows you to either make basic adjustments or work with advanced command line options, but it's limited by not giving you the option to specify several input files. Also it only allows you to make webms, while the included ffmpeg build is capable of much more.
  28.  
  29.  
  30. Lower filesize:
  31. ~~~~~~~~~~~~~~~
  32.  
  33. >lower video bitrate
  34. Main way of cutting down the size
  35. >change VP8's bitrate mode
  36. There are basically 3 bitrate modes that VP8 has to offer. I'm going to ignore constant quality though, as it's unsuitable to produce webms with a certain file size. That leaves us with the variable bitrate (VBR) mode and the constant bitrate (CBR) mode. VBR: -crf 10 -qmax 50 -b:v 1M | CBR: -minrate:v 500K -maxrate:v 500K -b:v 500K (it's important that all numbers match with CBR). Additionally the qmax option (min. crf value that each frame must reach) can have a serious impact on the file size, as it leads to a certain minimum size that cannot be lowered, so I tend to look at VBR without the qmax option as seperate bitrate mode (although it isn't really).
  37. To summarize: If you use -crf 10 -qmax 50 -b:v 100K, -crf 10 -b:v 100K and -minrate:v 100K -maxrate:v 100K -b:v 100K in this order, you'll most likely get a webm that becomes smaller with each try.
  38. >lower audio bitrate
  39. Only when you want to make very long webms (we're talking about >2 minutes). Otherwise try sticking with 96kbps. That gives a decent quality with vorbis.
  40. >lower resolution
  41. The effect depends on what encoding method you use for the video stream (see https://trac.ffmpeg.org/wiki/Encode/VP8 for more details). When working with crf values you'll notice a bigger difference. However you can lower it in all cases to increase the quality of your webm, since the same bitrate will look better with a smaller resolution.
  42. >lower framerate
  43. Especially powerful, when you want a static image as your video. You can lower the framerate to 1fps and decrease the filesize to a minimum. Only be careful to adjust the keyframe interval manually (with the -g option when using ffmpeg) or you could experience playback issues with some media players.
  44. >trim your source material
  45. Depending on what your source material is showing you can fit more or less in the 4MB limit. A lot of camera movement will lead to bigger files and you'll notice compression artifacts sooner in darker scenes. When all of the above points don't help (or the output just looks too bad to post) then try to shorten the clip you want to convert.
  46. >use a postprocessing filter with ffmpeg (see https://trac.ffmpeg.org/wiki/Postprocessing for more details)
  47. These filters are used to counteract compression artifacts somewhat. They make low quality video footage smoother (or blurrier if you overdo it), but remove details as well. If you're only a bit over the 4MB limit you can try to apply such a filter instead of lowering the bitrate further. It can also make your webm look better, when you work with low bitrates.
  48. >use a denoise filter
  49. In my experience only viable if you work with short, high quality webms, where the bitrate is high enough to even depict noise from the source material. There are several denoise filters available in ffmpeg (just search for denoise in their filter documentation: https://ffmpeg.org/ffmpeg-filters.html), but personally I stick with the hqdn3d denoise filter, because it's the only one where I understand what the input options do. For more infos look at this guide: https://mattgadient.com/2013/06/29/in-depth-look-at-de-noising-in-handbrake-with-imagevideo-examples/ (it's about denoising with Handbrake, but focuses on the hqdn3d filter).
  50.  
  51.  
  52. Make webms with a static picture as video:
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54.  
  55. Vorbis delivers decent results at 96kbps (http://listening-test.coresv.net/results.htm for anyone interested), so I'd try to stick with that, but /gif/ isn't really filled with audiophiles, so if necessary you can go lower.
  56. Also don't worry about the video bitrate. Set the framerate to 1fps and give the VP8 encoder some high bitrate to work with (~1mbps). It'll never use as much if you work with the variable bitrate mode, but gives the encoder the freedom to take the bitrate that is needed to reach the specified crf value. Actually, now that I think about it, the same results should be accomplished by only using crf values, but don't quote me on that.
  57.  
  58. Now the size of your video stream mainly depends on two things: The resolution and the keyframe interval (specified with -g when using ffmpeg; default for VP8 is 128 frames). A maximum keyframe interval produces a minimum filesize, but it can lead to playback difficulties for some media players (e.g. if you use the method above, but don't specify a custom keyframe interval, then you can start the video at 00:00 and jump forward to 02:08, but nothing in between), so try to find a compromise between keyframe interval and resolution to fit the 4MB limit.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement