导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

合并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 /b “1.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:@"\n"];

    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

posted on   淅沥枫  阅读(5688)  评论(3编辑  收藏  举报

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示