添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Local windows can be used, but it cannot be used when deployed to linux. Linux is a centos system, x86 architecture, 64-bit, and windows uses an intel i5 processor

2022-10-25 23:40:05.296 ERROR 14124 --- [nio-9979-exec-3] ws.schild.jave.Encoder                   : Process exit code: 137  to 69f1ba49-1f3f-4cd7-bd89-3cf7c877caed.mp4
ws.schild.jave.EncoderException: Exit code of ffmpeg encoding run is 137
    at ws.schild.jave.Encoder.encode(Encoder.java:572)
    at ws.schild.jave.Encoder.encode(Encoder.java:351)
    at ws.schild.jave.Encoder.encode(Encoder.java:318)

I hope that the old man who will teach me again, I will be very grateful

* 将mov格式频频转换为MP4 * @param inputStream * @return 转换后的文件 public static InputStream movToMp4(InputStream inputStream, String type){ //定义本地路径(mov) String temporaryMovUrl = temporary + "/" + UUID.randomUUID().toString() + "." + type; //定义本地路径(mp4) String temporaryMp4Url = temporary + "/" + UUID.randomUUID().toString() + ".mp4"; try { //保存mov文件到临时目录 writeToLocal(temporaryMovUrl,inputStream); //从临时文件加载mov视频 File source = new File(temporaryMovUrl); //定义转换为mp4的输出地址 File target = new File(temporaryMp4Url); AudioAttributes audio = new AudioAttributes(); // audio.setCodec("libmp3lame"); // audio.setCodec("aac"); //设置比特率 audio.setBitRate(236000 / 2); //设置音频通道数 audio.setChannels(2); //设置采样率 audio.setSamplingRate(8000); VideoAttributes video = new VideoAttributes(); // video.setCodec("h264"); // video.setCodec("libx264"); video.setBitRate(new Integer(1000000)); video.setFrameRate(new Integer(25)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setOutputFormat("mp4"); //设置最长截取30秒 attrs.setDuration(new Float("30")); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(new MultimediaObject(source), target, attrs); return new FileInputStream(new File(temporaryMp4Url)); } catch (Exception e) { e.printStackTrace(); }finally { //删除mov格式文件 //删除临时文件 FileSystemUtils.deleteRecursively(new File(temporaryMovUrl)); FileSystemUtils.deleteRecursively(new File(temporaryMp4Url)); return null;

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.