mpv config mainly for webm making
 
 
Go to file
pta 8a11eeda76 Disable crop area's default frame to make its precise edges visible
Adds crop.lua's documented configuration file to mpv's script-opts
directory
2023-08-22 15:21:49 -04:00
script-opts Disable crop area's default frame to make its precise edges visible 2023-08-22 15:21:49 -04:00
scripts Rename condition branch for clarity and organize variables 2023-08-22 13:41:59 -04:00
README.md Improve documentation in README.md 2023-08-22 14:33:40 -04:00
input.conf Add crop.lua 2023-07-31 12:17:44 -04:00
mpv.conf Add ab-loop points to OSD status message 2023-08-20 18:59:45 -04:00
tv_aliases.sh Make concatvid take argument files on the command line 2023-08-20 19:59:38 -04:00

README.md

4chan webm spammer's mpv config directory

Includes lua scripts for dumping portions of network streams to files, cropping those videos, and, to your clipboard, copying ffmpeg command lines for making webms.

Also, some shell aliases and functions for:

  • making audioless copies of webms
  • concatenating video files that use the same codec
  • converting youtube live stream URLs into their chat window URLs
  • taking screenshots with ffmpeg
  • watching Japanese news channels

Key bindings

Generally used

  • l: set ab-loop points; see mpv man page
  • ,, .: frame stepping
  • a, b: adjust ab-loop points separately
  • s: screenshot
  • O: show playback time, estimated frame number, mouse position, crop filters, and ab-loop points

Save portions of a live stream to disk

  • Ctrl-a: dumps the contents of the demuxer cache that's inside your selected ab-loop to a file in a configured directory. Intended for network streams. No reason to use this on local files since ffmpeg can operate on those. I have "demuxer-max-bytes=128M" in my mpv.conf, which usually keeps the last 3-15 minutes of the stream in memory, depending on the bitrate, so I have that much time to rewind the streams and clip something. Be careful when dumping. If you have the a-point but not the b-point set, it will continuously dump the entire cache up to the present and I haven't found out how to stop it besides closing mpv. Look up ab-loop in the mpv man page for details.

Make webms

  • c: begin crop selection, then select two corners of crop area with mouse
    • arrow keys can be used to make coarse adjustments to crop area
    • alt+arrow keys to make fine adjustments
  • d: remove the crop filter
  • m: toggle mute; excludes audio from generated webm

The next four keys put a string like this into your clipboard.

nice ffmpeg -i 'file:/home/anon/動画/切り抜き/watch?v=MgqP9WWvH0w23082108:55:4545.mkv' -vf crop=749:909:574:51 -c:v libvpx-vp9 -b:v 1555.7355991503k -pass 1 -ss 0.004 -to 6.104 -an -f null /dev/null &&  nice  ffmpeg  -hide_banner -y -i 'file:/home/anon/動画/切り抜き/watch?v=MgqP9WWvH0w23082108:55:4545.mkv' -vf crop=749:909:574:51 -c:v libvpx-vp9 -b:v 1555.7355991503k -pass 2 -ss 0.004 -to 6.104 -c:a libopus /tmp/a.webm; rm -f ffmpeg2pass-0.log

Just paste it into a terminal and run it. Default output file is /tmp/a.webm. Rename it when done. Use on local video files, not on network streams. All of them use ab-loop points, if set, and mute setting. If unset, the a-point defaults to start-of-video. If unset, the b-point defaults to end-of-video. Tip: pause and use the , and . keys to skip frames to the exact loop points you want for the webm, then hit l to set the loop points. Points can be reset separately with a or b keys.

  • Ctrl-s: get ffmpeg command for single-pass encoding. Works only on files
  • Ctrl-d: get ffmpeg command for dual-pass encoding. Works only on files
  • Ctrl-t: like Ctrl-d but covers the ticker on 1080p WNI clips
  • Ctrl-c: get ffmpeg command for stream copying. Works only on files. For copying a clip from a preexisting webm. Doesn't preserve a crop since that requires a re-encode.

Ctrl-d and Ctrl-t restrict the video portion of the result webm to 4chan's 4 megabyte file limit while preserving as much image quality as possible.

I usually run mpv from Dired in emacs, using the openwith package, which calls mpv with the video's absolute path, so the copied ffmpeg command can find the file from any working-directory. Running mpv from the shell sets the mpv's path property to whatever path you used on the command line.

dump.lua

Edit the cache dumps directory to your preferred directory before using.

Similar scripts

https://github.com/occivink/mpv-scripts/blob/master/scripts/encode.lua https://github.com/ekisu/mpv-webm/releases/download/latest/webm.lua webm.lua doesn't work on one of my machines for some reason, and I prefer encoding on the command line anyways, where I can use bash's line editing and history navigation and see ffmpeg's status messages.

crop.lua

Found on https://github.com/occivink/mpv-scripts#croplua. Useful for the rare occasion that I want mpv to show only part of the video. Also now used to crop videos before making a webm. Supports recursive cropping by chaining crop filters, though my webm script works only with filter chains length 0 or 1. To screenshot just part of the video, set a crop first, then press your screenshot key. Only the cropped portion will be screenshot.

Use mpv to stream albums from Youtube Music ad-free

Example:

  1. Go to an album's page. It should be of the form "/playlist?list=" https://music.youtube.com/playlist?list=OLAK5uy_nscRtcc2KZcydiVY7q0feukzm177h8yyw
  2. Run mpv with the quoted URL
mpv 'https://music.youtube.com/playlist?list=OLAK5uy_nscRtcc2KZcydiVY7q0feukzm177h8yyw'

You can even skip songs forwards and backwards like you can with local files using the < and > keys.