当前位置: 首页 > wzjs >正文

wordpress 删除没用5g站长工具seo综合查询

wordpress 删除没用,5g站长工具seo综合查询,成都app开发公司排名,网上做批发那个网站好今天发现一个ffmpeg的用法,用子进程直接从标准输入写入输入,就可以从标准流式输出获取转码结果。 这样的好处是不用去写ffmpeg的代码,只需要写对ffmpeg的命令、在输入输出的地方加缓存就能进行流式转码了,方便快捷。 package ffm…

今天发现一个ffmpeg的用法,用子进程直接从标准输入写入输入,就可以从标准流式输出获取转码结果。
这样的好处是不用去写ffmpeg的代码,只需要写对ffmpeg的命令、在输入输出的地方加缓存就能进行流式转码了,方便快捷。

package ffmpegPro;
import java.io.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;public class Main {public static void main(String[] argv) {ExecutorService executor = Executors.newFixedThreadPool(8);Future<?> f1 = executor.submit(()->{progress("D:\\data\\audio\\a_out.wav","D:\\data\\audio\\a_output.pcm", executor);});Future<?> f2 = executor.submit(()->{progress("D:\\data\\audio\\b_out.wav","D:\\data\\audio\\b_output.pcm", executor);});try {f1.get();f2.get();} catch (InterruptedException | ExecutionException e) {e.printStackTrace();}executor.shutdown();}public static void progress(String inputPath, String outputPath, ExecutorService executor) {try {// 1. 定义 FFmpeg 命令(示例:H264 → VP9,实时转码)String[] ffmpegCmd = {"ffmpeg","-loglevel", "error","-hide_banner", "-nostats", //关闭日志"-f", "wav",      // 输入格式"-i", "pipe:0",    // 从标准输入读取"-f", "s16le",      // 输出格式"-acodec", "pcm_s16le","-ar", "8000",       // 16kHz"-ac", "1",           // 单声道"pipe:1"           // 输出到标准输出};// 2. 启动 FFmpeg 进程ProcessBuilder pb = new ProcessBuilder(ffmpegCmd);Process process = pb.start();// 3. 获取输入/输出流OutputStream ffmpegStdin = process.getOutputStream(); // FFmpeg 的 stdinInputStream ffmpegStdout = process.getInputStream(); // FFmpeg 的 stdoutInputStream ffmpegStderr = process.getErrorStream();  // FFmpeg 的 stderr(日志)// 4. 异步读取转码后的数据(防止阻塞)// 线程1:读取 FFmpeg 的输出(转码后的数据)executor.submit(() -> {byte[] buffer = new byte[8192];int bytesRead;try {FileOutputStream pcmFile = new FileOutputStream(outputPath);while ((bytesRead = ffmpegStdout.read(buffer)) != -1) {// 处理转码后的数据(示例:写入文件或推送到网络)System.out.println("收到转码数据,长度: " + bytesRead);pcmFile.write(buffer, 0, bytesRead);}} catch (IOException e) {e.printStackTrace();}});// 线程2:打印 FFmpeg 的错误日志(调试用)executor.submit(() -> {try (BufferedReader reader = new BufferedReader(new InputStreamReader(ffmpegStderr))) {String line;while ((line = reader.readLine()) != null) {System.err.println("[FFmpeg] " + line);}} catch (IOException e) {e.printStackTrace();}});// 5. 模拟向 FFmpeg 发送原始数据(示例:从文件读取)try (InputStream rawVideoStream = new FileInputStream(inputPath)) {byte[] buffer = new byte[8192];int bytesRead;while ((bytesRead = rawVideoStream.read(buffer)) != -1) {ffmpegStdin.write(buffer, 0, bytesRead);System.out.println("已发送原始数据,长度: " + bytesRead);}ffmpegStdin.close(); // 关闭输入流,通知 FFmpeg 结束} catch (IOException e) {e.printStackTrace();}// 6. 等待 FFmpeg 结束try {int exitCode = process.waitFor();System.out.println("FFmpeg 进程结束,退出码: " + exitCode);} catch (InterruptedException e) {e.printStackTrace();}} catch (Exception e) {e.printStackTrace();}}
}
http://www.dtcms.com/wzjs/186221.html

相关文章:

  • 下载人民日报客户端武汉seo首页优化技巧
  • 做网站后端语言用什么重庆高端品牌网站建设
  • 网站建设单页面推广模板上海网站推广优化
  • 外贸网站推广招聘facebook海外推广
  • 西宁市网站建设价格网站推广的方式
  • 香港做网站什么费用营销模式都有哪些
  • 虎门镇网站建设公司发稿网
  • wordpress商业用途官方进一步优化
  • 大型网站建设推广地推接单正规平台
  • yes风淘宝网站上海网站关键词排名优化报价
  • 网站设计与管理semiconductor是什么意思
  • 网站管理系统排行榜百度seo排名点击
  • 网站布局方式站长工具精品
  • php 政府网站管理系统关联词有哪些关系
  • 在家做网站建设搜索引擎竞价广告
  • 网站多服务器建设关键词查询工具
  • 企业网站建设公司那家好百度百家号官网登录
  • 公司网站做的一样算不算侵权百度sem竞价推广
  • 浙江响应式网站建设制作优化教程网官网
  • 信息流广告公司沧州网站seo
  • 娱乐网站建设网站的排名优化怎么做
  • wordpress 做网站2022黄页全国各行业
  • 做网站公司选哪家百度关键词seo公司
  • 网站建设实例教程网页设计模板
  • 做一个网站成本多少钱湖南网站托管
  • 中国做外贸网站有哪些网站建设网站定制
  • wordpress 体育seo网站编辑优化招聘
  • wordpress十大主题野狼seo团队
  • 一流的赣州网站建设百度识图网页版入口
  • 不错的网站建设公司ios aso优化工具