zoukankan      html  css  js  c++  java
  • 合并ts文件

    合并ts文件

    合并ts文件

    文件在手机中的存储:

    ├── fe2cd5a64fe78a69f90a7c0a2b08a240e1444082.ts
    ├── ff5b590b44e676dc0a72d127fd165adaa0a478ec.ts
    ├── ff7085e695211f5e0b8cd239d51ad7870889c14b.ts
    ├── ....
    ├── ffec91db3441fd42adab27d0dbe26f424fc23a1d.ts
    ├── index.m3u8
    ├── index.m3u8.play
    ├── task.info

    1) 根据猎豹浏览器中的download.db,使用sqlite3打开文件,查看对应文件在手机浏览器中的真实路径.

    2) 通过手机插上U盘/移动硬盘,将文件拷贝到电脑

    3) 根据index.m3u8.play中的ts片段文件,生成一个总的ts文件.

    可以使用C/OC/python等,读取index.m3u8.play文件,生成类似下面的shell语句,即可合并为一个ts文件.

    windows:

     copy /b1.ts”+“2.ts”+…+”n.ts” /y “combine.ts

    mac:

      cat 1.ts 2.ts > combine.ts

    相关程序代码:

        //读文件
    
        NSString *fullFilePath = @"/xxx/index.m3u8.play";
    
        NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:fullFilePath ];
    
        NSData *data3 = [handle readDataToEndOfFile];
    
        NSString *temp = [[NSString alloc]initWithData:data3 encoding:NSUTF8StringEncoding];
    
        NSArray *tempArray = [temp componentsSeparatedByString:@"
    "];
    
        NSMutableArray *fileMArray = [NSMutableArray array];
    
        for (NSInteger index = 0 ; index < tempArray.count; index++) {
            NSString *fileContentLine = tempArray[index];
            if ([fileContentLine hasSuffix:@".ts"]) {
                [fileMArray addObject:fileContentLine];
            }
        }
        NSString *fileNames = [fileMArray componentsJoinedByString:@" "];
    
        //写入文件
    
        NSString *toPath = @"/yyy/combineTSFile.sh";
        NSFileHandle *handle2 = [NSFileHandle fileHandleForWritingAtPath:toPath];
    
        NSLog(@"%s [LINE:%d] fileNames=%@", __func__, __LINE__,fileNames);
    
        NSData *data = [fileNames dataUsingEncoding:NSUTF8StringEncoding];
        [handle2 writeData:data];    
        [handle2 synchronizeFile];
        [handle2 closeFile];
    

    4) 将ts文件转换为mp4文件

    ffmpeg -i combine.ts -acodec copy -vcodec copy -bsf aac_adtstoasc output.mp4
  • 相关阅读:
    5_添加购物车 View+Con
    5_添加购物车 B+M
    5_添加购物车 D
    登录注册V
    bootstrap-标题
    h5整理--详解css的相对定位和绝对定位
    各大门户网站的css初始化代码
    九月二十八JS验证
    js函数和运算符
    4.1原始表达式 9/16
  • 原文地址:https://www.cnblogs.com/xilifeng/p/4692368.html
Copyright © 2011-2022 走看看