video - ffmpeg 使用图像和视频制作幻灯片
问题描述
我正在尝试使用应包含视频和图像的 ffmpeg 制作幻灯片。因为据我所知,ffmpeg 无法一步完成(这当然是更可取的步骤),所以我将其分解为一些图像的幻灯片,并将生成的视频与另一个视频连接起来。
这样做的问题是,当使用 ffmpeg 制作幻灯片时(如此处所述:https ://trac.ffmpeg.org/wiki/Slideshow ),会调整帧速率,以便更长时间地查看一张图像。
现在我有多个具有不同帧速率的视频要连接,这不好(我没有让它工作)。
我还尝试以更高的帧速率(使用-vf fps=25
)制作幻灯片,但我没有得到这个工作。
(因为我有来自不同位置的图像/不是当前目录的所有图像都应该立即连接我真的需要使用 concat demuxer(据我所知))
有人知道如何正确执行此操作吗?
我已经尝试过的:
ffmpeg -safe 0 -f concat -i tmp -vsync vfr -pix_fmt yuv420p -vf fps=25 output.mkv
文件 tmp 看起来像这样:(请参阅上面的链接以供参考)
file /path/to/file1.JPG
duration 2
file /path/to/file2.JPG
duration 2
file /path/to/file2.JPG
这给了我一个视频,不知何故只有第一张图片。
ffmpeg -safe 0 -f concat -i tmp -vsync vfr -pix_fmt yuv420p output.mkv
文件 tmp 看起来像这样:(请参阅上面的链接以供参考)
file /path/to/file1.JPG
duration 2
file /path/to/file2.JPG
duration 2
file /path/to/file2.JPG
这给了我一个文件,它以正确的速率显示所有图像(到目前为止的一切),但我无法将它与正确的视频(25fps)连接起来ffmpeg -safe 0 -f concat -i <(printf "file ${PWD}/%s\n" "output.mkv" "video.mp4") -c copy out.mkv
编辑:主要问题是这两个文件的串联:
$ mediainfo video2.MTS
General
ID : 1 (0x1)
Complete name : video2.MTS
Format : MPEG-TS
File size : 8.95 MiB
Duration : 8 s 240 ms
Overall bit rate mode : Variable
Overall bit rate : 9 024 kb/s
FileExtension_Invalid : ts m2t m2s m4t m4s tmf ts tp trp ty
Video
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : 27
Duration : 8 s 320 ms
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Writing library : x264 core 159 r2991 1771b55
Encoding settings : 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=12 / lookahead_threads=2 / 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
Audio
ID : 257 (0x101)
Menu ID : 1 (0x1)
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Format version : Version 4
Muxing mode : ADTS
Codec ID : 15-2
Duration : 8 s 192 ms
Bit rate mode : Variable
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : -21 ms
Menu
ID : 4096 (0x1000)
Menu ID : 1 (0x1)
Duration : 8 s 240 ms
List : 256 (0x100) (AVC) / 257 (0x101) (AAC)
Service name : Service01
Service provider : FFmpeg
Service type : digital television
和
$ mediainfo output.mkv
General
Unique ID : 28406040384100140874396026026809692875 (0x155ECDEBB2C5FEFE07B31D86D8B512CB)
Complete name : output.mkv
Format : Matroska
Format version : Version 4
File size : 10.2 MiB
Duration : 6 s 83 ms
Overall bit rate : 14.0 Mb/s
Writing application : Lavf58.29.100
Writing library : Lavf58.29.100
ErrorDetectionType : Per level 1
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L6
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 6 s 63 ms
Width : 5 184 pixels
Height : 3 888 pixels
Display aspect ratio : 4:3
Frame rate mode : Variable
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Writing library : x264 core 159 r2991 1771b55
Encoding settings : 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=12 / lookahead_threads=2 / 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
Default : Yes
Forced : No
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : A_AAC-2
Duration : 6 s 83 ms
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Writing library : Lavc58.54.100 aac
Default : Yes
Forced : No
解决方案
推荐阅读
- python - 使用 matplotlib 将最大和最小滑块添加到按钮
- c++ - VS2017,C++ 包含目录与附加包含目录,子文件夹包含失败 - 但为什么?
- solr - 如何在 Solr 7.5 中通过 POST 工具索引 csv 时禁止创建 copyFields?
- django - Django 使用 python-requests 进行身份验证
- c# - 是否可以使用 SecureString 作为 ProtectedData.Protect 的参数?
- gstreamer - GStreamer:如果音频比视频短,如何生成静音
- node.js - 在 Firebase 实时数据库中创建新密钥时如何获取电子邮件
- angular - ag-grid:根据同一行其他单元格中的内容禁用单元格
- mysql - 是否可以使用 EXISTS 而不是带有 DISTINCT 的 IN 子句来优化查询
- elasticsearch - 从 Elastic Search 的索引中获取未在聚合中使用的字段值