标签: ffmpeg

通过场景检测使用 FFMPEG 拆分视频

我看到了这个线程,它几乎完全符合我的要求,但我实际上正在寻找场景检测的拆分。

自动将大型 .mov 视频文件拆分为黑帧(场景变化)的较小文件?

例如,假设我在 0:01 -> 0:05 有一个女人在屏幕上,然后从 0:06 -> 0:09 有一个男人在不同的场景中,然后从 0:10 到屏幕上有第二个女人 - > 0:14

这(理想情况下)将创建三个不同的视频剪辑。如果可能的话,我真的很喜欢它到帧级别,并在场景变化时自动检测。

** 更新 **

好的,我有一个很好的开始。我已经使用 FFProbe 完成了以下操作:

ffprobe -show_frames -of compact=p=0 -f lavfi "movie=foo.mp4,select=gt(scene\,.4)" > foo.txt
Run Code Online (Sandbox Code Playgroud)

这给了我一个似乎完全正确的时间戳列表!现在下一步 - 我如何获取这个时间戳列表并将它们输入回 ffmpeg 以拆分它?这是时间戳的示例。

media_type=video|key_frame=1|pkt_pts=972221|pkt_pts_time=10.802456|pkt_dts=972221|pkt_dts_time=10.802456|best_effort_timestamp=972221|best_effort_timestamp_time=10.802456|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=5083698|pkt_size=6220800|width=1920|height=1080|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|tag:lavfi.scene_score=0.503364
media_type=video|key_frame=1|pkt_pts=2379878|pkt_pts_time=26.443089|pkt_dts=2379878|pkt_dts_time=26.443089|best_effort_timestamp=2379878|best_effort_timestamp_time=26.443089|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=12736403|pkt_size=6220800|width=1920|height=1080|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|tag:lavfi.scene_score=1.000000
media_type=video|key_frame=1|pkt_pts=2563811|pkt_pts_time=28.486789|pkt_dts=2563811|pkt_dts_time=28.486789|best_effort_timestamp=2563811|best_effort_timestamp_time=28.486789|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=13162601|pkt_size=6220800|width=1920|height=1080|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|tag:lavfi.scene_score=0.745838
media_type=video|key_frame=1|pkt_pts=2627625|pkt_pts_time=29.195833|pkt_dts=2627625|pkt_dts_time=29.195833|best_effort_timestamp=2627625|best_effort_timestamp_time=29.195833|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=13485087|pkt_size=6220800|width=1920|height=1080|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|tag:lavfi.scene_score=0.678877
Run Code Online (Sandbox Code Playgroud)

video ffmpeg video-editing

20
推荐指数
1
解决办法
2万
查看次数

ffmpeg:编码 h264 时限制为单 CPU 核心

我需要在后台降低一些 H.264 视频的帧速率,而不用尽我的 CPU(在 Linux 上)。不知何故-threads 1根本没有效果:

ffmpeg -threads 1 -i 50fps.mp4 -filter:v fps=30 30fps.mp4
Run Code Online (Sandbox Code Playgroud)

流信息:

Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt470bg, progressive)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D)
Run Code Online (Sandbox Code Playgroud)

所有核心仍处于最大状态。我怎样才能将其限制为只有一个核心?H.265 有一个特定于编码器的选项(pools=none),我可以在这里使用类似的选项吗?

video cpu-usage ffmpeg video-encoding

20
推荐指数
3
解决办法
2万
查看次数

如何从 MKV 文件中剥离音频流?

我一直在尝试从 MKV (Matroska) 文件中删除不需要的音频流。我要这样做的原因是为了避免在 Windows Media Player 中手动选择所需的流。

输入文件提供以下 ffmpeg 信息:

Stream #0.0: Video: mpeg4, yuv420p, 704x396 [PAR 1:1 DAR 16:9], 29.98 tbr, 1k tbn, 29.98 tbc
Stream #0.1(eng): Audio: aac, 24000 Hz, 5.1, s16
Stream #0.2(jpn): Audio: aac, 24000 Hz, 5.1, s16
Stream #0.3(eng): Subtitle: 0x0000
Stream #0.4(eng): Subtitle: 0x0000
Stream #0.5: Attachment: 0x0000
Stream #0.6: Attachment: 0x0000
Run Code Online (Sandbox Code Playgroud)

由于我想要流 0、1 和 3(子),因此我的 ffmpeg 命令如下所示:

ffmpeg -i input.mkv -map 0:0 -map 0:1 -map 0:3 -vcodec copy -acodec libmp3lame -newsubtitle test.mkv …
Run Code Online (Sandbox Code Playgroud)

video ffmpeg

19
推荐指数
1
解决办法
4万
查看次数

FFmpeg 的“-vcodec copy”和“-sameq”有什么区别?

使用-vcodec copy-sameq使用 FFmpeg 有什么区别?

他们做同样的事情吗?

codec ffmpeg video-conversion

19
推荐指数
2
解决办法
6万
查看次数

FFmpeg 在将 png 图像序列编码为 x264 mp4 视频时丢帧

我正在尝试使用以下命令将图像序列 ( frame0001.png, frame0002.png, ... , frame0160.png)编码为 x264 视频:

ffmpeg -i frame%04d.png -sameq -r 24 out.mp4
Run Code Online (Sandbox Code Playgroud)

编码后,它说drop=5视频中确实有明显的“跳跃”。

似乎其他人也有类似的问题,但对我来说,接受的答案并不是很有用,因为我不希望丢帧。

命令中是否缺少开关?还是我做错了什么?


编辑:添加控制台输出:

ffmpeg version N-42347-g299387e Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul  8 2012 15:46:39 with gcc 4.7.1
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3
 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzli
b --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --
enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lam
e --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger
 --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc
--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --en …
Run Code Online (Sandbox Code Playgroud)

mp4 ffmpeg video-encoding

19
推荐指数
2
解决办法
3万
查看次数

ffmpeg 使用 YUYV 打开网络摄像头,但我想要 MJPEG

我需要 ffmpeg 在 MJPEG 模式下打开网络摄像头(罗技 C910),因为网络摄像头可以使用 MJPEG“协议”提供 ~24 fps,而使用 YUYV 只能提供 ~10 fps。我可以使用 ffmpeg 命令行在它们之间进行选择吗?

xx@(none) ~ $ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUV 4:2:2 (YUYV)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : MJPEG
Run Code Online (Sandbox Code Playgroud)

我当前的命令行:

ffmpeg -y -f alsa -i hw:3,0 -f video4linux2 -r 20 -s 1280x720 -i /dev/video0 -acodec libfaac -ab 128k -vcodec libx264 /tmp/web.avi
Run Code Online (Sandbox Code Playgroud)

当我从网络摄像头录制时,ffmpeg 会产生损坏的 h264 流,但是当我从 x11grab 录制时会产生正常的 h264 …

webcam ffmpeg v4l2 mjpeg

19
推荐指数
1
解决办法
5万
查看次数

使用 ffmpeg/avconv 将视频转换为 WebM

尝试优化我的家庭视频的大小时,我将其中一些转换为 WebM 作为测试,在 Xubuntu 上使用 Pitivi。大小差异显着。生成的 webm 文件只有原始文件的 10% 左右,而图片质量在我看来几乎相同。

我还尝试使用进行转换,avconv以便我可以编写脚本,但生成的文件看起来非常糟糕。在查看 Pitivi 中的渲染设置后,我尝试了一些参数:avconv -i $1 -q 5 -qmin 0 -qmax 63 ${1%.*}.webm,但质量看起来仍然很糟糕,所以我似乎缺少/使用了一些错误的参数。有人知道哪些是用于将 h264 电影转换为 webm 并获得与 Pitivi 相同质量的正确参数吗?

这些是 Pitivi 中的设置: 创建 Pitivi 项目 渲染到 webm(html5 视频) 编解码器配置

bash ffmpeg webm

19
推荐指数
1
解决办法
2万
查看次数

如何摆脱ffmpeg pts没有值错误

我正在尝试将 AVI 文件转换为 MP4 文件。视频流是 XVID,而音频流是 MP3。

问题是生成的 MP4 文件无法在 Mac 上的 QuickTime Player 中播放。它在 VLC 上播放。虽然它不是一个交易破坏者,但我想知道如何导致这些问题。

命令及其输出如下:

$ ffmpeg -i 103.avi -codec copy -f mp4 103.mp4

ffmpeg version N-60163-g78a9f18 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan 25 2014 14:03:47 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: 
  libavutil      52. 63.100 / 52. 63.100
  libavcodec     55. 49.100 / 55. 49.100
  libavformat    55. 26.100 / 55. 26.100
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.101 …
Run Code Online (Sandbox Code Playgroud)

ffmpeg

19
推荐指数
1
解决办法
3万
查看次数

ffmpeg 和“无法找到合适的输出”错误

我正在尝试将大型 MKV 转换为老式 AVI 文件。

我正在尝试这个:

ffmpeg -i video.mkv -s -codec:v mpeg4 -bf 1 -b 2567k -mbd 2 -g 300 -flags cgop -acodec copy video.avi
Run Code Online (Sandbox Code Playgroud)

但我明白了

[NULL @ 0x7fa0d901e600] Unable to find a suitable output format for 'mpeg4' mpeg4: Invalid argument

ffmpeg 消息的长版...

ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb  4 2014 17:53:32 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.3 --enable-shared     --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-     hardcoded-tables --enable-avresample --enable-vda --cc=clang …
Run Code Online (Sandbox Code Playgroud)

video avi ffmpeg video-codecs

19
推荐指数
1
解决办法
12万
查看次数

ffmpeg concat 不适用于绝对路径

我需要将 concat 与绝对路径一起使用,但它似乎不起作用。在文档中它说它应该工作。任何人都知道如何使它工作? ffmpeg 文档

它不起作用,因为它似乎将文本文件目录附加到文件路径

Impossible to open 'C:/temp/ffmpeg/c:/temp/ffmpeg/01.mov'
Run Code Online (Sandbox Code Playgroud)

我使用 Windows 7。

ffmpegTest.txt:
file 'c:/temp/ffmpeg/01.mov'
file 'c:/temp/ffmpeg/02.mov'

"Y:/Shotgun/bin/ffmpeg/bin/ffmpeg.exe" -f concat -i "C:/temp/ffmpeg/ffmpegTest.txt" -c copy "C:/temp/ffmpeg/test.mov
ffmpeg version N-58949-g0e575c2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Dec  9 2013 22:06:49 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 …
Run Code Online (Sandbox Code Playgroud)

video ffmpeg

19
推荐指数
3
解决办法
3万
查看次数