Hunter的大杂烩 技术学习笔记

2024-07-15

ffmpeg硬编码字幕中遇到GBK字符解决方法

Filed under: 技术话题 — hunter @ 11:14 pm

使用 -vf subtitle 过滤器时,遇到字幕中有GBK字符,出现错误信息:

Error decoding subtitles: Invalid data found when processing input
[srt @ 000002833affeb00] Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option

虽然还可以编码,但是视频中,有GBK字符的字幕统统没有显示,说明过滤器处理不了,直接丢弃了

按提示使用 -sub_charenc 选项,错误信息仍然存在,将编码指令改为

ffmpeg -i “40 Meets Molly Cule.mkv” -sub_charenc GBK -i “40 Meets Molly Cule.srt” -c:v mpeg2_qsv -qscale 8 -c:a mp3 -c:s mov_text “40 Meets Molly Cule.mpeg”

后,不出错,但是字幕完全无法显示

翻阅 subtitle 过滤器说明(https://ffmpeg.org//ffmpeg-filters.html#subtitles-1),发现有charenc参数,最终将编码指令改为:

ffmpeg -i “40 Meets Molly Cule.mkv” -c:v mpeg2_qsv -qscale 8 -c:a mp3 -vf subtitles=”filename=40 Meets Molly Cule.srt:charenc=GBK” “40 Meets Molly Cule.mpeg”

完成~

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress