ffplay 播放字幕以及lrc歌词

# 各个容器可以容纳的字幕格式不同:
text:
mkv: copy, srt, ssa, ass 
mp4/mov: copy, mov_text
bitmap:
ts: dvb_subtitle
vob: dvd_subtitle (closed caption)

# ffplay 显示字幕
-sst 只能显示bitmap类;
使用filter来显示text类[gcw]:
#检查是否配置了--enable-libass --enable-libfreetype 
如果不是UTF-8,还要加上 --enable-iconv 
#使用独立的字幕文件
export FONTCONFIG_FILE=/usr/local/etc/fonts/fonts.conf
ffplay -vf subtitles=sub.srt:1x1 infile
其他关于字体属性的应该可以参考doc/filters.texi:drawtext,没试过。
#使用自带的第0个字幕流
#ffprobe infile -print_format ini -show_streams 2>/dev/null |grep "streams.stream\|codec_type\|codec_name"
ffplay -vf subtitles=infile:si=0 infile
# ffmpeg 转换
ffmpg只能把同一类的相互转换;
bitmap to text: ccextractor infile [ccextractor]依赖tesseract-ocr /leptonica

# 测试文件
取自[samples],其他常见的:
bbc_news -- dvb
starship -- dvd

thief -- srt



# 杂项
ffmpeg -f lavfi -i "movie=input.ts[out0+subcc]" -map s output.srt?
这个可以,是因为码流本身自带了文本数据 
mpeg12dec.c mpeg es userdata=0x1b2.a53_caption 
ffmpeg -i input.mkv -sub_charenc CP1252 -i subtitle.srt -map 0:v -map 0:a -c copy -map 1 -c:s:0 srt -metadata:s:s:0 language=fre output.mkv

# mp3 lrc
ffmpeg lrcdec.c 会把lrc转换为通用格式ass, 然后调用libass库渲染。例子:

./ffplay -f lavfi "color,subtitles=audio.lrc:force_style='FontName=DejaVu Serif,FontSize=28,MarginV=60,PrimaryColour=&HAA00FF00'[out0];amovie=audio.mp3[out1]"



# todo

上面的lavfi播放mp3是不能快进快退的。


# 参考
[samples] http://samples.ffmpeg.org/sub/ 
[gcw] http://boards.dingoonity.org/gcw-releases/ffplay-media-player/
[ccextractor] http://ncu.dl.sourceforge.net/project/ccextractor/ccextractor/0.76/ccextractor.src.0.76.zip

[skia] http://blog.csdn.net/kangear/article/details/38779867

[more]https://dev.haiku-os.org/ticket/6826

猜你喜欢

转载自blog.csdn.net/coloriy/article/details/80222104