Page MenuHomePhabricator

Once it's not patent-encumbered, enable MPEG-2 support for Commons uploads and TMH/etc. playback
Open, LowestPublic

Description

Apparently, the last patent will expire 14 February 2018: List of United States MPEG-2 patents

Putting this up so legal has enough time. And that they don't duplicate work for the audio layer T120288.

What uses MPEG-2? DVD-Video and OTA broadcasts in the US.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 21 2017, 6:23 PM
RP88 added a subscriber: RP88.May 21 2017, 11:05 PM
Poyekhali triaged this task as Lowest priority.May 22 2017, 2:16 AM
Poyekhali changed the task status from Open to Stalled.
Keegan added a subscriber: Keegan.Jun 5 2017, 6:55 PM
Yuhong added a subscriber: Yuhong.EditedJul 26 2017, 3:04 AM

There are already very few patents remaining on MPEG-2. It is probably not as important as MP3 though.

Base added a subscriber: Base.Jul 26 2017, 4:31 AM
Ramsey-WMF moved this task from Untriaged to Desired epics on the Multimedia board.Nov 3 2017, 4:25 PM
Dispenser updated the task description. (Show Details)Dec 9 2017, 3:25 AM

According to MPEG-LA, MPEG-2 is patent free in the United States now.

TheDJ added a subscriber: TheDJ.Feb 15 2018, 9:26 AM

This task first needs to answer, in which file format it wants to support the codec. Codec detection happens in the file format parsing, so for each file format you want the codec to be supported in, you will have to take separate technical steps on that level (and thus likely separate tickets).

brion added a subscriber: brion.Feb 15 2018, 5:25 PM

So I think this is gonna be MPEG-2 transport stream or something? I'm a little rusty. Lemme do a quick spike with samples from Internet Archive and see what they look like.

Change 411051 had a related patch set uploaded (by Brion VIBBER; owner: Brion VIBBER):
[mediawiki/extensions/TimedMediaHandler@master] WIP: Support MPEG-1/MPEG-2 video uploads

https://gerrit.wikimedia.org/r/411051

brion changed the task status from Stalled to Open.Feb 15 2018, 6:43 PM
brion added a comment.Feb 15 2018, 8:12 PM

I fixed the aspect ratio problem I originally saw, but need to figure out how to detect interlacing and then apply deinterlacing on the transcodes...

brion added a comment.Feb 15 2018, 9:06 PM

Now detects interlaced input and applies yadif deinterlacing filter on transcodes.

So far so good with the spike patch, except that some files I've tested don't detect the audio track, possibly some incomplete support in getid3. It also returns the wrong pixel aspect ratio for MPEG-2 video, which I was able to work around on the TMH end for now.

(Note that I believe standard .mpg and .mpeg files are in fact program streams, not transport streams, which is used for broadcast and some of the streams for Apple's HLS.)

Most browsers don't play MPEG-2 in <video> tags (Safari on Mac does, but not on iOS) and ogv.js doesn't yet include MPEG playback, so during the time between initial upload and the completion of the first transcode, users may see an ugly message about unsupported formats instead of it trying to play back the original source. Will want eventually to rethink the UI around transcoding status reporting on the File: page!

Question: is there any concern about extra patrolling needs for piracy in the case of decrypted DVD rips? Or would the large original size of full-length movies in MPEG-2 make this too difficult for drive-by uploaders to exploit?

Upstream issues reported:

TheDJ added a comment.EditedFeb 16 2018, 10:15 AM

If you are concerned of DVD rips, these used to be either the full .iso's rips, or they were the VIDEO_TS folders within them. VIDEO_TS is a structure around mpeg-ps files that includes the DVD metadata etc. BTW. DVDs are kinda special, if you'd play their raw files then likely you wouldn't enjoy the movie much, as they are divided in chapters, and sometimes this is quite messy. You really actually need that DVD specific metadata.

The most common format is MPEG-TS these days (used for DVB-C, DVB-T and DVB-S). MPEG-TS is a super flexible, timing accurate and streaming capable file format, that can basically include whatever you want. It supports hundreds of different type of codecs and metadata (EPG, chapters, menu's, subtitles, teletext etc).

I always say that MPEG-TS is what satellite engineers understood about writing specifications, that the Internet part of the world only understood just a few years ago. It's as flexible as mov/mp4/mkv, but with slight overhead, simply better manageable for the hardware industry.

Honestly, MPEG-PS is rare. It exists, but not nearly as much as you'd expect. DVDs are a super spec on top of it, or they are transcoded to simpler codecs, Broadcast video is MPEG-TS or ripped to other formats, and archived material is either the original captured video in camera specific formats, MXF or proprietary stuff around MPEG-TS.

I wonder if there is much matroska wrapped mpeg2 video...

brion added a comment.Feb 16 2018, 9:35 PM

I didn't have any MPEG-TS files handy but I did a quick test creating one with ffmpeg -- ffmpeg will take it as input and convert it just fine, but getid3's handling is incomplete and it errors out.

To support TS as well as PS, would need:

  • complete the logic in getid3's module.audio-video.ts.php and patch it upstream
    • (or replace with shell-out to ffprobe)
  • make sure the mime detection maps .ts/.tsv/.tsa files to video/mp2t and does the correct magic check
  • route the file handler class appropriately
  • validate codecs so we don't let streams with MPEG-4, H.264 etc through
brion added a comment.Feb 21 2018, 5:07 PM

Note that for WMF production I think we'd also need to change our thumbor configuration to make sure the files get passed through the ffmpeg handler:

https://phabricator.wikimedia.org/diffusion/THMBREXT/browse/master/wikimedia_thumbor/loader/video/__init__.py

I don't think anything special would need to be added other than adding checks for the '.mpg' and '.mpeg' extensions.

Clpo13 added a subscriber: Clpo13.Nov 20 2018, 5:25 PM