nilaoda / N_m3u8DL-CLI

[.NET] m3u8 downloader 开源的命令行m3u8/HLS/dash下载器,支持普通AES-128-CBC解密,多线程,自定义请求头等. 支持简体中文,繁体中文和英文. English Supported.
https://nilaoda.github.io/N_m3u8DL-CLI/
MIT License
14.47k stars 2.18k forks source link

分片太多, 只合并部分后, 把这些部分再次合并在一起应该用什么命令? #574

Closed zsneala closed 2 years ago

zsneala commented 2 years ago

找了一些ffmpeg命令合并, 结果是输出的文件没有音轨

zsneala commented 2 years ago
LOG 2021/12/18
Save Path: C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\Logs
Task Start: 2021/12/18 15:44:03
Task CommandLine: "C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\N_m3u8DL-CLI_v2.9.9.exe" 

15:44:03.467 / (NORMAL) 开始解析 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/2021-12-17-12:42:11_2021-12-17-17:12:23_v.m3u8?bitrate=0&client=81&definition=yuanhua&pid=1199544618486&scene=vodreplay&vid=624356281
15:44:04.683 / (NORMAL) 写出meta.json
15:44:05.047 / (NORMAL) 开始下载文件
15:44:06.168 / (NORMAL) 读取文件信息...
15:44:06.565 / (NORMAL) PID 0x100: Video h264, yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn, 120 tbc
15:44:06.566 / (NORMAL) PID 0x101: Audio aac, 0 channels
15:49:00.952 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639727446_477669.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:49:01.960 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639727446_477669.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:50:43.475 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639720358_475968.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:50:44.485 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639720358_475968.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:52:16.438 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639724516_476966.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:52:17.453 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639724516_476966.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:59:49.560 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639722696_476529.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
15:59:50.574 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639722696_476529.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:00:31.218 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639719608_475788.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:00:32.228 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639719608_475788.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:00:58.217 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639724808_477036.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:00:59.222 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639724808_477036.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:05:46.778 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639729054_478055.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:05:47.794 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639729054_478055.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:09:56.777 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639726025_477328.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:09:57.782 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639726025_477328.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:10:18.641 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639728213_477853.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:10:19.654 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639728213_477853.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:14:38.230 / (ERROR) DOWN: 操作已超时。 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639718104_475427.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:14:39.243 / (ERROR) DOWN: AUTO RETRY 1/3 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639716125/1639718104_475427.ts?scene=vodreplay&client=81&vid=624356281&definition=yuanhua&bitrate=0&pid=1199544618486
16:15:57.100 / (NORMAL) 开始合并分片...
16:15:58.673 / (NORMAL) 分片大于1800个,执行分部合并中...
16:16:53.813 / (NORMAL) 结果输出至 [ffreport.log]
16:16:53.815 / (NORMAL) 任务结束

Task End: 2021/12/18 16:16:53
File: C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\Downloads\2021-12-17-12_42_11_2021-12-17-17_12_23_v_20211218154403.mp4
"C:\\Users\\xxx\\Downloads\\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\\ffmpeg.exe" -loglevel warning -i "concat:T0000.ts|T0001.ts|T0002.ts|T0003.ts|T0004.ts|T0005.ts|T0006.ts|T0007.ts|T0008.ts|T0009.ts|T0010.ts|T0011.ts|T0012.ts|T0013.ts|T0014.ts|T0015.ts|T0016.ts|T0017.ts|T0018.ts|T0019.ts|T0020.ts|T0021.ts|T0022.ts|T0023.ts|T0024.ts|T0025.ts|T0026.ts|T0027.ts|T0028.ts|T0029.ts|T0030.ts|T0031.ts|T0032.ts|T0033.ts|T0034.ts|T0035.ts|T0036.ts|T0037.ts|T0038.ts|" -map "0:v?" -map "0:a?" -map "0:s?" -metadata "date=2021-12-18T16:16:52.5276029+08:00" -metadata "encoding_tool=" -metadata "title=" -metadata "copyright=" -metadata "comment=" -metadata:s:a:0 "handler_name=" -metadata:s:a:0 "handler=" -c copy -y -bsf:a aac_adtstoasc "C:\\Users\\xxx\\Downloads\\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\\Downloads\\2021-12-17-12_42_11_2021-12-17-17_12_23_v_20211218154403.mp4"
ffmpeg version N-94813-g85386c36e3-ffmpeg-for-N_m3u8DL-CLI Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.0 (GCC)
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 56.101 / 58. 56.101
  libavformat    58. 32.104 / 58. 32.104
  libavfilter     7. 58.102 /  7. 58.102
  libavresample   4.  0.  0 /  4.  0.  0
  libswresample   3.  6.100 /  3.  6.100
[h264 @ 023b2440] non-existing SPS 0 referenced in buffering period
[h264 @ 023b2440] SPS unavailable in decode_picture_timing
[h264 @ 023b2440] non-existing SPS 0 referenced in buffering period
[h264 @ 023b2440] SPS unavailable in decode_picture_timing
[mpegts @ 02507500] start time for stream 1 is not set in estimate_timings_from_pts
[mpegts @ 02507500] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'concat:T0000.ts|T0001.ts|T0002.ts|T0003.ts|T0004.ts|T0005.ts|T0006.ts|T0007.ts|T0008.ts|T0009.ts|T0010.ts|T0011.ts|T0012.ts|T0013.ts|T0014.ts|T0015.ts|T0016.ts|T0017.ts|T0018.ts|T0019.ts|T0020.ts|T0021.ts|T0022.ts|T0023.ts|T0024.ts|T0025.ts|T0026.ts|T0027.ts|T0028.ts|T0029.ts|T0030.ts|T0031.ts|T0032.ts|T0033.ts|T0034.ts|T0035.ts|T0036.ts|T0037.ts|T0038.ts|':
  Duration: 04:30:03.42, start: 5.599000, bitrate: 10869 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn, 120 tbc
    Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 0 channels
[mp4 @ 0247e5c0] sample rate not set
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
nilaoda commented 2 years ago

看样子是流有问题 建议使用二进制合并

zsneala commented 2 years ago

把1800的限制去掉就没有问题了

LOG 2021/12/18
Save Path: C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\Logs
Task Start: 2021/12/18 21:45:09
Task CommandLine: "C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\N_m3u8DL-CLI.exe" 

21:45:09.472 / (NORMAL) 开始解析 https://v-replay-hw.cdn.huya.com/e-commerce/1199544618486-1199544618486-5363309925202132992-2399089360428-10057-A-0-1/1639629023/2021-12-16-12:30:29_2021-12-16-17:05:48.m3u8?bitrate=0&client=81&definition=yuanhua&pid=1199544618486&scene=vodreplay&vid=623806635
21:45:10.638 / (NORMAL) 写出meta.json
21:45:10.939 / (NORMAL) 开始下载文件
21:45:11.631 / (NORMAL) 读取文件信息...
21:45:12.562 / (NORMAL) PID 0x100: Video h264, yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn, 120 tbc
21:45:12.563 / (NORMAL) PID 0x101: Audio aac, 44100 Hz, stereo, fltp, 23 kb/s
22:37:30.853 / (NORMAL) 开始合并分片...
22:38:22.142 / (NORMAL) 将文件转换到 MPEG-TS 封装:Part_0.ts
22:41:43.158 / (NORMAL) 将文件转换到 MPEG-TS 封装:Part_1.ts
22:42:52.853 / (NORMAL) 结果输出至 [ffreport.log]
22:42:52.854 / (NORMAL) 任务结束

Task End: 2021/12/18 22:42:52
File: C:\Users\xxx\Downloads\N_m3u8DL-CLI_v2.9.9_with_ffmpeg_and_SimpleG\Downloads\2021-12-16-12_30_29_2021-12-16-17_05_48_20211218214509.mp4
nilaoda commented 2 years ago

你的第一个m3u8链接之所以会遇到1800的限制是因为这个m3u8中没有#EXT-X-DISCONTINUITY标记,程序会认为这一整个视频都是参数相同的TS片段,会全部使用ffmpeg合并,但是程序调用的参数传入有长度限制,故每N个小分片先合并为T0000.ts、T0001.ts、T0002.ts……之类的大分片,再使用ffmpeg来concat。这样的行为通常应对点播平台是没有问题的,但你这个应该是直播回放,存在服务器切片或主播网络波动等因素导致的某些TS包中不含有正确PTS信息的问题,让ffmpeg在封装mp4时无法构造moov box,自然无法合并。

第二个m3u8链接的内容有#EXT-X-DISCONTINUITY标记,它将m3u8分为了两个不同的部分,程序会认为这两个部分的视频参数可能不完全一样,则尝试以下动作:将各个分片二进制合并为Part0.ts、Part1.ts,然后使用ffmpeg对这两个大分片进行concat(这种情况常见于flv分片切片m3u8,如早期的搜狐视频)。

所以直播回放我建议直接使用二进制把他们统一合并为TS观看,这样最为万能。

PS:若只想要其中的某些片段,可以考虑使用--downloadRange选项,或使用GUI指定:

image