website/content/blog/trim-video-ffmpeg.md

32 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2022-09-28 18:59:54 -04:00
---
2023-01-25 13:20:29 -05:00
date: 2022-09-28 18:46:32-04:00
2022-09-28 18:59:54 -04:00
draft: false
math: false
2023-01-05 14:04:45 -05:00
medium_enabled: true
2023-01-25 13:20:29 -05:00
medium_post_id: dd83a32af440
tags:
- Audio-Video
title: How to trim a video using FFMPEG
2022-09-28 18:59:54 -04:00
---
2022-12-17 23:48:56 -05:00
Recently I came across a video that I wanted to split up into multiple files. Given my love for `ffmpeg` the video/audio swiss army knife, I knew there had to be a solution for cutting a video on the terminal. Luckily on [AskUbuntu](https://askubuntu.com/a/56044), Luis Alvarado provides a command snippet. This post will go into slightly more detail on the flags used in the command
2022-09-28 18:59:54 -04:00
```bash
ffmpeg -ss 00:00:00 \
-t 00:30:00 \
-i input.mp4 \
-vcodec copy \
-acodec copy \
output.mp4
```
| Command | Description |
| --------- | ------------------------------------------------------------ |
| `-ss` | Position within the input file. Most file formats do not allow exact seeking, so ffmpeg will pick the closest seek point. Format is in *time duration* notation. |
| `-t` | Limits the duration of data read from the input file. Format is in *time duration* notation. |
| `-vcodec` | Format used to transcribe the video. Use `copy` to not transcribe to a different format. |
| `-acodec` | Format used to transcribe the audio. Use `copy` to not transcribe to a different format. |
Time duration notation follows the format `<HH>:<MM>:<SS>` where `HH` is the number of hours, `MM` is the number of minutes, and `SS` is the number of seconds.
For this command in general, the output video length would be the same time duration as specified in the `-t` flag.