Create a video from images. images must be numbered sequentially. example:
001.png 002.png 003.png etc and All must be same size
The ( -framerate 2 ) means 2 images per second .
EXAMPLE
ffmpeg -framerate 2 -i use/%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p vids/vid-from-images.mp4
Create Subtitles for a Video
You may Add Subtitles - to videos easily
with FFmpeg.
create a subtitle file --- filename subtitle.srt 1 00:00:00,000 --> 00:00:03,000 2 00:00:03,050 --> 00:00:05,550 to videos easily 3 00:00:05,700 --> 00:00:07,900 with FFmpeg. ----------------- Convert the subtitle.srt to a subtitle.assThis file may be hand generated but the default generated is much easier.
ffmpeg -i subtitle.srt subtitle.ass ffmpeg -i vids/vid-from-images.mp4 -vf "ass=subtitle.ass" vids/subtitled.mp4
Using a custom *.ass file
ffmpeg -i vids/vid-from-images.mp4 -vf "ass=subtitle2.ass" vids/subtitled.mp4 [Script Info] ; Script generated by Aegisub 6962-master-2cb92a5 ; http://www.aegisub.org/ ScriptType: v4.00+ PlayResX: 640 PlayResY: 640 YCbCr Matrix: TV.709 [Aegisub Project Garbage] Video File: vids/vid-from-images.mp4 Video AR Mode: 4 Video AR Value: 1.000000 Video Zoom Percent: 0.500000 Active Line: 3 Video Position: 343 [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding Style: Default,Arial,50,&HCC0019FF,&HCC0019FF,&H00FFFFFF,&H00000000,-1,0,0,0,100,100,0,0,1,1.9,0,2,17,17,22,0 [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,{\pos(336,62)}You may Add Subtitles Dialogue: 0,0:00:03.05,0:00:05.55,Default,,0,0,0,,{\pos(328,138)}to videos easily Dialogue: 0,0:00:05.70,0:00:07.90,Default,,0,0,0,,with FFmpeg. Dialogue: 0,0:00:07.90,0:00:09.90,Default,,0,0,0,,{\pos(324,550)}Editing with a text editor Dialogue: 0,0:00:09.90,0:00:11.90,Default,,0,0,0,,or with Aegisub Editor
Add Sound to a Video using a mp3 file
FADE SOUND IN AND OUT
ffmpeg -i vids/subtitled-test.mp4 -i music/Quiet.mp3 \ -c copy -map 0:0 -map 1:0 -shortest vids/subtitled-sound.mp4 FADE SOUND IN AND OUT: ffmpeg -i vids/subtitled-test.mp4 -i music/Quiet.mp3 \ -af 'afade=in:st=0:d=7,afade=out:st=8:d=4' \ -map 0:0 -map 1:0 -shortest vids/fadesubtitled-sound.mp4
Fading Multiple Images in a Video Fade: fade=st=0:d=1:alpha=1,fade=out:st=2:d=1:alpha=1,trim=0:3,setpts=PTS+5/TB[ovr1]; Location: of image overlay=100:80 Start and Duration: enable='between(t,5,13) between=(t,3,30) Start location 1220 (x=1220) with each step of t move left 60px (x=1220-t*60). Set y axis at 50px (y=50[out])
ffmpeg -i vids/ZOOM.mp4 -loop 1 -i use/001.png -loop 1 -i use/002.png -loop 1 -i use/003.png -filter_complex "[1]fade=st=0:d=1:alpha=1,fade=out:st=2:d=1:alpha=1,trim=0:3,setpts=PTS+5/TB[ovr1]; \ [2]fade=st=0:d=1:alpha=1,fade=out:st=2:d=1:alpha=1,trim=0:3,setpts=PTS+17/TB[ovr2]; \ [3]fade=st=0:d=1:alpha=1,fade=out:st=2:d=1:alpha=1,trim=0:3,setpts=PTS+25/TB[ovr3]; \ [0:v][ovr1]overlay=100:80:enable='between(t,5,13)'[base1]; \ [base1][ovr2]overlay=90:200:enable='between(t,17,22)'[base2]; \ [base2][ovr3]overlay=430:170:enable='between(t,25,29)'[out]" -map "[out]" \ -c:v libx264 -c:a copy -flags +global_header -shortest -s 1280x720 -y vids/overlay-zoom.mp4
Save in file scrCAP.sh USAGE: "Usage must include a delay time in seconds Example:" Example: scrCAP.sh 10 Script waits ten seconds then start video capture the wait time is defines after scrCAP.sh The video file is saves as date and time: 2019-01-21-18-01.mp4 The file may be copied to /usr/local/bin as scrCAP sudo cp scrCAP.sh /usr/local/bin/scrCAP Then the command scrCAP may be used globally Because it is a screen capture run: ffmpeg -i vids/2019-01-21-18-01.mp4 vids/datcon.mp4 then use the resulting file. you may see the original file locally but it may not work on YouTube until you re-encode it. or a webpage.
----- filename scrCAP.sh ---------------- #!/bin/bash if [ -z "$1" ] then echo "Usage must include a delay time in seconds Example:" echo "scrCAP 10" echo "" exit 0 fi sleep $1 ffmpeg -y -f alsa -ac 2 -i hw:1,0 -strict -2 -f x11grab -framerate 30 -video_size 1280x720 -i :0.0 \ -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast $(date +%Y-%m-%d-%H-%M).mp4 ffmpeg -i vids/2019-01-21-18-01.mp4 vids/datcon.mp4
THis is file subtitle.ass generated from the command:
ffmpeg -i subtitle.srt subtitle.ass
-------------- filename subtitle.ass ------------
[Script Info] ; Script generated by FFmpeg/Lavc58.39.100 ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0 [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0,0,0,,You may Add Subtitles Dialogue: 0,0:00:03.05,0:00:05.55,Default,,0,0,0,,to videos easily Dialogue: 0,0:00:05.70,0:00:07.90,Default,,0,0,0,,with FFmpeg.