Next revision | Previous revision |
lwc:multimedia_and_graphics [2020/11/26 19:37] – created John Harrison | lwc:multimedia_and_graphics [2023/08/18 08:22] (current) – John Harrison |
---|
[[http://stackoverflow.com/questions/12336401/creating-icon-fonts-with-vector-software-i-e-inkscape-and-fontforge|How to create a ttf]] | * [[http://stackoverflow.com/questions/12336401/creating-icon-fonts-with-vector-software-i-e-inkscape-and-fontforge|How to create a ttf]] |
\\ | |
| |
| |
crossfade example with ffmpeg (audio and video): | |
| |
| ==== Crossfade with ffmpeg ==== |
| === crossfade example with ffmpeg (audio and video) === |
| <code> |
/opt/ffmpeg/bin/ffmpeg -i 1.mov -i 2.mov -f lavfi -i color=black -filter_complex \ | /opt/ffmpeg/bin/ffmpeg -i 1.mov -i 2.mov -f lavfi -i color=black -filter_complex \ |
| |
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\ | "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\ |
| |
[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\ | [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\ |
| |
[2:v]scale=1920x1080,trim=duration=7[over];\ | [2:v]scale=1920x1080,trim=duration=7[over];\ |
| |
[0:a]afade=t=out:st=4:d=1[a0];\ | [0:a]afade=t=out:st=4:d=1[a0];\ |
| |
[1:a]afade=t=in:st=0:d=1[a1];\ | [1:a]afade=t=in:st=0:d=1[a1];\ |
| |
aevalsrc=0:d=4[s1];\ | aevalsrc=0:d=4[s1];\ |
| |
[s1][a1]concat=n=2:v=0:a=1[ac1];\ | [s1][a1]concat=n=2:v=0:a=1[ac1];\ |
| |
[a0][ac1]amix[outa];\ | [a0][ac1]amix[outa];\ |
| |
[over][va0]overlay[over1];\ | [over][va0]overlay[over1];\ |
| |
[over1][va1]overlay=format=yuv420[outv]" \ | [over1][va1]overlay=format=yuv420[outv]" \ |
| |
-vcodec libx264 -aspect 1.778 -map [outv] -map [outa] -codec:a libmp3lame -qscale:a 2 -ss 00:00:02 -t 5 out.mp4 | -vcodec libx264 -aspect 1.778 -map [outv] -map [outa] -codec:a libmp3lame -qscale:a 2 -ss 00:00:02 -t 5 out.mp4 |
| </code> |
| * highest quality: |
\\ | <code> |
| |
| |
highest quality: | |
/opt/ffmpeg/bin/ffmpeg -i 1.mov -i 1.mov -f lavfi -i color=black -filter_complex \ | /opt/ffmpeg/bin/ffmpeg -i 1.mov -i 1.mov -f lavfi -i color=black -filter_complex \ |
| |
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\ | "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\ |
| |
[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\ | [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\ |
| |
[2:v]scale=1920x1080,trim=duration=7[over];\ | [2:v]scale=1920x1080,trim=duration=7[over];\ |
| |
[0:a]afade=t=out:st=4:d=1[a0];\ | [0:a]afade=t=out:st=4:d=1[a0];\ |
| |
[1:a]afade=t=in:st=0:d=1[a1];\ | [1:a]afade=t=in:st=0:d=1[a1];\ |
| |
aevalsrc=0:d=4[s1];\ | aevalsrc=0:d=4[s1];\ |
| |
[s1][a1]concat=n=2:v=0:a=1[ac1];\ | [s1][a1]concat=n=2:v=0:a=1[ac1];\ |
| |
[a0][ac1]amix[outa];\ | [a0][ac1]amix[outa];\ |
| |
[over][va0]overlay[over1];\ | [over][va0]overlay[over1];\ |
| |
[over1][va1]overlay=format=yuv420[outv]" \ | [over1][va1]overlay=format=yuv420[outv]" \ |
| |
-vcodec libx264 -preset ultrafast -qp 0 -aspect 1.778 -map [outv] -map [outa] -acodec libvorbis -qscale:a 10 -ss 00:00:02 -t 5 out.mp4 | -vcodec libx264 -preset ultrafast -qp 0 -aspect 1.778 -map [outv] -map [outa] -acodec libvorbis -qscale:a 10 -ss 00:00:02 -t 5 out.mp4 |
| </code> |
| === crossfade using ffmpeg and xfade === |
| <code> |
| ffmpeg -i first.mp4 -i second.mp4 -filter_complex "xfade=transition=fade:offset=60:duration=1" out.mp4 |
| <code> |
| // from https://superuser.com/questions/778762/crossfade-between-2-videos-using-ffmpeg // |
| </code> |
| * compress video with ffmpeg: |
| <code>ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4</code> |
| ''crf'' is typically 24 through 30. Higher numbers are smaller files and lower quality. From [[https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg]] |
| * convert video to a sequence of pngs: ''ffmpeg -i <FILENAME1> <FILENAME2>_%03d.png'' |
| * [[https://superuser.com/questions/810471/remove-mp4-video-top-and-bottom-black-bars-using-ffmpeg|remove letterboxing with ffmpeg]] |
| * slow down video but keep smoothness by using optical flow (sometimes called motion interpolation): ''ffmpeg -i input.mkv -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'" output.mkv'' where ''fps'' is the output fps (independent of input fps) |
| * change speed video is played (fps) without changing anything else. No frames are harmed with this cmd: ''ffmpeg -itsscale 2 -i input.mp4 -c copy -an output.mp4'' # slow to 2x slower |