DongJu-Na / sbwvss-mvc

Spring Boot WebMvc Video Streaming Server
0 stars 0 forks source link

ffmpeg effect sample #1

Open DongJu-Na opened 1 year ago

DongJu-Na commented 1 year ago

https://medium.com/numatic-ventures/top-17-ffmpeg-commands-of-video-processing-64b587325d9e

ffmpeg17가지 예제 커맨드

DongJu-Na commented 1 year ago

https://ottverse.com/stack-videos-horizontally-vertically-grid-with-ffmpeg/

ffmpeg 그리드 예제

DongJu-Na commented 1 year ago

https://www.bannerbear.com/blog/how-to-create-a-slideshow-from-images-with-ffmpeg/

ffmpeg 슬라이드 예제

DongJu-Na commented 1 year ago

https://stackoverflow.com/questions/11552565/vertically-or-horizontally-stack-mosaic-several-videos-using-ffmpeg

ffmpeg 그리드 예제 2 - 질답

DongJu-Na commented 1 year ago

https://stackoverflow.com/questions/73019429/ffmpeg-stack-videos-with-custom-grid-layout ffmpeg 커스텀 그리드

DongJu-Na commented 1 year ago
  1. 영상 4분할 슬라이드 줌인

    영상 하나씩 만들

1) 2*2 grid ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[top]; [2:v][3:v]hstack=inputs=2[bottom]; [top][bottom]vstack=inputs=2[v]" -map "[v]" finalOutput.mp4

ffmpeg -i area1.gif -i area2.gif -i area3.gif -i area4.png -filter_complex "[0:v][1:v]hstack=inputs=2[top];[2:v][3:v]hstack=inputs=2[bottom];[top][bottom]vstack=inputs=2[v]" -map "[v]" -c:v libx264 -crf 10 -preset veryfast -pix_fmt yuv420p finalOutput_gifTest.mp4

1-1) 2*2 grid effect ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "[0:v]crop=iw/2:ih:0:0,format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v0];[1:v]format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v1];[2:v]format=yuva420p,fade=t=in:st=0:d=2:alpha=1[v2];[3:v]format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v3];[v0][v1]hstack=inputs=2[top];[v2][v3]hstack=inputs=2[bottom];[top][bottom]vstack=inputs=2[v]" -map "[v]" finalOutput.mp4

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "[0:v]crop=iw/2:ih:0:0,format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v0];[1:v]format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v1];[2:v]format=yuva420p,fade=t=in:st=0:d=2:alpha=1[v2];[3:v]format=yuva420p,fade=t=out:st=7:d=2:alpha=1[v3];[v0][v1]hstack=inputs=2[top];[v2][v3]hstack=inputs=2[bottom];[top][bottom]vstack=inputs=2[v]" -map "[v]" finalOutput.mp4

1) 슬라이드 2) 페이드아웃 3) 페이드인 4) 흑백

2) customize grid ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v01];[2:v]scale=1080:-1[v3];[v3][v01]vstack=inputs=2" -f flv output_test.mp4

DongJu-Na commented 1 year ago

https://pati.hashnode.dev/4-ffmpeg-tips-convert-animated-gif-to-mp4-and-back-to-animated-gif#heading-1-animated-gif-mp4 gif to video

DongJu-Na commented 1 year ago

https://stackoverflow.com/questions/17623676/text-on-video-ffmpeg video addon text

DongJu-Na commented 1 year ago

https://stackoverflow.com/questions/30384577/ffmpeg-move-overlay-from-one-pixel-coordinate-to-another 픽셀 단위 조작

DongJu-Na commented 1 year ago

https://www.bannerbear.com/blog/how-to-do-a-ken-burns-style-effect-with-ffmpeg/ Zoom In Effect 효과

DongJu-Na commented 1 year ago

https://www.bannerbear.com/blog/how-to-add-watermark-to-videos-using-ffmpeg/ 워터마크 삽입

DongJu-Na commented 1 year ago

ffmpeg -loop 1 -t 5 -i h1.png -loop 1 -t 5 -i h2.png -loop 1 -t 5 -i h3.png -filter_complex "[0:v]drawtext=fontfile='c\:\/ffmpeg\/font\/BMEuljiro10yearslater.ttf':fontcolor=0xFFFFFF:fontsize=20:x='w-(w+tw)mod(t,10)/10':y='h/20':enable='lt(mod(t,180),10)':text='최고의 화장품'[txt1];[1:v]drawtext=fontfile='c\:\/ffmpeg\/font\/BMEuljiro10yearslater.ttf':fontcolor=0xFFFFFF:fontsize=20:x='w-(w+tw)mod(t,10)/10':y='h/20':enable='lt(mod(t,180),10)':text='인라이플'[txt2];[2:v]drawtext=fontfile='c\:\/ffmpeg\/font\/BMEuljiro10yearslater.ttf':fontcolor=0xFFFFFF:fontsize=20:x='w-(w+tw)*mod(t,10)/10':y='h/20':enable='lt(mod(t,180),10)':text='모비온'[txt3];[txt1][txt2]xfade=transition=fade:duration=1:offset=4,split[s0][s1];[s0]palettegen[p1];[s1][p1]paletteuse[fade1];[fade1][txt3]xfade=transition=fade:duration=1:offset=8,format=yuv420p" h_output.mp4

fade 효과 및 텍스트

DongJu-Na commented 1 year ago

Zooming and Panning https://el-tramo.be/blog/ken-burns-ffmpeg/

DongJu-Na commented 1 year ago

ffmpeg -i daba1.png -i daba2.png -i daba3.png -i daba4.png -i daba5.png -filter_complex "\ [0:v]fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v0];\ [1:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v1];\ [2:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v2];\ [3:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v3];\ [4:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=25*4:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v4];\ [v0][v1]xfade=transition=fade:duration=1:offset=2[xfade1];\ [xfade1][v2]xfade=transition=fade:duration=1:offset=5[xfade2];\ [xfade2][v3]xfade=transition=fade:duration=1:offset=8[xfade3];\ [xfade3][v4]xfade=transition=fade:duration=1:offset=11,\ drawtext=text='D&B by DABAGIRL':fontfile='c\:\/ffmpeg\/font\/SpoqaHanSansNeo-Medium.ttf':fontcolor=white:fontsize=36:x='(w-text_w)/2':y='h-text_h-10'[vfinal]" \ -map "[vfinal]" -c:v libx264 -pix_fmt yuv420p -t 15 test_output.mp4

템플릿1번 이미지 5개 xfade 효과 하단텍스트

DongJu-Na commented 1 year ago

[템플릿1] ffmpeg -i daba1.png -i daba2.png -i daba3.png -i daba4.png -i daba5.png -filter_complex "[0:v]fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v0];[1:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v1];[2:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v2];[3:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v3];[4:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=25*4:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v4];[v0][v1]xfade=transition=fade:duration=1:offset=2[xfade1];[xfade1][v2]xfade=transition=fade:duration=1:offset=5[xfade2];[xfade2][v3]xfade=transition=fade:duration=1:offset=8[xfade3];[xfade3][v4]xfade=transition=fade:duration=1:offset=11,drawtext=text='D&B by DABAGIRL':fontfile='c:/ffmpeg/font/SpoqaHanSansNeo-Medium.ttf':fontcolor=white:fontsize=36:x='(w-text_w)/2':y='h-text_h-10'[vfinal]" -map "[vfinal]" -c:v libx264 -pix_fmt yuv420p -t 15 test_output.mp4

ffmpeg -i test_output.mp4 -i GROUP_IMAGE.png -filter_complex "[0:v]fade=t=out:st=0:d=2:alpha=1[fade_out];[1:v]fade=t=in:st=2:d=1:alpha=1,fade=t=out:st=5:d=1:alpha=1,setpts=PTS-STARTPTS[fade_in];[fade_out][fade_in]overlay=x='if(gte(t,2),(W-w)/2,0)':y='if(gte(t,2),(t-2)*((H-h)/2-1193)/3+(H-h)/2,H)'[v]" -map "[v]" -c:v libx264 -pix_fmt yuv420p -t 15 modified_output.mp4

DongJu-Na commented 1 year ago

[완성조정필요] ffmpeg -i daba1.png -i daba2.png -i daba3.png -i daba4.png -i daba5.png -filter_complex "[0:v]fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v0];[1:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v1];[2:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v2];[3:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v3];[4:v]fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=2:d=1:alpha=1,zoompan=z='zoom+0.002':d=254:s='1080x1920':fps=25:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'[v4];[v0][v1]xfade=transition=fade:duration=1:offset=2[xfade1];[xfade1][v2]xfade=transition=fade:duration=1:offset=5[xfade2];[xfade2][v3]xfade=transition=fade:duration=1:offset=8[xfade3];[xfade3][v4]xfade=transition=fade:duration=1:offset=11,drawtext=text='D&B by DABAGIRL':fontfile='c:/ffmpeg/font/SpoqaHanSansNeo-Medium.ttf':fontcolor=white:fontsize=36:x='(w-text_w)/2':y='h-text_h-10'[vfinal]" -map "[vfinal]" -c:v libx264 -pix_fmt yuv420p -t 15 test_output.mp4 [최종] ffmpeg -i test_output.mp4 -i GROUP_IMAGE.png -filter_complex "[0:v]fade=t=out:st=0:d=2:alpha=1[fade_out];[fade_out][1:v]overlay=x='if(between(t,2,5),0,0)':y='if(between(t,2,4),1920-(t-2)362,if(eq(t,4),1738,1193))',format=yuva420p[overlay];[0:v][overlay]overlay=enable='between(t,2,5)'[v]" -map "[v]" -c:v libx264 -pix_fmt yuv420p -t 15 modified_output.mp4

완성!!

DongJu-Na commented 1 year ago

https://creatomate.com/blog/how-to-zoom-images-and-videos-using-ffmpeg

zoomin zoomout

DongJu-Na commented 1 year ago

ffmpeg -y -loop 1 -t 10 -i https://wimg.mk.co.kr/news/cms/202311/15/news-p.v1.20231113.ec9b5b5cfd034cc786243aa5be67cfaa_P1.jpg -loop 1 -t 10 -i https://wimg.mk.co.kr/news/cms/202311/15/news-p.v1.20231113.f1cd84e2bb114d639cefd71af36bffc5_P1.jpg -loop 1 -t 10 -i https://wimg.mk.co.kr/news/cms/202311/15/news-p.v1.20231113.283cf7240a5b4851a05ffcdc4e2acbd9_P1.jpg -loop 1 -t 10 -i https://wimg.mk.co.kr/news/cms/202311/15/news-p.v1.20231113.6b5a1aec03a241f0bf8139581f386aa9_P1.jpg -filter_complex "[0:v]fps=15,scale=700:464,setsar=1[s1];[1:v]fps=15,scale=700:464,setsar=1[s2];[2:v]fps=15,scale=700:464,setsar=1[s3];[3:v]fps=15,scale=700:464,setsar=1[s4];[s1][s2][s3][s4]concat=n=4:v=1:a=0[output];[output]drawtext=text='D&B by DABAGIRL':fontfile='c:/ffmpeg/font/SpoqaHanSansNeo-Medium.ttf':fontcolor=white:y=h-th-10[output_subtitled]" -map "[output_subtitled]" -pix_fmt yuv420p -c:v libx264 -t 40 output_subtitled.mp4

DongJu-Na commented 11 months ago

https://www.abyssale.com/generate-video/how-to-create-slideshow-video-from-images-with-ffmpeg 슬라이드쇼