janus-pp-rec may be producing .webm with incomplete metadata

217 views
Skip to first unread message

Eugene F.

unread,
Sep 24, 2021, 1:20:00 AM9/24/21
to meetecho-janus
Hello.
I have faced the problem with "incorrectly" oriented video recordings. As WebRTC users may know, the orientation of a video is encoded in the special RTP header that is described at SDP (in the line like "a=extmap:13 urn:3gpp:video-orientation"), so a receiving device can rotate an incoming video stream if needed. In meantime, Janus records its .mjr`s "as is", without any rotations - and that`s great because it makes the recording process high-performant. We still can find out the rotation of a video stream bypassing -v {$HEADER_NUM} flag to janus-pp-rec util and parsing the textual output. Furthermore, tools like ffmpeg claim that they will rotate your videos by default (-autorotate flag is always on), so it sounds like one can convert .mjr to, say, .webm and then autorotate it to "normal" orientation. But it doesn`t work, even when I use the -v flag with janus-pp-rec. The following code doesn`t rotate the video:
janus-pp-rec -v 13 src.mjr out.webm
ffmpeg -i out.webm trgt.webm
even if janus-pp-rec -v 13 -p src.mjr prints "Video rotation: 90 degrees".
So my question is: should janus-pp-rec add some secret sauce to the resulting .webm metadata in the case of rotated videos? If shouldn`t, why? Is the described situation a bug or the behavior isn`t implemented intentionally? Imho, .webm with orientation metadata could be very convenient for users.
P.S. I saw the solution with "videoorient_ext = false" in the videoroom config, but I use the videocall plugin, and (what's more important) the solution with modifying .webm metadata (if it is possible) seems more universal.

Sots Ts

unread,
Sep 24, 2021, 2:18:37 AM9/24/21
to meetecho-janus
We've seen this with iPhone and iPad Janus pprec webm recordings.
The content displays in the videoroom appropriately to subscribers, but the webm has the rotation parameter incorrect.
Thanks for helping me understand more of this... 

Lorenzo Miniero

unread,
Sep 24, 2021, 4:39:52 AM9/24/21
to meetecho-janus
janus-pp-rec does not modify the media packets, it just saves them to a playable container format, so it will never rotate video for you (it would mean re-encoding the video). It just prints the information it reads in the RTP extension, so that if you want you can take care of the rotation yourself later on, e.g., using ffmpeg. So it's working as intended.

L.

Eugene F.

unread,
Sep 24, 2021, 5:50:19 AM9/24/21
to meetecho-janus
thanks for the answers!
Could janus-pp-rec add rotation info to the resulting file metadata? I think that kind of feature makes sense.
In the video-processing code, it would be easier for the user: I can parse the rotation info from the janus-pp-rec stdout, but its format can eventually change, and this approach is not as safe and convenient as saving, say, {... "r":"90"} field right in the COMMENT metadata field of the resulting file, just like the info that already comes there from Janus.

Lorenzo Miniero

unread,
Sep 24, 2021, 8:41:13 AM9/24/21
to meetecho-janus
IIRC we currently put the whole JSON info of the mjr file already in the metadata section. Some people are relaying on that information in their production environments, so replacing that with what you need could be considered a breaking change. Besides, there could be several rotations in a single recording, and metadata I think is written before we process the packets, and so we wouldn't know about rotations yet anyway when we write it. Your best option right now is scrape the output of the tool console/log to create an associated metadata file yourself.

L.

Eugene F.

unread,
Sep 24, 2021, 8:44:57 AM9/24/21
to meetecho-janus
Okay, thank you
Reply all
Reply to author
Forward
0 new messages