All Projects → aerobounce → Trim.lua

aerobounce / Trim.lua

Licence: agpl-3.0
Trim mode for mpv — Turn mpv into Lossless Audio / Video Editor.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Trim.lua

Mpv.net
🎞 mpv.net is a modern media player for Windows that works just like mpv.
Stars: ✭ 737 (+2970.83%)
Mutual labels:  ffmpeg, mpv
Media Autobuild suite
This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.
Stars: ✭ 900 (+3650%)
Mutual labels:  ffmpeg, mpv
FFCreatorLite
一个基于node.js的轻量极速短视频加工库 A lightweight and fast short video processing library based on node.js
Stars: ✭ 155 (+545.83%)
Mutual labels:  ffmpeg, video-processing
Lintel
A Python module to decode video frames directly, using the FFmpeg C API.
Stars: ✭ 240 (+900%)
Mutual labels:  ffmpeg, video-processing
eloquent-ffmpeg
High-level API for FFmpeg's Command Line Tools
Stars: ✭ 71 (+195.83%)
Mutual labels:  ffmpeg, video-processing
Mlt
MLT Multimedia Framework
Stars: ✭ 836 (+3383.33%)
Mutual labels:  ffmpeg, video-processing
Super-Stitch
一款视频超级拼接软件
Stars: ✭ 28 (+16.67%)
Mutual labels:  ffmpeg, video-processing
Vidgear
A High-performance cross-platform Video Processing Python framework powerpacked with unique trailblazing features 🔥
Stars: ✭ 2,048 (+8433.33%)
Mutual labels:  ffmpeg, video-processing
nebula
Media asset management and broadcast automation system
Stars: ✭ 103 (+329.17%)
Mutual labels:  ffmpeg, video-processing
DuME
A fast, versatile, easy-to-use and cross-platform Media Encoder based on FFmpeg
Stars: ✭ 66 (+175%)
Mutual labels:  ffmpeg, video-processing
Ffmpeg Libav Tutorial
FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more
Stars: ✭ 7,074 (+29375%)
Mutual labels:  ffmpeg, video-processing
Mpv thumbnail script
A Lua script to show preview thumbnails in mpv's OSC seekbar, sans external dependencies
Stars: ✭ 350 (+1358.33%)
Mutual labels:  ffmpeg, mpv
Mpv
🎥 Command line video player
Stars: ✭ 17,018 (+70808.33%)
Mutual labels:  ffmpeg, mpv
Vidcutter
Been busy guys, will be reviewing and integrating pull requests shortly. Thanks to all contributors! LATEST RELEASE: 6.0.0 - flatpak @ https://flathub.org/apps/details/com.ozmartians.VidCutter - snap @ https://snapcraft.io/vidcutter - see https://github.com/ozmartian/vidcutter/releases for more details...
Stars: ✭ 775 (+3129.17%)
Mutual labels:  ffmpeg, mpv
Online Video Editor
API based Online Video Editing using FFMPEG & NodeJs for Backend Editing
Stars: ✭ 176 (+633.33%)
Mutual labels:  ffmpeg, video-processing
video-summarizer
Summarizes videos into much shorter videos. Ideal for long lecture videos.
Stars: ✭ 92 (+283.33%)
Mutual labels:  ffmpeg, video-processing
Screen Recorder Ffmpeg Cpp
*Multimedia project* A screen recording application to capture your desktop and store in a video format. Click here to watch the demo
Stars: ✭ 98 (+308.33%)
Mutual labels:  ffmpeg, video-processing
Fwf
HTML video editor with FFmpeg
Stars: ✭ 128 (+433.33%)
Mutual labels:  ffmpeg, video-processing
video-audio-tools
To process/edit video and audio with Python+FFmpeg. [简单实用] 基于Python+FFmpeg的视频和音频的处理/剪辑。
Stars: ✭ 164 (+583.33%)
Mutual labels:  ffmpeg, video-processing
Boram
🎞 Cross-platform graphical WebM converter
Stars: ✭ 312 (+1200%)
Mutual labels:  ffmpeg, mpv

✂️ trim.lua

mpv script to create a "precise" clip of audio / video files without transcoding.

❓ Differences from the other similar scripts

  • trim.lua is aimed only for extraction of clips with no-transcoding. Encodings will never be occured.
  • Without encoding, video trimming becomes tricky.
    • Without transcoding, points you can specify to trim is limited to keyframes.
    • Tested several softwares on macOS and as far as I know there is no software that can do it accurately. Well, there is, but none were perfect nor lightweight.
    • This script is here to achieve accuracy as much as possible — Making a clip from a file within minimum keyframe distance, without transcoding.

In short, trim.lua turns mpv into a simple lossless audio / video editor.

📦 Install

# macOS, *nix
curl https://raw.githubusercontent.com/aerobounce/trim.lua/master/trim.lua >> ~/.config/mpv/scripts/trim.lua
  • If your shell has PATH to ffmpeg you're ready to use.
    • If not, rewrite ffmpeg_bin accordingly.
  • All Windows users likely have to specify full path to ffmpeg.
    • Or copy the standalone binary into the script directory (not tested).

trim.lua

-- macOS, *nix
ffmpeg_bin = "ffmpeg"

-- Windows
ffmpeg_bin = "ffmpeg.exe"

⚠️ Requirements

  • ffmpeg

✂️ Usage

Enable trim mode

  • h or k

If initialized with h, default trim positions will be: Current time position to End of file.
If initialized with k, default trim positions will be: Head of file to Current time position.

Toggle strip metadata mode (After initializing trim mode)

Stripping metadata can fix certain corrupted files.

  • t

Save Trim Positions

To write out a clip, press either of the keys twice with the same start / end position.
To quit Trim Mode, close mpv instance.

  • h Save Trim Start Keyframe
  • k Save Trim End Position

Seeking

Seek to saved positions

  • shift + h Seek to the saved Trim start position
  • shift + k Seek to the saved Trim end position

With video file

  • LEFT Seek backward by keyframe (Minimum distance)
  • RIGHT Seek forward by keyframe (Minimum distance)
  • UP Seek forward by keyframe (Larger distance)
  • DOWN Seek backward by keyframe (Larger distance)
  • shift+LEFT Seek backward exactly by seconds (-0.1 seconds)
  • shift+RIGHT Seek forward exactly by seconds (0.1 seconds)
  • shift+UP Seek backward exactly by seconds (0.5 seconds)
  • shift+DOWN Seek forward exactly by seconds (-0.5 seconds)

With audio file

  • LEFT Seek backward by seconds (-1 seconds)
  • RIGHT Seek forward by seconds (1 seconds)
  • UP Seek forward by seconds (5 seconds)
  • DOWN Seek backward by seconds (-5 seconds)
  • shift+LEFT Seek backward by seconds (-10 seconds)
  • shift+RIGHT Seek forward by seconds (10 seconds)
  • shift+UP Seek forward by seconds (30 seconds)
  • shift+DOWN Seek backward by seconds (-30 seconds)

ℹ️ To create a valid video file

  • Beggining of the trim position must be a keyframe.
  • End position can be any point.

🗜 Concat with ffmpeg

After splitting, you can concat them with a script something like this.

CLIPS=("example_1.mp4" "example_2.mp4")
DESTINATION="concat_example.mp4"

ffmpeg \
    -hide_banner \
    -loglevel verbose \
    -f concat \
    -safe 0 \
    -auto_convert 0 \
    -err_detect ignore_err \
    -i <(
        while read -r; do
            echo "file '$REPLY'"
        done <<< "${CLIPS[*]}"
    ) \
    -copy_unknown \
    -map_chapters 0 \
    -c copy \
    "$DESTINATION"

Known Issue

  • Any embedded media other than video / audio will be lost, such as embedded subtitles. This will unlikely be fixed.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].