[JAVA] FFmpeg로 Thumbnail 추출하기

[JAVA] FFmpeg로 Thumbnail 추출하기

ffmpeg를 이용하혀 Thumbnail을 추출하는 방법

전 포스팅에 ffmpeg설치 및 사용법이 있다.

import java.io.IOException; public class VideoTimeCut { public static void main(String[] args) throws IOException { thumbnail(); } public static void thumbnail() { Runtime run = Runtime.getRuntime(); String videofile = "C:/Users/Min/Desktop/test1/test.mp4"; String command = "C:/ffmpeg-20191109-0f89a22-win64-static/bin/ffmpeg.exe -i \"" + videofile + "\" -ss 00:00:01 -vcodec png -vframes 1 \"" +videofile + "_%2d.png\""; // 동영상 1초에서 Thumbnail 추출 System.out.println(command); try{ run.exec("cmd.exe chcp 65001"); // cmd에서 한글문제로 썸네일이 만들어지지않을시 cmd창에서 utf-8로 변환하는 명령 run.exec(command); }catch(Exception e){ System.out.println("error : "+e.getMessage()); e.printStackTrace(); } } }

728x90

from http://byul91oh.tistory.com/417 by ccl(A) rewrite - 2021-11-24 10:27:30