justdan96 / tsMuxer

tsMuxer is a transport stream muxer for remuxing/muxing elementary streams, EVO/VOB/MPG, MKV/MKA, MP4/MOV, TS, M2TS to TS to M2TS. Supported video codecs H.264/AVC, H.265/HEVC, VC-1, MPEG2. Supported audio codecs AAC, AC3 / E-AC3(DD+), DTS/ DTS-HD.
Apache License 2.0
860 stars 144 forks source link

Mux TS files downloaded from Twitch #789

Closed superbonaci closed 11 months ago

superbonaci commented 12 months ago

Could be possible to mux files from https://www.twitch.tv/

Some programs that can download the .ts parts are

I've tried a sample and says lots of unrecognised tracks.

jcdr428 commented 11 months ago

@superbonaci can you please provide the mentionned sample with unrecognised tracks.

superbonaci commented 11 months ago

The app used is tsMuxeR GUI 2.6.11 for MacOS.

Here are the samples:

ts_files.zip

lgoncal commented 11 months ago

Maybe you could try to update to latest version, and then try again.

jcdr428 commented 11 months ago

@superbonaci in the three samples, all H264 and AAC are recognized by tsMuxer 2.6.16 latest release.

superbonaci commented 11 months ago

@superbonaci in the three samples, all H264 and AAC are recognized by tsMuxer 2.6.16 latest release.

Then why does it say:

Some tracks not recognized. This tracks was ignored. File name:

You had to see it, why that error?

jcdr428 commented 11 months ago

@superbonaci as can be seen on MediaInfo, this is an IGS menu file. TsMuxer does not mux them.

superbonaci commented 11 months ago

If you use TwitchDownloader or DownloadHelper to download any Twitch video you will see that the IGS menu file is preserved after merging them. If you are stripping information from files you are not merging them you are recoding them.

jcdr428 commented 11 months ago

@superbonaci correction: looking at the file with Eric Berendsen 'DVD Inspector', the track is private metadata that is likely proprietary to Twitch. There is no need for tsMuxer to be able to decode and parse this track.

Packet: 2
File Offset: 376
Time: 00h00m00:000
Metadata in PES packets - Service 1

Header:

sync_byte: 0x47 (71)
transport_error_indicator: 0
payload_unit_start_indicator: 1
transport_priority: 0
PID: 0x102 (258)
transport_scrambling_control: 0 (not scrambled)
adaptation_field_control: 3 (adaptation_field followed by payload)
continuity_counter: 0xA (10)

adaptation_field:

adaptation_field_length: 0x1 (1)
discontinuity_indicator: 0
random_access_indicator: 1
elementary_stream_priority_indicator: 0
PCR_flag: 0
OPCR_flag: 0
splicing_point_flag: 0
transport_private_data_flag: 0
adaptation_field_extension_flag: 0

Pes Header:

stream_id: 0xBD (189) => private_stream_1
PES_packet_length: 0x150 (336)
markerBits: 0x2 (2)
pes_scrambling_control: 0x0 (0) => Not scrambled
pes_priority: 0x0 (0) => normal
data_alignment_indicator: 0x1 (1) => PES packet header is immediately followed by the video start code or audio syncword indicated in the data_stream_alignment_descriptor
copyright: 0x0 (0) => not defined whether the material is protected by copyright
original_or_copy: 0x0 (0) => contents of the associated PES packet payload is a copy
pts_dts_flags: 0x2 (2) => PTS fields shall be present in the PES packet header
escr_flag: 0x0 (0) => no ESCR fields are present
es_rate_flag: 0x0 (0) => no ES_rate field is present
dsm_trick_mode_flag: 0x0 (0) => 8-bit trick mode field is not present
additional_copy_info_flag: 0x0 (0) => additional_copy_info field is not present
pes_crc_flag: 0x0 (0) => CRC field is not present
pes_extension_flag: 0x0 (0) => extension field is not present
pes_header_data_length: 0x5 (5)
pts: 0x61A68E (6399630) => 0:01:11.1070

Data:
         0001 0203 0405 0607 0809 0A0B 0C0D 0E0F 0123456789ABCDEF
0x000000 4741 023A 0140 0000 01BD 0150 8480 0521 GA.:.@.....P...!
0x000010 0187 4D1D 4944 3304 0000 0000 023E 5452 ..M.ID3......>TR
0x000020 434B 0000 0003 0000 0335 0054 4445 4E00 CK.......5.TDEN.
0x000030 0000 1500 0003 3230 3233 2D31 302D 3033 ......2023-10-03
0x000040 5430 333A 3235 3A32 3900 5444 5447 0000 T03:25:29.TDTG..
0x000050 0015 0000 0332 3032 332D 3130 2D30 3354 .....2023-10-03T
0x000060 3033 3A32 353A 3239 0054 4F46 4E00 0000 03:25:29.TOFN...
0x000070 1500 0003 696E 6465 782D 3030 3030 3030 ....index-000000
0x000080 3030 3035 2E74 7300 5453 5345 0000 0015 0005.ts.TSSE....
0x000090 0000 036C 6962 6176 7477 6974 6368 3A20 ...libavtwitch: 
0x0000a0 3636 6538 3035 0054 5858 5800 0001 2B00 66e805.TXXX...+.
0x0000b0 0003 7365 676D 656E 746D 6574           ..segmentmet
Packet: 3
File Offset: 564
Time: 00h00m00:000
Metadata in PES packets - Service 1

Header:

sync_byte: 0x47 (71)
transport_error_indicator: 0
payload_unit_start_indicator: 0
transport_priority: 0
PID: 0x102 (258)
transport_scrambling_control: 0 (not scrambled)
adaptation_field_control: 3 (adaptation_field followed by payload)
continuity_counter: 0xB (11)

adaptation_field:

adaptation_field_length: 0x17 (23)
discontinuity_indicator: 0
random_access_indicator: 0
elementary_stream_priority_indicator: 0
PCR_flag: 0
OPCR_flag: 0
splicing_point_flag: 0
transport_private_data_flag: 0
adaptation_field_extension_flag: 0

Data:
         0001 0203 0405 0607 0809 0A0B 0C0D 0E0F 0123456789ABCDEF
0x000000 4701 023B 1700 FFFF FFFF FFFF FFFF FFFF G..;............
0x000010 FFFF FFFF FFFF FFFF FFFF FFFF 6164 6174 ............adat
0x000020 6100 7B22 6272 6F61 6463 5F72 223A 302C a.{"broadc_r":0,
0x000030 2262 726F 6164 635F 7322 3A31 2C22 636D "broadc_s":1,"cm
0x000040 6422 3A22 6C64 5F6C 6174 5F64 6174 6122 d":"ld_lat_data"
0x000050 2C22 696E 6765 7374 5F72 223A 3136 3936 ,"ingest_r":1696
0x000060 3330 3335 3239 3433 322C 2269 6E67 6573 303529432,"inges
0x000070 745F 7322 3A33 2C22 7374 7265 616D 5F6F t_s":3,"stream_o
0x000080 6666 7365 7422 3A31 312C 2274 7261 6E73 ffset":11,"trans
0x000090 635F 7222 3A31 3639 3633 3033 3532 3935 c_r":16963035295
0x0000a0 3039 2C22 7472 616E 7363 5F73 223A 3136 09,"transc_s":16
0x0000b0 3936 3330 3335 3239 3537 327D           96303529572}

Closing, can be reopened on demand.

superbonaci commented 11 months ago

Now with TwitchDownloader you can do it from the command line:

TwitchDownloaderCLI tsmerge -l list.txt -o output.ts

https://github.com/superbonaci/TwitchDownloader

It uses native .NET Framework functions and it's the best, other software like ffmpeg break the ts streams: ffmpeg concat destroys metadata tracks when combining TS (Transport Stream) files

A pull has been requested to original fork, but doesn't look like they want to implement it: