Issue transcoding H.265 to H.264 stream with FFMPEG

I’m having an issue trying to do some tests restreaming an H.265 stream to H.264 as follows:

  • I use a MP4 file as video source, then I use VLC to stream it with H.265 codec as follows:
  1. I go to media -> stream menu, then select a file and stream:

enter image description here

  1. The second step allows me to add a destination for the stream, I chose HTTP:

enter image description here

  1. The next step allows me to select a profile, I select Video – H.265 + MP3 (MP4) profile leaving the Activate Transcoding option:

enter image description here

  • Previous steps allow me to stream the video file, I can open another instance of VLC and open the URL of the created stream (http://localhost:8080/test) and it is able to playback the stream. Moreover, if I go to Tools -> Codec Info menu I see that the playback indeed uses H.265 codec.

  • Then I try to use FFMPEG library to take that input stream and transcode to two separate stream, one H.264 for a copy of the video and another an opus audio output with the following command:

ffmpeg -i http://localhost:8080/test -c:v libx264 -bsf:v h264_mp4toannexb -b:v 2M -profile:v baseline -pix_fmt yuv420p -x264-params keyint=120 -max_delay 0 -bf 0 -listen 1 -f h264 unix:/tmp/myvideo.sock -c:a libopus -page_duration 20000 -vn -listen 1 -f opus unix:/tmp/myaudio.sock

But I get the following error:

enter image description here

If I try RTSP instead of HTTP it works but the stream is awful, I can barely see some frames on the receiver and the video usually freezes or just shows black.

I’m using Ubuntu with VLC 3.0.18 and FFMPEG 4.4.2.

I have specific requirements to handle the live streams, I cannot just convert and save to a new container (MP4 file) the transcoded video, I require a source streaming H.265 and transcode the stream to be injected into a WebRTC server (requiring H.264 as input).

Any help/suggestion is much appreciated in advance!

  • DO NOT post images of code, data, error messages, etc. – copy or type the text into the question. How to Ask

    – 

  • I’m voting to close this question because , as the ffmpeg tag states: Only questions about programmatic use of the FFmpeg libraries, API, or tools are on topic. Questions about interactive use of the command line tool should be asked on superuser.com or video.stackexchange.com. Please delete this.

    – 

Leave a Comment