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.
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
Using this example configuration...
Dial into conference using verto
Play my_problem_file.mp4 into conference
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.
Establish WebRTC call from a browser to the FreeSWITCH.
Start screen sharing of one of the windows on the screen.
From the fs_cli console issue uuid_record start .mp4 for the screen sharing channel
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.
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
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.
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.