signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.58k stars 1.42k forks source link

Wrong colorspace with h264/mp4 recordings #544

Open ofrzeta opened 4 years ago

ofrzeta commented 4 years ago

I recently opened a bug report for Chrome because our video recordings from the conference got rendered with wrong colors in Chrome. Now the Chrome team says they are doing it correctly and "the color space is incorrect on the containers and frame" (https://bugs.chromium.org/p/chromium/issues/detail?id=1067377). In the Chromium Bug report there's also a URL to a sample video file.

I tried different settings in av.conf.xml and different versions of Freeswitch, also compiled 1.10.2 from Git on Debian 10 with no success. The resulting mp4/h264 does always show pxfmt/colorspace "yuvj420p(pc, gbr/unknown/unknown)" regardless of my settings in the above config. For instance I tried colorspace values 1 and 5 but it didn't make a difference.

From the logs:

2020-04-04 00:51:15.463697 [DEBUG] avformat.c:1757 use video codec: [28] h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10) 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0x1:0x111 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=60 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=10 qpmax=31 qpstep=4 ip_ratio=1.41 aq=1:1.00 2020-04-04 00:51:15.503691 [INFO] avformat.c:2525 use video codec implementation Video: h264 (libx264), yuv420p(pc, gbr/unknown/unknown), 1280x720, q=10-31, 1650 kb/s

seven1240 commented 4 years ago

https://github.com/signalwire/freeswitch/commit/036d3e80857ad1414fb036ca9e6e6cb0a9d477f4#diff-f15644a7ddb5f203a3622948fc56d4a7 was the main change we support colorspace. can you find out what should we do to make it right? or make a pr ?

seven1240 commented 4 years ago

you can try the test_avformat.c and see if you can make it correct by change to different color space. I'm not sure how to check it.

ofrzeta commented 4 years ago

After taking a look at the test I managed to get a conference recording with "bt709/unknown/unknown". For this I had to set the colorspace in the "AV Format Config" section:

<configuration name="avformat.conf" description="AVFormat Config">
  <settings>
      <param name="colorspace" value="1"/>
  </settings>
</configuration>

While setting the colorspace in the 'profile name="H264' didn't seem to have an effect.

briankwest commented 4 years ago

Did you set it in AV Codec too?

ofrzeta commented 4 years ago

Yes, we have configured it in the H264 profile of the "AVCodec Config". I didn't yet check if it works without that setting.

ofrzeta commented 4 years ago

I finally tried this and I got the correct colorspace also with the colorspace settings in "AV Format Config" section only.