-
-
Save Bioblaze/cfed6f126302a0eb642493d758ff3f5a to your computer and use it in GitHub Desktop.
This is a collection of command line one-liners for manipulating with audio and video files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Write list of videos in a text file | |
$ cat mylist.txt | |
file '/path/to/file1' | |
file '/path/to/file2' | |
file '/path/to/file3' | |
## Concatenate videos | |
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4 | |
# -f concat => filter concatenate | |
# -safe 0 => safe mode for paths | |
# -i => input | |
# -c copy => use the same codec as origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Convert video to H.265/HVEC | |
ffmpeg -i input.mp4 -c:v libx265 -tag:v hvc1 output.mp4 | |
# -c:v libx265 => for video use codec H.265 (HEVC) | |
# -c:v hevc_videotoolbox => for video use codec H.265 (HEVC) with hardware acceleration on Apple (faster, but lower quality) | |
# -tag:v hvc1 => enable playing in Apple QuickTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Combine video with audio, audio is delayed (shifted, in offset) 75 seconds | |
ffmpeg -i video.mp4 -itsoffset 75 -i audio.m4a -c:v copy -c:a copy -map 0:v -map 1:a output.mp4 | |
# -itsoffset 75 => following file input is 75 seconds delayed | |
# -c:v copy => copy video codec | |
# -c:a copy => copy audio codec | |
# -map 0:v => from the first input take a video stream | |
# -map 1:a => from the second input take a audio stream | |
# -i => input file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Inspect original audio format | |
ffprobe video.mp4 | |
## Extract audio | |
ffmpeg -i video.mp4 -vn -c:a copy audio.m4a | |
# -vn => -vn / -an / -sn / -dn options can be used to skip inclusion | |
# of video, audio, subtitle and data streams respectively | |
# -c:a copy 5 => audio codec copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Convert image to video | |
convert -quality 100 -delay 5 image.png video.mp4 | |
# -quality 100 => quality of compression (0 worst quality -- 100 best quality) | |
# -delay 5 => 5 seconds length of video |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment