日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

合并ts文件

發布時間:2023/12/29 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 合并ts文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

合并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:@"
"];

    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

參考資料

http://www.tuicool.com/articles/Ivyie2e
http://my.oschina.net/zhangxu0512/blog/353861
http://blog.csdn.net/?aspxerrorpath=/blog/u011757360/20491055
http://blog.163.com/y_p_xu/blog/static/1708571022011896311101/

總結

以上是生活随笔為你收集整理的合并ts文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。