Last active
March 16, 2021 19:24
-
-
Save zhangzhhz/3f686051ddd7358055de0ec24a59f215 to your computer and use it in GitHub Desktop.
Some ffmpeg commands
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 videos to mp4: | |
Move MOOV atom to the beginning so that the video can be streamed: | |
ffmpeg -i orig.mp4 -movflags faststart -c copy out.mp4 | |
ffmpeg -i S04E04.1080p.mkv -c:a copy -c:v libx264 -preset faster -f mp4 -s hd720 -hide_banner S04E04A.720p.mp4 | |
# to specify profile and level for h264 coding: | |
# to output 8bit, use `-pix_fmt yuv420p` | |
ffmpeg -i video.mkv -c:a copy -c:v libx264 -profile:v high -level:v 4 -preset faster -pix_fmt yuv420p -f mp4 -s hd720 -hide_banner output.mp4 | |
ffmpeg -i input_video_file_name -c:a aac -b:a 128k -c:v libx264 -preset fast -s hd720 -f mp4 -hide_banner output.mp4 | |
ffmpeg -i input_video_file_name -c:a aac -b:a 128k -c:v libx264 -preset medium -crf 18 -f mp4 -hide_banner output.mp4 | |
Extract mp4 from mkv container: | |
ffmpeg -i input.mkv -codec copy output.mp4 | |
Extract subtitle: | |
ffmpeg -i yourFile -codec:s srt sub.srt | |
ffmpeg -i foo.mkv -map 0:2 foo.ssa | |
OR | |
1) perform track identification | |
ffmpeg -i yourFile | |
2) extract the subtitle track with | |
ffmpeg -i yourFile -codec:s srt sub.srt | |
with X.Y the track number indicator you found from the cmd (1) . | |
# Add a subtitle as a stream into a mp4 file | |
ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4 | |
# Burn a subtitle into a mp4 file | |
https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo | |
Draw subtitles on top of input video using the libass library. This filter requires ffmpeg to be compiled with --enable-libass. See the subtitles video filter documentation for more details. | |
If the subtitle is a separate file called subtitle.srt, you can use this command: | |
ffmpeg -i video.avi -vf subtitles=subtitle.srt out.avi | |
If the subtitle is embedded in the container video.mkv, you can do this: | |
ffmpeg -i video.mkv -vf subtitles=video.mkv out.avi | |
# starting at 20s, extract 5 seconds of video | |
ffmpeg -i example.mp4 -f mp4 -ss 20 -t 5 -c:v libx264 -preset fast -c:a aac summary.mp4 -hide_banner | |
# extract 10 seconds starting at 1 min | |
ffmpeg -i input.mkv -c copy -ss 00:01:00 -t 10 output.mkv | |
# extract starting at 1 min and ending at 2 min | |
ffmpeg -i input.mkv -c copy -ss 00:01:00 -to 00:02:00 output.mkv | |
# extract only audio | |
ffmpeg -i input.mkv -vn audio_only.ogg | |
# concatenate files: | |
(for %i in (*.wav) do @echo file '%i') > mylist.txt | |
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output | |
# rip dvds | |
ffmpeg -i concat:"e:VIDEO_TS\VTS_01_0.VOB|e:VIDEO_TS\VTS_01_1.VOB|e:VIDEO_TS\VTS_01_2.VOB" -c:v libx264 01.mp4 | |
ffmpeg -i concat:"e:VIDEO_TS\VTS_02_0.VOB|e:VIDEO_TS\VTS_02_1.VOB|e:VIDEO_TS\VTS_02_2.VOB" -map 0:v -map 0:a:1 -c:v libx264 02.mp4 | |
ffmpeg -i concat:"e:VIDEO_TS\VTS_03_0.VOB|e:VIDEO_TS\VTS_03_1.VOB|e:VIDEO_TS\VTS_03_2.VOB" -map 0:v -map 0:a:2 -c:v libx264 03.mp4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment