欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 海康视频不能在浏览器解析播放,需要转码

海康视频不能在浏览器解析播放,需要转码

2025/2/4 10:26:34 来源:https://blog.csdn.net/a2272062968/article/details/143358682  浏览:    关键词:海康视频不能在浏览器解析播放,需要转码

海康视频不能在浏览器解析播放,需要转码

参考:https://blog.csdn.net/xcg340123/article/details/139825982

依赖

        <dependency><groupId>ws.schild</groupId><artifactId>jave-core</artifactId><version>2.4.5</version></dependency><!--    核心包--><dependency><groupId>ws.schild</groupId><artifactId>jave-native-win64</artifactId><version>2.4.5</version></dependency><!--   这个是在windows环境下的jar,使用不同的环境,会调用不同的jar文件--><dependency><groupId>ws.schild</groupId><artifactId>jave-native-linux64</artifactId><version>2.4.5</version></dependency><!--   这个是在linux环境下的jar-->

转码逻辑

import ws.schild.jave.*;import java.io.File;public class VideoConvertUtil {public static void main(String[] args) throws EncoderException {convertH264();}public static void convertH264() throws EncoderException {//源视频位置File file = new File("C:\\Users\\Administrator\\Documents\\录入脚本\\video1.mp4");//目标视频位置File file1 = new File("C:\\Users\\Administrator\\Documents\\录入脚本\\video1test.mp4");// 创建转码器AudioAttributes audio = new AudioAttributes();//指定编码audio.setCodec("aac");audio.setBitRate(new Integer(128000));//通道audio.setChannels(new Integer(2));audio.setSamplingRate(new Integer(44100));VideoAttributes video = new VideoAttributes();//设置编解码器video.setCodec("h264");video.setX264Profile(VideoAttributes.X264_PROFILE.BASELINE);video.setBitRate(new Integer(1024 * 1024 * 2));//设置帧率video.setFrameRate(new Integer(25));//设置大小//video.setSize(new VideoSize(2560, 1440));EncodingAttributes attrs = new EncodingAttributes();//格式attrs.setFormat("mp4");//attrs.setAudioAttributes(audio);attrs.setVideoAttributes(video);// 进行转码Encoder encoder = new Encoder();encoder.encode(new MultimediaObject(file), file1, attrs);}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com