TS文件无法转换成MP4格式

我从直播流的m3u8中下载下来的TS文件片段,在直播结束之后,使用ffmpeg合成整个文件时

ffmpeg  -f concat -safe 0 -i 1.txt -c copy 1.mp4

无法进行合成。提示如下错误:

[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[NULL @ 0000029825704f80] PPS id out of range: 0
[hevc @ 00000298257ae740] PPS id out of range: 0
[hevc @ 00000298257ae740] Error parsing NAL unit #1.
[concat @ 00000298256d97c0] decoding for stream 0 failed
[concat @ 00000298256d97c0] Could not find codec parameters for stream 0 (Video: hevc ([36][0][0][0] / 0x0024), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, concat, from '2020-08-26-07-22.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: hevc ([36][0][0][0] / 0x0024), none, 14.99 fps, 14.99 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 134 kb/s
[mp4 @ 0000029825f16700] dimensions 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)
    Last message repeated 1 times

后来我使用格式工厂,查看TS文件的属性,发现现在的TS文件中Video属性是这样的

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L3.1@Main
Codec ID                                 : 36
Duration                                 : 8 min 47 s
Width                                    : 720 pixels
Height                                   : 1 280 pixels
Display aspect ratio                     : 0.563
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits

而上述异常的TS文件中Video属性却少很多,没有Color space,Width,Height 等属性值。

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Codec ID                                 : 36
Duration                                 : 3 s 938 ms

有没有办法把这些属性直播添加到TS文件中呢?

链接:https://pan.baidu.com/s/1dXQy3TLx8HQd9ZxROV5M0A
提取码:1111

百度网盘中共享出来1个有问题的TS文件,请指教。

Could not find codec parameters for stream 0 (Video: hevc ([36][0][0][0] / 0x0024), none): unspecified size
数据格式的问题
解决参考:
https://blog.csdn.net/weixin_34187822/article/details/85926723

本地文件合并:

-i concat:"1.ts|2.ts|3.ts" -vcodec copy -acodec copy "合并.mp4" -y

远程合并:

-allowed_extensions ALL -protocol_whitelist "file,http,crypto,tcp,https,tls" -i "http://1.com/test.m3u8" -vcodec copy -acodec copy -absf aac_adtstoasc "合并.mp4"

另外检查m3u8里面有没有key文件