当前位置: 首页> 健康> 知识 > 制作灯笼作文300字_广西网络营销外包公司_seo优化师就业前景_百度信息流广告怎么投放

制作灯笼作文300字_广西网络营销外包公司_seo优化师就业前景_百度信息流广告怎么投放

时间:2025/7/9 0:22:00来源:https://blog.csdn.net/qq_55946937/article/details/148859715 浏览次数:0次
制作灯笼作文300字_广西网络营销外包公司_seo优化师就业前景_百度信息流广告怎么投放

流程

        1.将时间戳,源文件名称和地址,输出文件名称地址写入excel.

        2.读取excel文件并循环执行ffmpeg指令

excel表格内容

E:\aht\PIQBR2021Q3.mp30:34:130:33:23E:\aht\ddd\lowlight.mp3
E:\aht\PIQBR2021Q3.mp31:29:081:28:12E:\aht\ddd\look_forward_to.mp3
E:\aht\STQBR2023Q3.mp30:18:140:13:06E:\aht\ddd\customer.mp3

  代码

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;import java.io.*;
import org.apache.poi.ss.usermodel.*;import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;public class MP3Trimmer {public static void main(String[] args) throws IOException {getExcelData();
//        MP3Trimmer("E:\\aht\\EnglishPath\\ttt.mp3","0:00:00","0:00:07","E:\\aht\\EnglishPath\\0102.mp3");}public static void MP3Trimmer(String file, String startTime, String endTime, String outFile) {try {// 执行一个命令String command = "ffmpeg -i \""+file+"\" -ss "+startTime+" -to "+endTime+" -c copy \""+outFile+"\"";  // 你可以更改为任何 cmd 命令Process process = Runtime.getRuntime().exec(command);// 获取命令执行的输出InputStream inputStream = process.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));String line;while ((line = reader.readLine()) != null) {System.out.println(line);}// 等待命令执行完成int exitCode = process.waitFor();System.out.println("命令执行完成,退出码:" + exitCode);} catch (IOException | InterruptedException e) {e.printStackTrace();}}public static void getExcelData() throws IOException {// 加载 Excel 文件FileInputStream file = new FileInputStream(new File("E:\\aht\\EnglishPath\\yyyy.xlsx"));// 创建工作簿对象Workbook workbook = new XSSFWorkbook(file);// 获取第一个工作表Sheet sheet = workbook.getSheetAt(0);// 读取前20行和前3列for (int rowNum = 0; rowNum < 300; rowNum++) {Row row = sheet.getRow(rowNum);String infile="";String startTime="";String endTime="";String outFile="";if (row != null) { // 检查当前行是否为 nullfor (int colNum = 0; colNum < 4; colNum++) {Cell cell = row.getCell(colNum);if (cell != null) {// 根据单元格类型读取值switch (cell.getCellType()) {case 1:if (colNum == 0) {infile=cell.getStringCellValue();}else if (colNum == 1) {startTime=cell.getStringCellValue();}else if (colNum == 2) {endTime=cell.getStringCellValue();}else if (colNum == 3) {outFile=cell.getStringCellValue();}System.out.print(cell.getStringCellValue() + "\t");break;case 0:if (DateUtil.isCellDateFormatted(cell)) {// 如果单元格是日期或时间,格式化输出SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");if (colNum == 0) {infile=sdf.format(cell.getDateCellValue());}else if (colNum == 1) {startTime=sdf.format(cell.getDateCellValue());}else if (colNum == 2) {endTime=sdf.format(cell.getDateCellValue());}else if (colNum == 3) {outFile=sdf.format(cell.getDateCellValue());}System.out.print(sdf.format(cell.getDateCellValue()) + "\t");} else {if (colNum == 0) {infile=cell.getStringCellValue();}else if (colNum == 1) {startTime=cell.getStringCellValue();}else if (colNum == 2) {endTime=cell.getStringCellValue();}else if (colNum == 3) {outFile=cell.getStringCellValue();}System.out.print(cell.getNumericCellValue() + "\t");}break;case 2:if (colNum == 0) {infile=cell.getStringCellValue();}else if (colNum == 1) {startTime=cell.getStringCellValue();}else if (colNum == 2) {endTime=cell.getStringCellValue();}else if (colNum == 3) {outFile=cell.getStringCellValue();}System.out.print(cell.getBooleanCellValue() + "\t");break;case 3:if (colNum == 0) {infile=cell.getStringCellValue();}else if (colNum == 1) {startTime=cell.getStringCellValue();}else if (colNum == 2) {endTime=cell.getStringCellValue();}else if (colNum == 3) {outFile=cell.getStringCellValue();}System.out.print(cell.getCellFormula() + "\t");break;case 4:System.out.print("BLANK" + "\t");break;case 5:System.out.print("ERROR" + "\t");break;}} else {System.out.print("EMPTY" + "\t");}}}MP3Trimmer(infile,startTime,endTime,outFile);System.out.println(); // 换行}// 关闭文件流file.close();workbook.close();}}

关键字:制作灯笼作文300字_广西网络营销外包公司_seo优化师就业前景_百度信息流广告怎么投放

版权声明:

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

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

责任编辑: