从mkv文件中提取src格式等字幕流

增加字幕流
ffmpeg -i video.avi -i sub.ass -map 0:0 -map 0:1 -map 1 -c:a copy -c:v copy -c:s copy video.mkv

从mkv文件中提取字幕流
1)原始文本输出
ffmpeg -i output.mkv -an -vn -bsf:s mov2textsub -scodec copy -f rawvideo sub.txt

ffmpeg -i output.mkv -an -vn -c:s copy -f rawvideo -map 0:s sub2.txt
2)字幕src格式输出(本人在制作mp4的外挂字幕时常用格式)
ffmpeg -i output.mkv -an -vn -scodec copy subtitle.ass

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要通过Java提取mkv视频的图片,可以使用开源的Java库Xuggler来实现。以下是一个简单的示例代码: ```java import com.xuggle.xuggler.ICodec; import com.xuggle.xuggler.IContainer; import com.xuggle.xuggler.IStream; import com.xuggle.xuggler.IStreamCoder; import com.xuggle.xuggler.IVideoPicture; public class ExtractImagesFromVideo { public static void main(String[] args) { String filename = "inputVideo.mkv"; String outputFolder = "outputImages/"; IContainer container = IContainer.make(); if (container.open(filename, IContainer.Type.READ, null) < 0) { throw new IllegalArgumentException("Could not open file: " + filename); } int numStreams = container.getNumStreams(); for (int i = 0; i < numStreams; i++) { IStream stream = container.getStream(i); IStreamCoder coder = stream.getStreamCoder(); if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) { coder.open(); IVideoPicture picture = IVideoPicture.make(coder.getPixelType(), coder.getWidth(), coder.getHeight()); IPacket packet = IPacket.make(); while (container.readNextPacket(packet) >= 0) { if (packet.getStreamIndex() == i) { int offset = 0; while (offset < packet.getSize()) { int bytesDecoded = coder.decodeVideo(picture, packet, offset); if (bytesDecoded < 0) { throw new RuntimeException("Error decoding video"); } offset += bytesDecoded; if (picture.isComplete()) { IImage image = picture.getImage(); BufferedImage javaImage = Utils.videoPictureToImage(picture); File outputfile = new File(outputFolder + "image-" + picture.getFormattedTimeStamp() + ".png"); ImageIO.write(javaImage, "png", outputfile); } } } } } coder.close(); } container.close(); } } ``` 以上代码使用Xuggle库来打开mkv视频文件,并提取视频的图像帧,然后将图像帧保存成png格式的图片文件。在实际使用过程,还可以根据需要对图像进行处理或者保存成其他格式的图片文件

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值