New issue
Advanced search Search tips

Issue 830575 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Some videos played via MSE do not honour rotation metadata

Reported by bvan...@mozilla.com, Apr 9 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0

Example URL:
https://www.reddit.com/r/StartledCats/comments/84o5bf/i_think_i_scared_my_cat_into_yesterday/

Steps to reproduce the problem:
1. Open https://www.reddit.com/r/StartledCats/comments/84o5bf/i_think_i_scared_my_cat_into_yesterday/
2. The video plays in portrait (no rotation applied)
3. Compare to opening the raw video at https://v.redd.it/vnmngn3xmyl01/DASH_1_2_M which is displayed rotated

What is the expected behavior?
The MSE video should be displayed rotated

What went wrong?
It appears when using MSE, that the rotation metadata in the mp4s being is ignored leading to the video not being rotated.

Did this work before? N/A 

Is it a problem with Flash or HTML5? HTML5

Does this work in other browsers? N/A

Chrome version: <Copy from: 'about:version'>  Channel: n/a
OS Version: 10.0
Flash Version: 

Contents of chrome://gpu:
 
Cc: tmathmeyer@chromium.org
Owner: wolenetz@chromium.org
Status: Assigned (was: Unconfirmed)
Hmm, yeah looks like we don't parse this rotation data in ChunkDemuxer like we do for FFMpegDemuxer.

+tmathmeyer since this might be a good first bug relating to MSE.
Components: -Internals>Media Internals>Media>Source
Labels: Hotlist-GoodFirstBug
Ted, is this something you want to work on?
@#2 Some more context:

FFmpegDemuxer handles "<video/audio src=[some normal file URL]</video/audio>"  stream demuxing (e.g. for raw media files).

Relevant MSE API/impl summary:
ChunkDemuxer handles the case where [some normal file URL] is instead a blob URL that references a MediaSource object. Once that MediaSource is "attached" to the media element using blob URL, the web app can add one or more SourceBuffer objects to the MediaSource and append well-formatted media streams to those SourceBuffers. This provides an API for web apps to adapt media playback dynamically (bitrate/quality adaptation, as well as ad insertion). The spec for the API is at https://www.w3.org/TR/media-source/.

Quick dive-in:
Rotation metadata needs to be extracted and populated into the VideoDecoderConfig in various sub-types of StreamParser class (a StreamParser is what handles the extraction of compressed media coded frames and decoder configurations from bytes appended by the web app to a SourceBuffer).

An example for normal (non-MSE) FFmpegDemuxer rotation metadata population into a video decoder config is:
https://cs.chromium.org/chromium/src/media/ffmpeg/ffmpeg_common.cc?type=cs&sq=package:chromium&l=527
This depends on the parsing within ffmpeg to populate the rotation information into the AVStream for each stream (e.g. media track) it finds in the input media.

For MSE, we have multiple parsers (all under //media/formats/...). Given the bug context, I'd start with the Mp4StreamParser, and then follow-up if research indicates there is rotation signalling info also available in other bytestreams (webm, mp2ts). A very quick scan of ffmpeg source seems to indicate it may only handle such rotation within mov demuxing (mp4, and similar ISO-BMFF streams -> //third_party/ffmpeg/libavformat/mov.c), though maybe there is other treatment for rotation metadata in other streams that I missed.

If this sounds like something you'd like to work on, please reassign to yourself. Don't hesitate to ask questions :)
Cc: -tmathmeyer@chromium.org wolenetz@chromium.org
Owner: tmathmeyer@chromium.org
Sure, I'll take this.
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/01b29f3e6a7d4109b4fe6756e643585c782882be

commit 01b29f3e6a7d4109b4fe6756e643585c782882be
Author: Ted Meyer <tmathmeyer@chromium.org>
Date: Tue Apr 17 18:18:58 2018

MSE: Support for extracting rotation from MP4 videos

The MP4 spec specifies a matrix stored in both the movie header as well
as individual track headers. A final matrix is created by composing and
transforming a track header with the movie header. A rotation value can
be extracted from this final matrix. This is defined in ISO-14496-12.

Bug:  830575 
Change-Id: If788e4492a082096b36796a3cbf22105a4d57d3f
Reviewed-on: https://chromium-review.googlesource.com/1006177
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551400}
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/box_definitions.cc
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/box_definitions.h
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/box_reader.cc
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/box_reader.h
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/mp4_stream_parser.cc
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/mp4_stream_parser.h
[modify] https://crrev.com/01b29f3e6a7d4109b4fe6756e643585c782882be/media/formats/mp4/mp4_stream_parser_unittest.cc

Status: Fixed (was: Assigned)

Sign in to add a comment