gpt4 book ai didi

video - 使用 FFmpeg 创建缩略图

转载 作者:行者123 更新时间:2023-11-28 21:41:22 26 4
gpt4 key购买 nike

我正在使用 FFmpeg 从视频文件的特定位置提取缩略图。

我在网上找到了两种方法:

  1. -i(输入)参数之前加上-ss(查找)参数:

    ffmpeg -y -ss $SEEK_POINT -i input.ogv -vcodec mjpeg -vframes 1 -an -s 120x90 -f rawvideo output.jpg

  2. -i(输入)参数之后加上-ss(查找)参数:

    ffmpeg -y -i input.ogv -vcodec mjpeg -ss $SEEK_POINT -vframes 1 -an -s 120x90 -f rawvideo output.jpg

第一种方法生成带有灰色 Blob 的不良缩略图,但速度非常快。返回的错误是[theora @ 0x8097240] vp3: first frame not a keyframe

第二种方法总是有效,但会显示错误,导致提取需要很长时间。这个时间量不是固定的,它取决于我注意到的搜索点。有时提取缩略图需要几秒钟,有时需要几分钟。我收到错误 不支持缓冲多个帧。请在添加新帧之前使用所有可用帧。 在以下输出中:

Input #0, ogg, from 'input.ogv':
Duration: 00:21:52.76, start: 0.000000, bitrate: 844 kb/s
Stream #0.0: Video: theora, yuv420p, 800x600 [PAR 4:3 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: vorbis, 44100 Hz, stereo, s16, 192 kb/s
Metadata:
ENCODER : Lavf52.102.0
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0x9250840] w:800 h:600 pixfmt:yuv420p
[scale @ 0x92508a0] w:800 h:600 fmt:yuv420p -> w:120 h:90 fmt:yuvj420p flags:0x4
Output #0, rawvideo, to 'output.jpg':
Metadata:
encoder : Lavf53.2.0
Stream #0.0: Video: mjpeg, yuvj420p, 120x90 [PAR 4:3 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
[buffer @ 0x9250840] Buffering several frames is not supported. Please consume all available frames before adding a new one.
frame= 0 fps= 0 q=0.0 size= 0kB time=10000000000.00 bitrate= 0.0kbit
Last message repeated 15448 times
frame= 1 fps= 0 q=3.4 Lsize= 3kB time=0.04 bitrate= 598.8kbits/s
video:3kB audio:0kB global headers:0kB muxing overhead 0.000000%

无论输入格式如何,如何使用 FFmpeg 从视频的自定义位置毫无问题地提取缩略图?

最佳答案

使用 itsoffset 选项尝试这样的事情:

ffmpeg -itsoffset 4 -i "$INFILE" -vcodec png -vframes 1 -an -f rawvideo -s 120x90 -y "$OUTFILE"

来自关于 itsoffset 的 FFmpeg 文档:

Set the input time offset in seconds. [-]hh:mm:ss[.xxx] syntax is also supported. The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by offset seconds.

关于video - 使用 FFmpeg 创建缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8170860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com