Skip to content

Instantly share code, notes, and snippets.

@fernandoherreradelasheras
fernandoherreradelasheras / smart-video-cutter.sh
Created February 26, 2022 17:01
Smart video cutter with minimal transcoding using ffmpg
#!/usr/bin/bash
#
# Cut a fragment of a video with the minimal possible re-encoding.
# If the new start point is not a key frame it reencodes the video
# from that point until the frame before a new keyframe. The remaining
# part is copied as passthrough and both fragments are concatenated
#
# In order to make the video streams compatible we use the same codec
# and bitrate. This works fine with h264. No idea about other codecs
@agyild
agyild / NVScaler.glsl
Last active March 20, 2026 02:49
NVIDIA Image Scaling v1.0.2 for mpv
// The MIT License(MIT)
//
// Copyright(c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files(the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions :
@agyild
agyild / FSR.glsl
Last active March 29, 2026 21:23
AMD FidelityFX Super Resolution v1.0.2 for mpv
// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@agyild
agyild / CAS-scaled.glsl
Last active March 5, 2026 21:02
AMD FidelityFX Contrast Adaptive Sharpening v1.0.2 for mpv
// LICENSE
// =======
// Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved.
// -------
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// -------
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
@bitingsock
bitingsock / rewindPlaylist.lua
Created September 6, 2021 10:35
keybind to rewind to the end of the previous playlist entry
local optStart = 0
function seekHandler(duration)
if mp.get_property_number("playlist-pos") > 0 then
optStart = mp.get_property("start")
mp.set_property("start", duration)
mp.command("playlist-prev")
end
end
mp.register_event("file-loaded", function() mp.set_property("start", optStart) end)
@bitingsock
bitingsock / stopCache.lua
Last active July 15, 2023 06:14
stops the demuxer from downloading more if it is already past --end
local maxBytes = mp.get_property("demuxer-max-bytes")
local function stopCache()
local state = mp.get_property_native("demuxer-cache-state")
if state and state["cache-end"] and tonumber(state["cache-end"]) > tonumber(mp.get_property("end")) then
mp.set_property("demuxer-max-bytes",0)
print("stop")
mp.unobserve_property(stopCache)
end
end
local function look()
@bitingsock
bitingsock / ytdl-preload.lua
Last active February 9, 2026 02:39
Precache the next entry in your playlist if it is a network source by downloading it to a temp file ahead of time. Change Line 20 to temp directory. It will delete the directory on exit.
----------------------
-- #example ytdl_preload.conf
-- # make sure lines do not have trailing whitespace
-- # ytdl_opt has no sanity check and should be formatted exactly how it would appear in yt-dlp CLI, they are split into a key/value pair on whitespace
-- # at least on Windows, do not escape '\' in temp, just us a single one for each divider
-- #temp=R:\ytdltest
-- #ytdl_opt1=-r 50k
-- #ytdl_opt2=-N 5
-- #ytdl_opt#=etc
@bitingsock
bitingsock / audio-dupe.lua
Last active November 15, 2024 21:25
Runs a child process to play a second audio stream. Synced through named pipe. Recommend using with [cycle-adevice](https://gist.github.com/bitingsock/ad58ee5da560ecb922fa4a867ac0ecfd) to change the output device of the parent process.
--New child with start with the current 'aid' and 'audio-device' of the parent
-- non-Windows environments require the use of the 'socat' package
local platform_is_windows = (package.config:sub(1, 1) == "\\")
local options = require 'mp.options'
local o = {
pipe_template = platform_is_windows and "\\\\.\\pipe\\mpvDupedAudio" or "~/mpvDupedAudio", --windows format
new_child_key = 'Ctrl+A', --Start a new child: 'Ctrl+Shift+a'
cycle_child_control_key = 'Ctrl+Alt+A', --Cycle child control: 'Ctrl+Shift+Alt+a'
cycle_child_aid_key = 'Ctrl+Alt+a', --Cycle 'aid' of child: 'Ctrl+Alt+a'
child_increase_volume_key = 'Ctrl+Alt+WHEEL_UP', --Change volume of child: 'Ctrl+Alt+wheel'
@richardpl
richardpl / drcbox.lua
Last active June 30, 2025 05:24
dynaudnorm filter with visual feedback
--[[
mpv dynaudnorm filter with visual feedback.
Copyright 2016 Avi Halachmi ( https://github.com/avih )
Copyright 2020 Paul B Mahol
License: public domain
Needs mpv with very recent FFmpeg build.
Default config:
@ChuckMichael
ChuckMichael / vcredistr.md
Last active April 27, 2026 08:28
Visual C++ Redistributable Packages