ffmpeg 기반 영상 편집 명령어
[원본 퀄리티 유지 옵션] - ffmpeg high quailty video & audio
-c:v libx264 -c:a pcm_s16le 또는 -c:v copy -c:a pcm_s16le
-c:v copy option copies the video stream without re-encoding it. The -c:a pcm_s16le option converts the audio stream to uncompressed PCM audio with 16-bit depth and little-endian byte order. This ensures the best audio quality possible.
[영상 해상도 변경하기 - (1) ] - rescale video
ffmpeg -i 4_vid_org.avi -vf "scale=1920x1080" -c:v libx264 -c:a pcm_s16le 4_vid.avi
[영상 해상도 변경하기 - (2) ] - rescale video with black part
ffmpeg -i test.avi -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black" test_1920x1080.avi
(출처: https://m.blog.naver.com/chandong83/221677551117 )
[영상 fps 변경하기]
ffmpeg -i input_v.avi -filter:v fps=23.98 -c:v libx264 -c:a pcm_s16le out_v.avi
[일정 시간 동안 무음 오디오 만들기] - silent audio making by time
ffmpeg -f lavfi -i anullsrc=r=11025:cl=mono -t 7 -acodec aac silent.m4a
: 7초 동안 무음인 silent.m4a 파일 생성
[단일 이미지로 영상 만들기 (audio 미포함)] - make video with single image by time, fps, non-audio
ffmpeg -framerate 23.98 -loop 1 -i png_in.PNG -pix_fmt yuv420p -t 7 png_out.avi
: png_in.PNG가 23.98 fps로 7초간 유지되는 영상 png_out.avi 생성
[단일 이미지와 오디오 파일로 영상 만들기] - make video with one image and audio
ffmpeg -framerate 23.98 -loop 1 -i png_in.PNG -i silent.m4a -c:v libx264 -tune stillimage -c:a aac -b:a 192k -vf "scale='iw-mod(iw,2)':'ih-mod(ih,2)',format=yuv420p" -shortest -movflags +faststart png_out.avi
[여러 개의 영상 합치기] - 해상도, 속도 무관 (단, 영상 quailty가 낮아진다는 단점 있음)
ffmpeg -i video1.avi -i video2.avi -filter_complex "[0:v]scale=1920x1080,setpts=PTS-STARTPTS[v0]; [1:v]scale=1920x1080,setpts=PTS-STARTPTS[v1];[v0][0:a][v1][1:a] concat=n={2}:v=1:a=1[v][a]" -map "[v]" -map "[a]" vid_out.avi
[영상 볼륨 조정] - volume up the sound of video
ffmpeg -i 4_vid_org.avi -c:v libx264 -c:a pcm_s16le -filter:a "volume=2" -y 4_vid.avi
[영상 배속 조정]
- set_pts (영상 속도 조정 옵션)
To double the speed of the video with the setpts filter, you can use:
(https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video)
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv
[ffmpeg 옵션별 의미] (출처: https://peche326.tistory.com/58 )
ffmpeg -y ⓐ -i ⓑ -acodec ⓒ -ab ⓓ -ar ⓔ -ac ⓕ -b:a ⓖ -vcodec ⓗ -level ⓘ -b:v ⓙ-r ⓚ -s ⓛ -threads ⓜ -strict experimental ⓝ ⓞ