improve doc

pull/2640/head
Mikael Finstad 8 months ago
parent 251120dd0c
commit 25112052c0
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -88,45 +88,29 @@ The main feature is lossless trimming and cutting of video and audio files, whic
## Example lossless use cases
- Cut out commercials from a recorded TV show (and re-format from TS to MP4)
- Remove audio tracks from a file
- Extract music track from a video and cut it to your needs
- Add music to a video (or replace existing audio track)
- Combine audio and video tracks from separate recordings
- Cut out commercials from a recorded TV show (and re-format from TS to MP4).
- Remove audio tracks from a file.
- Extract music track from a video and cut it to your needs.
- Add music to a video (or replace existing audio track).
- Combine audio and video tracks from separate recordings.
- Include an external subtitle into a video
- Quickly change a H264/H265 MKV video to MOV or MP4 for playback on iPhone
- Import a list of cut times from other tool as a EDL (edit decision list, CSV) and run these cuts with LosslessCut
- Export a list of cut times as a CSV EDL and process these in another tool
- Quickly cut a file by its MP4/MKV chapters
- Quickly cut a [YouTube video](https://youtube-dl.org/) by its chapters (or music times from a comment)
- Change the language of a file's audio/subtitle tracks
- Attach cover art / thumbnail to videos / audio from an external JPEG file or from a frame on the timeline
- Change author, title, GPS position, recording time of a video
- Fix rotation of a video that has the wrong orientation flag set
- Great for rotating phone videos that come out the wrong way without actually re-encoding the video.
- Loop a video / audio clip X times quickly without re-encoding
- See [#284](https://github.com/mifi/lossless-cut/issues/284)
- Quickly change a H264/H265 MKV video to MOV or MP4 for playback on iPhone.
- Import a list of cut times from other tool as a EDL (edit decision list, CSV) and run these cuts with LosslessCut.
- Export a list of cut times as a CSV EDL and process these in another tool.
- Quickly cut a file by its MP4/MKV chapters.
- Quickly cut a [YouTube video](https://youtube-dl.org/) by its chapters (or music times from a comment).
- Change the language of a file's audio/subtitle tracks.
- Attach cover art / thumbnail to videos / audio from an external JPEG file or from a frame on the timeline.
- Change author, title, GPS position, recording time of a video.
- Fix rotation of a video that has the wrong orientation flag set.
- Loop a video / audio clip X times quickly without re-encoding, see [#284](https://github.com/mifi/lossless-cut/issues/284).
- Convert a video or parts of it into X image files (not lossless)
- Losslessly split a video into one file per scene (note you probably have to shift segments, see [#330](https://github.com/mifi/lossless-cut/issues/330).)
- Cut away silent parts of an audio/video
- Split video into segments to for example respect Twitter's 140 second limit
- Cut away silent parts from an audio/video file.
- Split video into segments to for example respect Twitter's 140 second limit.
- Annotate each segment with one or more tags, then use those tags to organize your segments or use it to create an output folder structure or hierarchy for your segments.
### Export cut times as YouTube Chapters
1. Export with Merge and "Create chapters from merged segments" enabled
2. Open the exported file and select "Import chapters" in the dialog
3. File -> Export project -> YouTube Chapters
### Re-encode only the audio track, keeping the lossless video track
First export each track as individual files. Then use Handbrake or similar to re-encode the audio file (if mp4 file, encode as AAC.) Then open the extracted video stream in LosslessCut. The open your encoded audio file and select "Include all tracks from the new file". Then export.
### Advanced multi-step workflows
**Tip:** you can use LosslessCut in multiple passes in order to achieve separate trimming of individual tracks:
1. Open a file an export all tracks as individual files
2. Open the exported track files independently and cut them as desired
3. Add the track back to the video and combine them to one output video
See also [Recipe cookbook](./recipes.md)
## Download

@ -1,6 +1,6 @@
# Batch processing ⏩
I get a lot of questions about whether LosslessCut can help automate the same operation on X number of files. For example given a folder of 100 files, cut off 10 seconds from the beginning of every file, or split each file into 30 second files. LosslessCut was not designed to be a batch processing toolkit and generally cannot not do these things, however the good news is that often it's not very hard to automate with a simple script.
I get a lot of questions about whether LosslessCut can help automate the **exact same operation on X number of files**. For example given a folder of 100 files, cut off 10 seconds from the beginning of every file, or split each file into 30 second files. LosslessCut was not designed to be a batch processing toolkit and generally cannot not do these things, however the good news is that often it's not very hard to automate with a simple script.
See also [#868](https://github.com/mifi/lossless-cut/issues/868).
@ -26,7 +26,7 @@ If there's a particular operation from LosslessCut you want to automate across m
I wish more people were aware of this: large language models like ChatGPT can be incredibly useful for helping non-programmers with simple scripting tasks as well as helping you learn things and debug error messages, and it's free! Basically you just ask the AI to write a script for you to do whatever you need. If it doesn't work, you can continue the conversation with the AI and give it the error messages you received and it will try to help your get it working.
Start your sentence with your operating system, e.g. "I am using Windows 10", then try to be so exact and concise as possible to describe what kind of files you have and what you want to do with them to the AI using FFmpeg. Example prompt:
Start your sentence with your operating system, e.g. "I am using Windows 10", then try to be so exact and concise as possible to describe what kind of files you have and what you want to do with them to the AI using FFmpeg. Example prompt to the AI:
> I am on macOS. Please help me write a script that for each *.mp4 file in a specified folder, losslessly removes the first 10 seconds from each file? Also how do I run the script? The files are inside the folder `/Users/user/my-files`. I have FFmpeg installed and running as `ffmpeg`.

@ -28,9 +28,9 @@
- **Note:** The original video file will not be modified. Instead, a file is created file in the same directory as the original file with from/to timestamps in the file name.
- See Keyboard shortcuts dialog for more custom actions. (<kbd>SHIFT</kbd> + <kbd>/</kbd>)
## Primer: Video & audio formats vs. codecs
## Primer: Video/audio codecs vs. formats
Here's a little primer about video and audio formats for those not familiar. A common mistake when dealing with audio and video files, is to confuse *formats*, *codecs*, and *file names*. In short: A file's media format is a *container* that holds one or more *codecs* (audio/video/subtitle) inside of it. For example `.mov` is a *container format*, and `H265`/`HEVC` is a *codec*. Some formats support only a few codecs inside of them, while others support more codecs. The most common formats are MP4/MOV (often `.mp4`,`.mov`,`.m4a`) and Matroska (often `.mkv`,`.mka`). Example: If you have a file named `My video.mp4`, this file most likely (but not necessarily) has the *format* `MP4`. Note that the extension of a file (in this case `.mp4`) doesn't really mean anything, and the file could in reality for example have the `MOV` format, or the extension could be `.txt`. Inside `My video.mp4` there are multiple tracks/streams, each with their own *codec*. In this example, let's say that it contains one `H264` track and one `AAC` track. In LosslessCut you can view and add/delete/modify these tracks.
Here's a little primer about video and audio formats for those not familiar. A common mistake when dealing with audio and video files, is to confuse *formats*, *codecs*, and *file names*. In short: A file's media format is a *container* that holds one or more *codecs* (audio/video/subtitle) inside of it. For example `.mov` is a *container format*, and `H265`/`HEVC` is a *codec*. Some formats support only a few kinds of codecs inside of them (e.g. `.wav`), while others support almost all codecs (e.g. Matroska). The most common formats are MP4/MOV (often `.mp4`,`.mov`,`.m4a`) and Matroska (often `.mkv`,`.mka`). Example: If you have a file named `My video.mp4`, this file most likely (but not necessarily) has the *format* `MP4`. Note that the extension of a file (in this case `.mp4`) doesn't really mean anything, and the file could in reality for example have the `MOV` format, or the extension could be `.txt`. Inside `My video.mp4` there are multiple tracks/streams, each with their own *codec*. In this example, let's say that it contains one `H264` track and one `AAC` track. In LosslessCut you can view and add/delete/modify these tracks.
**Remuxing**: If you change the output format in LosslessCut and export a file, you are *remuxing* the tracks/codecs into a different container format. When you do this, the operation is in theory lossless, meaning you will not lose any codec data and the different tracks will remain exactly the same, even though the format is now different (but some format metadata might get lost due to incompatibilities between container formats). There are limitations: Some popular codecs like VP8 or VP9 are not supported in popular formats like MP4, and some popular formats like Matroska (`.mkv`) are not natively supported in popular video players like iPhone or QuickTime.
@ -43,12 +43,12 @@ Here is a great introduction to audio/video: [howvideo.works](https://howvideo.w
## Segments
Segments are the first class citizens of LosslessCut. A segment is a time-slice of your media file, defined by a *start time* and an *end time*. When a segment has no *end time*, it's called a [marker](#markers).
Segments are the first class citizens of LosslessCut. A segment is a time-slice of your source media file, defined by a *start time* and an *end time*. When a segment has no *end time*, it's called a *[marker](#markers)*.
Segments have a segment number (their export order), and can optionally have a label and tags. Segments are be the basis of what gets exported.
### Markers
A segment that has no *end time* is called a *marker*. It has no length and will be excluded from exports, but behaves similar to segments. Markers are distinctively visualized on the timeline with a vertical line and a number on top. You can convert markers to segments by setting their out-point (<kbd>O</kbd>). This can be done manually or by one of the many tools in LosslessCut. For example you can invert all segments on the timeline to convert all markers into segments.
A segment that has no *end time* is called a *marker*. It has no length and will be excluded from exports, but behaves similar to segments. Markers are distinctively visualized on the timeline with a vertical line and a number on top. You can convert markers to segments by setting their out-point (<kbd>O</kbd>). This can be done manually or automated with one of the many tools in LosslessCut. For example you can invert all segments on the timeline to convert all markers into segments.
## Tracks
@ -56,7 +56,7 @@ The LosslessCut tracks panel is used to selectively enable/disable individual tr
## Custom exported file names
When exporting segments as files, LosslessCut offers you the ability to specify how the output files will be named in sequence using a *template string*. The template string is evaluated as a [JavaScript template string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), so you can use JavaScript syntax inside of it.
When exporting segments as files, LosslessCut offers you the ability to specify how the output files will be named in sequence using a *template*. The template is evaluated as a [JavaScript template string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), so you can use JavaScript syntax inside of it.
The following variables are available in the template to customize the filenames:
@ -80,19 +80,17 @@ The following variables are available in the template to customize the filenames
| | | `${CUT_DURATION}` | `string` | The duration of the segment (`CUT_TO-CUT_FROM`) in `hh.mm.ss.sss` format (e.g. `00.00.28.000`).
| | | `${SEG_TAGS.XX}` | `object` | Allows you to retrieve the tags for a given segment by name. If a tag is called foo, it can be accessed with `${SEG_TAGS.foo}`. Note that if the tag does not exist, it will yield the text `undefined`. You can work around this as follows: `${SEG_TAGS.foo ?? ''}`
Your files must always include at least one unique identifer (such as `${SEG_NUM}` or `${CUT_FROM}`), and it should end in `${EXT}` (or else players might not recognise the files). For instance, to achieve a filename sequence of `Beach Trip - 1.mp4`, `Beach Trip - 2.mp4`, `Beach Trip - 3.mp4`, your format should read `${FILENAME} - ${SEG_NUM}${EXT}`. If your template gives at least two duplicate output file names, LosslessCut will revert to using the default template instead.
Your files must always include at least one unique identifer (such as `${SEG_NUM}` or `${CUT_FROM}`), and it should end in `${EXT}` (or else players might not recognise the files). For instance, to achieve a filename sequence of `Beach Trip - 1.mp4`, `Beach Trip - 2.mp4`, `Beach Trip - 3.mp4`, your format should read `${FILENAME} - ${SEG_NUM}${EXT}`. If your template gives at least two duplicate output file names, LosslessCut will revert to using the default template instead. You can ask AI to help you create a template string by referring it to this page.
### JavaScript expression tips
## Padding numbers
#### Padding numbers
If you need to pad a number, you can use this JavaScript code around the variable. For example to pad the `FILE_EXPORT_COUNT` variable to 2 digits with leading zeros: `${String(FILE_EXPORT_COUNT).padStart(2, '0')}`
If you need to pad a number, you can use this JavaScript code around the variable. For example to pad the `FILE_EXPORT_COUNT` variable to 2 digits with leading zeros, we convert it to a `String` and then call `padStart` on the string: `${String(FILE_EXPORT_COUNT).padStart(2, '0')}`
If you need more help, you can ask an AI to help you with this, e.g. "How to pad a number with JavaScript?"
## Import / export projects
LosslessCut also allows importing/exporting your project (segments) in a variety of file formats. See [list of supported formats](https://github.com/mifi/lossless-cut/issues/1340).
LosslessCut default project file `.llc` is in a JSON5 format. It contains information about the segments in your timeline. LosslessCut also allows importing/exporting your project (segments) in a variety of file formats. See [list of supported formats](https://github.com/mifi/lossless-cut/issues/1340).
### CSV files
@ -114,6 +112,7 @@ Same as CSV but `<tab>` instead.
## More
- [FAQ, known issues, limitations and troubleshooting](issues.md)
- [Command line interface (CLI)](cli.md)
- [HTTP API](api.md)
- [❓ FAQ, known issues, limitations and troubleshooting](issues.md)
- [💻 Command line interface (CLI)](cli.md)
- [🕸️ HTTP API](api.md)
- [📝 Recipe cookbook](./recipes.md)

Loading…
Cancel
Save