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.5k stars 1.4k forks source link

FreeSWITCH fails to start recording video stream in MP4 format #1395

Open figaro2015 opened 2 years ago

figaro2015 commented 2 years ago

Describe the bug

FreeSWITCH fails to start recording video stream in MP4 format which dimensions (width and/or height) is an odd number. Instead of start recording the video it fails the recording with the following error log messages from MOD_AV:

2021-10-20 17:21:50.836563 [ERR] avformat.c:674 Could not open video codec [0x20545845] (libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10): Generic error in an external library 2021-10-20 17:21:50.836563 [ERR] avformat.c:2611 Error adding video stream

To Reproduce

  1. Using this example configuration...
  2. Dial into conference using verto
  3. Play my_problem_file.mp4 into conference
  4. FreeSWITCH crashes

The easiest way to reproduce the problem is by establishing a WebRTC call and then start screen sharing of one of the windows on the screen.

  1. Establish WebRTC call from a browser to the FreeSWITCH.
  2. Start screen sharing of one of the windows on the screen.
  3. From the fs_cli console issue uuid_record start .mp4 for the screen sharing channel
  4. Observe failure to start recording of the specified video stream.

The problem is more easily reproducible when client is running in Firefox on Linux platform.

Expected behavior

The expected behavior is for the recording of a specified video stream to start successfully and run until terminated by command.

Package version or git hash

commit 578024ed861226eee58706a393a891e1bb41afec

Trace logs

2021-10-20 17:21:50.836563 [ERR] avformat.c:674 Could not open video codec [0x20545845] (libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10): Generic error in an external library 2021-10-20 17:21:50.836563 [ERR] avformat.c:2611 Error adding video stream

NOTE

Further debugging indicated that FreeSWITCH fails to start recording into MP4 only those video streams which have dimensions (width and/or height) as an odd number. Consequently, in order to avoid changes in the x264 library, the easiest immediate fix seems to be to adjust the video stream dimensions to make sure they are even numbers - before passing it to x264 library via avcodec_open2 library API.

seven1240 commented 2 years ago

is the video been played comes with an odd number? or freeswitch somehow scaled it?