使用ffmpeg提取帧并包含字幕


0

我试图使用ffmpeg从带有字幕的视频中提取单个帧。

我自己建了ffmpeg:

sircmpwn@picard ~/sources/bakabt-staging/hennkeo/groups $ ffmpeg
ffmpeg version N-54036-g6c4516d Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun 15 2013 11:56:01 with gcc 4.7 (Ubuntu/Linaro 4.7.3-1ubuntu1)
  configuration: --prefix=/home/sircmpwn/ffmpeg_build --extra-cflags=-I/home/sircmpwn/ffmpeg_build/include --extra-ldflags=-L/home/sircmpwn/ffmpeg_build/lib --bindir=/home/sircmpwn/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      52. 35.101 / 52. 35.101
  libavcodec     55. 16.100 / 55. 16.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 77.101 /  3. 77.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

我运行这个:

sircmpwn@picard ~/sources/bakabt-staging/hennkeo/groups $ ffmpeg -ss 00:09:18 -i horrible.mkv -sn -vf ass=horrible.ass -t 1 -vframes 1 horrible-1.png
ffmpeg version N-54036-g6c4516d Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun 15 2013 11:56:01 with gcc 4.7 (Ubuntu/Linaro 4.7.3-1ubuntu1)
  configuration: --prefix=/home/sircmpwn/ffmpeg_build --extra-cflags=-I/home/sircmpwn/ffmpeg_build/include --extra-ldflags=-L/home/sircmpwn/ffmpeg_build/lib --bindir=/home/sircmpwn/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      52. 35.101 / 52. 35.101
  libavcodec     55. 16.100 / 55. 16.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 77.101 /  3. 77.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, matroska,webm, from 'horrible.mkv':
  Metadata:
    creation_time   : 2013-05-26 13:34:41
  Duration: 00:23:42.11, start: 0.000000, bitrate: 1900 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30.30 fps, 30.30 tbr, 1k tbn, 59.94 tbc (default) (forced)
    Stream #0:1: Audio: aac, 44100 Hz, stereo, fltp (default) (forced)
    Stream #0:2: Subtitle: ssa (default) (forced)
Codec 0x18000 is not in the full list.
    Stream #0:3: Attachment: unknown_codec
    Metadata:
      filename        : OpenSans-Semibold.ttf
      mimetype        : application/x-truetype-font
[Parsed_ass_0 @ 0x3521780] Added subtitle file: 'horrible.ass' (9 styles, 374 events)
Output #0, image2, to 'horrible-1.png':
  Metadata:
    encoder         : Lavf55.8.102
    Stream #0:0: Video: png, rgb24, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 30.30 tbc (default) (forced)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A dup=0 drop=57    
video:364kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.005907%

这给了我这个形象。所需的图像有点像这一个

Answers:


1

好吧,答案是在#ffmpeg IRC上找到的。问题是参数的排序(毫无疑问)。正确的调用是:

ffmpeg -i horrible.mkv -ss 00:09:18 -vf ass=horrible.ass -vframes 1 horrible-1.png

我遇到了你可能会分享的第二个字体问题。ffmpeg不会使用您提供的媒体中的字体,因此您首先必须将它们安装到您的系统中。我在IRC上修改了一个脚本,它将视频文件中的字体提取到〜/ .fonts中:https://gist.github.com/SirCmpwn/5789762


考虑在FFmpeg Bug Tracker上添加嵌入字体作为功能请求的使用,或者如果感兴趣的话,提交补丁以实现此功能到ffmpeg-devel邮件列表
llogan 2013年

0

你的命令有-sn-sn基本上意味着“没有字幕”。ffmpeg表现得很好。

搜索-sn的文档

你的解决方案没有-sn

我可能完全离开了,但这很可能解决了你的第一个问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.