将图像转换成视频
Convert images into video
文件夹里有一些图片。我想将所有图像转换成视频。但问题是,当分辨率不同时,它会显示错误。我不想拉伸视频中的图像。我只想保持图像大小不变。但是它显示这个错误。
我的命令:
ffmpeg -framerate 1/3 -pattern_type glob -i "images/*.jpg" -i trinity.MP3 -shortest -c:v libx264 -r 30 -vf "scale=iw*sar:ih , pad=max(iw\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2" -aspect 16:9 -pix_fmt yuv420p out.mp4 -y
日志:
[mjpeg @ 0x6b3820] Changeing bps to 8
Input #0, image2, from 'images/*.jpg':
Duration: 00:00:24.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 0.33 fps, 0.33 tbr, 0.33 tbn, 0.33 tbc
[mp3 @ 0x6b4ca0] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'trinity.MP3':
Metadata:
encoded_by : Lavf52.9.0
Duration: 00:09:02.35, start: 0.000000, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
[swscaler @ 0x68a3c0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x6bada0] using SAR=1/1
[libx264 @ 0x6bada0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x6bada0] profile High, level 3.1
[libx264 @ 0x6bada0] 264 - core 142 r2438 af8e768 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc56.26.100 libx264
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
Metadata:
encoder : Lavc56.26.100 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (native) -> aac (libfaac))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:596x913 fmt:yuvj420p
[Parsed_pad_1 @ 0x697940] Input area 512:0:1108:913 not within the padded area 0:0:1622:912 or zero-sized
[Parsed_pad_1 @ 0x697940] Failed to configure input pad on Parsed_pad_1
有什么方法可以保持分辨率不变并制作所有图像的视频吗?
假设您要调整所有图像的大小以适应 1280x720 canvas,请使用
ffmpeg -framerate 1/3 -pattern_type glob -i "images/*.jpg" -i trinity.MP3
-vf "scale='if(gt(a,1280/720),1280,-1)':'if(gt(a,1280/720),-1,720)':eval=frame,
pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1"
-c:v libx264 -r 30 -pix_fmt yuv420p -shortest -y out.mp4
文件夹里有一些图片。我想将所有图像转换成视频。但问题是,当分辨率不同时,它会显示错误。我不想拉伸视频中的图像。我只想保持图像大小不变。但是它显示这个错误。
我的命令:
ffmpeg -framerate 1/3 -pattern_type glob -i "images/*.jpg" -i trinity.MP3 -shortest -c:v libx264 -r 30 -vf "scale=iw*sar:ih , pad=max(iw\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2" -aspect 16:9 -pix_fmt yuv420p out.mp4 -y
日志:
[mjpeg @ 0x6b3820] Changeing bps to 8
Input #0, image2, from 'images/*.jpg':
Duration: 00:00:24.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 0.33 fps, 0.33 tbr, 0.33 tbn, 0.33 tbc
[mp3 @ 0x6b4ca0] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'trinity.MP3':
Metadata:
encoded_by : Lavf52.9.0
Duration: 00:09:02.35, start: 0.000000, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
[swscaler @ 0x68a3c0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x6bada0] using SAR=1/1
[libx264 @ 0x6bada0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x6bada0] profile High, level 3.1
[libx264 @ 0x6bada0] 264 - core 142 r2438 af8e768 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc56.26.100 libx264
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
Metadata:
encoder : Lavc56.26.100 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (native) -> aac (libfaac))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:596x913 fmt:yuvj420p
[Parsed_pad_1 @ 0x697940] Input area 512:0:1108:913 not within the padded area 0:0:1622:912 or zero-sized
[Parsed_pad_1 @ 0x697940] Failed to configure input pad on Parsed_pad_1
有什么方法可以保持分辨率不变并制作所有图像的视频吗?
假设您要调整所有图像的大小以适应 1280x720 canvas,请使用
ffmpeg -framerate 1/3 -pattern_type glob -i "images/*.jpg" -i trinity.MP3
-vf "scale='if(gt(a,1280/720),1280,-1)':'if(gt(a,1280/720),-1,720)':eval=frame,
pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1"
-c:v libx264 -r 30 -pix_fmt yuv420p -shortest -y out.mp4