ExoPlayer
ExoPlayer copied to clipboard
BDAV .m2ts extraction support
ref: https://en.wikipedia.org/wiki/MPEG_transport_stream
m2ts file have a 4-byte header: 4-byte Transport Stream Header
TsExtractor cannot recognize it.
video data clip: 000000000 01 95 1D 2E 47 40 00 10 00 00 B0 11 00 00 C1 00 00 00 00 E0 1F 00 01 E1 00 23 5A AB 82 FF FF FF ....G@....°...Á....à...á.#Z«.ÿÿÿ 000000032 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000064 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000096 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000128 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000160 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000192 01 95 22 24 47 41 00 30 15 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 02 .."$GA.0..ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.. 000000224 B0 37 00 01 C1 00 00 F0 01 F0 0C 05 04 48 44 4D 56 88 04 0F FF 84 FC 1B F0 11 F0 14 05 08 48 44 °7..Á..ð.ð...HDMV...ÿ.ü.ð.ð...HD 000000256 4D 56 FF 1B 57 3F 31 08 00 00 00 00 F0 00 00 01 82 F1 00 F0 00 A4 6E A1 2F FF FF FF FF FF FF FF MVÿ.W?1.....ð....ñ.ð.¤n¡/ÿÿÿÿÿÿÿ 000000288 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000320 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000352 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000384 01 95 25 72 47 40 1F 10 00 7F F0 19 FF FF C1 00 00 F0 0A 63 08 C1 D4 C0 FF FF FF FF FF 00 01 80 ..%rG@....ð.ÿÿÁ..ð.c.ÁÔÀÿÿÿÿÿ... 000000416 00 03 00 38 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ...8mÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000448 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000480 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000512 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000544 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000576 01 95 28 C0 47 10 01 20 B7 10 00 00 AC DE 7E 70 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ..(ÀG.. ·...¬Þ~pÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000608 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000640 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000672 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000704 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000736 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 000000768 01 95 31 03 47 50 11 10 00 00 01 E0 00 00 80 C0 0A 31 00 0B 7E ..1.GP.....à...À.1..~
Unfortunately we cannot work with a hexdump of your file. We will need the file itself. You can either post it here or send it to [email protected]. However, I can see that the sync byte is not at the beginning of the file, so if you remove the first four bytes (so that the file starts with 0x47), it should work. If this solves your issue, let me know through this issue. If it doesn't, open a new issue including all required information in the issue template.
It is M2TS format. It has four additional bytes at start of each common DVB packet. As I know a timestamp is stored there. For fast access on the low level. You may (as I had made it) create a wrapper around TsExtractror and realize consumption that cuts the first four bytes and than send DVB part into TsExtractor.
Well, considering this addition breaks the 188 packet size restriction, I wouldn't say it is M2TS format. If these four extra bytes appear for every TS packet then no "actual TS parser" will be able to sync, and therefore, to read.
I am wondering though where you got this file from (considering @Avetri knows about it). On top of that, the timestamp included there is to facilitate access according to what? If it was playback time, I would have expected the first four bytes to include a value near 0.
another m2ts file:http://download1655.mediafire.com/x9vxw78itlbg/muj20yyjdqi/Babylon+A.D.M2TS packet structure: 4 bytes header + 188 body
As per the response above, if you're adding data between transport stream packets then it's not a valid transport stream. I'm not sure why you expect this to work?
https://en.wikipedia.org/wiki/MPEG_transport_stream
Name | Number of bits |
32-bit BE mask |
Description |
---|---|---|---|
4-byte Transport Stream Header | |||
Sync byte | 8 | 0xff000000 | Bit pattern of 0x47 (ASCII char 'G') |
Transport Error Indicator (TEI) | 1 | 0x800000 | Set when a demodulator can't correct errors from FEC data; indicating the packet is corrupt.[7] |
Payload Unit Start Indicator | 1 | 0x400000 | Set when a PES, PSI, or DVB-MIP packet begins immediately following the header. |
Transport Priority | 1 | 0x200000 | Set when the current packet has a higher priority than other packets with the same PID. |
PID | 13 | 0x1fff00 | Packet Identifier, describing the payload data. |
Scrambling control | 2 | 0xc0 | '00' = Not scrambled.
For DVB-CSA and ATSC DES only:[8] |
Adaptation field flag | 1 | 0x20 | |
Payload flag | 1 | 0x10 | |
Continuity counter | 4 | 0xf | Sequence number of payload packets (0x00 to 0x0F) within each stream (except PID 8191) Incremented per-PID, only when a payload flag is set. |
Optional fields | |||
Adaptation field | variable | If Adaptation field flag is set, see below. | |
Payload Data | variable | If Payload flag is set. Payload may be PES packets, program specific information (below), or other data. |
I'm not sure what you're trying to show by pasting part of a Wikipedia article into this issue with no accompanying comment. Please clarify?
Also, I think you're misreading the specification. The packet structure is not 4-random-bytes-to-do-what-you-like-with followed by a 188-byte-body. The packet structure is a 4-byte-packet-header followed by 184 bytes of payload. The 4 byte header consists of the fields starting from the sync byte and ending at the continuity counter, as defined in the table above (note that these fields total to 4 bytes in length). The remaining 184 bytes is the payload data (optionally preceded by an adaptation field).
@ojw28 @uplusplus A small patch to add the M2TS support. AddM2TS.patch.zip
A link to https://en.wikipedia.org/wiki/.m2ts would have cleared up a lot of confusion on this issue a long time ago... Please can you provide some working sample content in this format to [email protected]
. The link to sample content above no longer works.
It (four byte header) is better to skip. Better_to_skip.patch.zip
We need proper sample content to look at this. The patch above is incomplete in that it doesn't implement seeking or duration parsing, both of which should be possible using the extra four bytes in this type of media.
"We need proper sample content to look at this." @ojw28 Unfortunately i am not able to give such content sample. You may look it for in sample packs as DVD5, DivX Test or other that is compatible with ExoPlayer. The player has not been flexible enough yet to work with any TS or M2TS (BDAV as You named it) file.
"implement seeking or duration parsing" It will be gorgeous if somebody writes such code.
Until someone provides sample content for this enhancement, we wont be looking at it.
@ojw28 https://www.dropbox.com/sh/poubu1hb6f1lzu8/AADl9XHl3EKFq2QAnsYWHBFOa?dl=0
A few sample files there are in the folder. Many of them are audio related.
hello, thank you! Exoplayer 2 have not DefaultTsPayloadReaderFactory class.
I don't know TsPayloadReader and DefaultTsPayloadReaderFactory
ExoPlayer 2.0.4 repo dev-v2 hash 92a98d1ce2a27266fa69927235929f45678aac40
hello, I use your diff of m2ts, audio id is null, video id is null.How do i do?
my media file is m2ts.it's ac3 and h264.it can't be played.
I should look at it. Please give a sample.
hello, this is my media file, https://drive.google.com/file/d/0Byd5TAkGBKhMSzVzckNTZkZoWWs/view?usp=sharing
Ok. I will look at.
At first (I have not looked inside it yet) it is an UltraHD file with 120 megabit bitrate! I am not completely sure that any Android device can correctly support UltraHD H264.
Your file isn't a M2TS according to internal structure. It has no 4 byte length M2TS headers.
java.lang.OutOfMemoryError
Can not belive that a feature was raised in 2016 and still has no been solved.
The point is whether have you solved the issue after so many years past? If you need examples, I can send to you.
AquilesCanta commented on Nov 20, 2019 As per #1488, this type of files is not yet supported. Forking TS extractor to support them should be relatively easy. Please track #1488 for support.
If it is easy, why there is no progress along the line after so many years?
@ooyellow58 Please don't repeatedly spam issues demanding they be addressed - I'm afraid it's unlikely to achieve the result you want.