3

I'm trying to created live event broadcast on my VPS server , to make the audience able watch my broadcast I use Nginx RTMP that's produce link at this format http://192.168.1.5:8080/hls/live.m3u8 this is my ffmpeg command

ffmpeg -re -i <input> -s 634x360 -vb 110k -c:v libx265 -preset ultrafast -c:a aac -ab 38k -ar 44100 -f mpegts rtmp://localhost/hls/live

command output

frame= 1465 fps= 25 q=-0.0 size= 1231kB time=00:00:58.56 bitrate= 172.2kbits/s speed=0.999x

Nginx config file

server {
listen      8080;
server_name  localhost;
 location /hls 
   {
     types 
       {
                application/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
       }
      root /tmp;
      add_header Cache-Control no-cache;
    }
  }

so the encoding runs on mealtime but when I try to access live.m3u8 url I got nginx 404 Not Found error message like Nginx didn't generate .m3u file at all .

==update

Alright I found workaround solution to generate .m3u8 file directly from ffmpeg using this command

  ffmpeg -i <input> -map 0 -c:v libx265 -vb 300k -c:a aac -ab 38k -ar 44100 -preset veryfast -f ssegment -segment_list /var/www/vhl/live.m3u8 -segment_list_type hls -segment_list_size 10 -segment_list_flags +live -segment_time 10 -segment_wrap 30 /var/www/vhl/live%01d.ts 

I was able to play it via VLC for which is good for now to gain more performance e.g you have huge number of audience mount your output folder /var/www/vhl/ as tmpfs

4
  • HLS does not accept HEVC.
    – Gyan
    Jun 14, 2018 at 4:33
  • 2
    HLS does support HEVC using an mp4 container. RTMP does not support HEVC.
    – SlimSCSI
    Jun 14, 2018 at 14:37
  • Alright I found workaround solution to generate .m3u8 file directly from ffmpeg using this command ffmpeg -i <input> -map 0 -c:v libx265 -vb 300k -c:a aac -ab 38k -ar 44100 -preset veryfast -f ssegment -segment_list /var/www/dmain/live.m3u8 -segment_list_type hls -segment_list_size 10 -segment_list_flags +live -segment_time 10 -segment_wrap 30 /var/www/dmain/live%01d.ts I was able to play it via VLC for which is good for now .
    – Salem F
    Jun 15, 2018 at 5:43
  • Sorry, I meant to write FLV.
    – Gyan
    Jun 16, 2018 at 5:10

1 Answer 1

1

Update, as of March 2023, RTMP has added support for HEVC. Refer to Enhanced RTMP. Therefore, both RTMP and FLV standards now support HEVC.

Support status for related open-source projects:

To test RTMP HEVC, you can use OBS, patched FFmpeg, and SRS. First, start SRS:

docker run --rm -it -p 1935:1935 -p 8080:8080 ossrs/srs:6 \
  ./objs/srs -c conf/hevc.flv.conf

Download OBS 29+ from here, select the HEVC codec, or use FFmpeg 6.0 to publish RTMP HEVC stream:

ffmpeg -stream_loop -1 -re -i doc/source.flv -acodec copy -vcodec libx265 \
  -f flv rtmp://localhost/live/livestream

Note: Build or patch FFmpeg 4/5/6+ with HEVC over RTMP, please see this post.

Now, you are able to play HTTP-FLV or HLS with HEVC codec:

Keep in mind that FFmpeg 6.0 does not support HEVC over RTMP until the following commit 637c761b:

commit 637c761be1bf9c3e1f0f347c5c3a390d7c32b282
Author: Steven Liu <[email protected]>
Date:   Mon Aug 28 09:59:24 2023 +0800

    avformat/rtmpproto: support enhanced rtmp
    
    add option named rtmp_enhanced_codec,
    it would support hvc1,av01,vp09 now,
    the fourcc is using Array of strings.
    
    Signed-off-by: Steven Liu <[email protected]>

For details, please refer to SRS HEVC Usage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.