FFmpeg로 이미지에서 비디오를 만드는 방법은 무엇입니까?
ffmpeg -r 1/5 -start_number 2 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
이 줄은 정상적으로 작동했지만 다른 폴더의 이미지에서 비디오 파일을 만들고 싶습니다. 내 폴더의 이미지 이름은 다음과 같습니다.
img001.jpg
img002.jpg
img003.jpg
...
다른 폴더에서 이미지 파일을 어떻게 입력 할 수 있습니까? 예:C:\mypics
이 명령을 시도했지만 ffmpeg
첫 번째 이미지 (img001.jpg)로만 비디오를 생성했습니다.
ffmpeg -r 1/5 -start_number 0 -i C:\myimages\img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
이미지에서 비디오 슬라이드 쇼 만들기 – FFmpeg를 참조하십시오.
비디오에 프레임이 올바르게 표시되지 않는 경우 첫 번째 이미지를 건너 뛰거나 한 프레임에만 표시되는 등의 문제가 발생 하면 출력 프레임 속도 에 -r 대신 fps 비디오 필터 를 사용하십시오
ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4
또는 "fps = 25, format = yuv420p" 와 같이 -pix_fmt yuv420p 를 대체하기 위해 형식 비디오 필터를 필터 체인에 추가 할 수 있습니다 . 이 방법의 장점은 어떤 필터를 먼저 제어 할 수 있다는 것입니다
ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -vf "fps=25,format=yuv420p" out.mp4
나는 아래 매개 변수를 테스트했는데 그것은 나를 위해 일했다.
"e:\ffmpeg\ffmpeg.exe" -r 1/5 -start_number 0 -i "E:\images\01\padlock%3d.png" -c:v libx264 -vf "fps=25,format=yuv420p" e:\out.mp4
아래 매개 변수도 작동했지만 항상 첫 번째 이미지를 건너 뜁니다.
"e:\ffmpeg\ffmpeg.exe" -r 1/5 -start_number 0 -i "E:\images\01\padlock%3d.png" -c:v libx264 -r 30 -pix_fmt yuv420p e:\out.mp4
다른 폴더에있는 이미지로 비디오 만들기
먼저 아래와 같이 imagepaths.txt 에 이미지 경로를 추가하십시오 .
# this is a comment details https://trac.ffmpeg.org/wiki/Concatenate
file 'E:\images\png\images__%3d.jpg'
file 'E:\images\jpg\images__%3d.jpg'
다음과 같은 샘플 사용법;
"h:\ffmpeg\ffmpeg.exe" -y -r 1/5 -f concat -safe 0 -i "E:\images\imagepaths.txt" -c:v libx264 -vf "fps=25,format=yuv420p" "e:\out.mp4"
-safe 0 매개 변수로 안전하지 않은 파일 이름 오류 방지
관련된 링크들
-pattern_type glob
이 훌륭한 옵션을 사용하면 많은 경우 이미지를 쉽게 선택할 수 있습니다.
초당 하나의 이미지로 슬라이드 쇼 비디오
ffmpeg -framerate 1 -pattern_type glob -i '*.png' \
-c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
이미지가 끝날 때 오디오가 끊어지면 음악을 추가하십시오.
ffmpeg -framerate 1 -pattern_type glob -i '*.png' -i audio.ogg \
-c:a copy -shortest -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
YouTube의 두 가지 데모는 다음과 같습니다.
히피가되어 Theora의 특허를받지 않은 비디오 형식을 사용하십시오 .
ffmpeg -framerate 1 -pattern_type glob -i '*.png' -i audio.ogg \
-c:a copy -shortest -c:v libtheora -r 30 -pix_fmt yuv420p out.ogg
이미지는 물론 알파벳순으로 정렬해야합니다.
0001-first-thing.jpg
0002-second-thing.jpg
0003-and-third.jpg
등등.
참조 : http://unix.stackexchange.com/questions/68770/converting-png-frames-to-video-at-1-fps/339399#339399
30 FPS에서 프레임 당 하나의 이미지가있는 표준 속도 비디오
ffmpeg -framerate 30 -pattern_type glob -i '*.png' \
-c:v libx264 -pix_fmt yuv420p out.mp4
그 모습은 다음과 같습니다.
그것에 오디오를 추가하십시오 :
ffmpeg -framerate 30 -pattern_type glob -i '*.png' \
-i audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4
결과 : https://www.youtube.com/watch?v=HG7c7lldhM4
Convert one music file to a video with a fixed image for YouTube upload
Answered at: https://superuser.com/questions/700419/how-to-convert-mp3-to-youtube-allowed-video-format/1472572#1472572
Obtain some synthetic test input images
These are the test images I've been using in this answer:
wget -O opengl-rotating-triangle.zip https://github.com/cirosantilli/media/blob/master/opengl-rotating-triangle.zip?raw=true
unzip opengl-rotating-triangle.zip
cd opengl-rotating-triangle
wget -O audio.ogg https://upload.wikimedia.org/wikipedia/commons/7/74/Alnitaque_%26_Moon_Shot_-_EURO_%28Extended_Mix%29.ogg
Images generated with: How to use GLUT/OpenGL to render to a file?
It is cool to observe how much the video compresses the image sequence way better than ZIP as it is able to compress across frames with specialized algorithms:
opengl-rotating-triangle.mp4
: 340Kopengl-rotating-triangle.zip
: 7.3M
About the CLI options
Note however that despite the name, -glob
this is not as general as shell Glob patters, e.g.: -i '*'
fails: https://trac.ffmpeg.org/ticket/3620 (apparently because filetype is deduced from extension).
-r 30
makes the -framerate 1
video 30 FPS to overcome bugs in players like VLC for low framerates: VLC freezes for low 1 FPS video created from images with ffmpeg Therefore it repeats each frame 30 times to keep the desired 1 image per second effect.
Next steps
You will also want to:
cut up some audio to match the video length: Cutting the videos based on start and end time using ffmpeg
ffmpeg -i in.mp3 -ss 03:10 -to 03:30 -c copy out.mp3
add the cut up audio: https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg
ffmpeg -i video.mp4 -i audio.mp3 -c copy output.mkv
TODO: learn to cut and concatenate multiple audio files into the video without intermediate files, I'm pretty sure it's possible:
- ffmpeg cut and concat single command line
- https://video.stackexchange.com/questions/21315/concatenating-split-media-files-using-concat-protocol
- https://superuser.com/questions/587511/concatenate-multiple-wav-files-using-single-command-without-extra-file
Tested on
ffmpeg 3.4.4, vlc 3.0.3, Ubuntu 18.04.
Bibliography
- http://trac.ffmpeg.org/wiki/Slideshow official wiki
Simple Version from the Docs
Works particularly great for Google Earth Studio images:
ffmpeg -framerate 24 -i Project%03d.png Project.mp4
cat *.png | ffmpeg -f image2pipe -i - output.mp4
from wiki
참고URL : https://stackoverflow.com/questions/24961127/how-to-create-a-video-from-images-with-ffmpeg
'Programing' 카테고리의 다른 글
MyISAM과 InnoDB를 언제 사용해야합니까? (0) | 2020.07.06 |
---|---|
iOS에서 합성 된 속성의 이름을 밑줄로 바꾸는 이유는 무엇입니까? (0) | 2020.07.06 |
R에 data.frame을 저장하는 방법? (0) | 2020.07.06 |
배열에서 스트림을 어떻게 만들 수 있습니까? (0) | 2020.07.06 |
ASP.NET MVC 응용 프로그램에서 디버깅을위한 시작 페이지를 어떻게 설정합니까? (0) | 2020.07.06 |