Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpac Incompatibility with x264 Level 4.x for HLS Playlist Generation #2677

Open
JuanMorenoS opened this issue Nov 2, 2023 · 3 comments
Open

Comments

@JuanMorenoS
Copy link

Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

Detailed guidelines: https://gpac.io/bug-reporting/

I've identified an issue with Gpac concerning the generation of Low-Latency HLS (LL HLS) playlists when using the x264 encoding profile at level 4.2. Broadcasting a UDP stream containing video and audio, encoded via FFMPEG, fails to produce the correct LL HLS playlists. The stream is broadcast with the following configuration:

ffmpeg -i "$URI" \
        -vf "scale=1280:720,fps=24,drawtext=text='%{localtime} ${FILTER}':x=10:y=10:fontsize=24:fontcolor=white:box=1:[email protected]" \
        -map 0:0 -c:v h264_videotoolbox -profile:v high -level:v 4.2 -g 24 -keyint_min 24 -sc_threshold 0 -b:v 3000k -maxrate 4000k -bufsize 6000k -f mpegts "udp:https://239.0.0.1:$VIDEO_PORT" \
        -map 0:1 -c:a aac -ac 2 -b:a 128k -f mpegts "udp:https://239.0.0.1:$AUDIO_PORT"

Attempting to generate an LL HLS playlist with Gpac using the command below only results in a master playlist that contains the audio track, without the video or proper HLS tags:

gpac \
        -i udp:https://239.0.0.1:5000:gpac:#Representation=normal:#HLSGroup=normal:#HLSMExt=AUDIO=\"normal\" \
        -i udp:https://239.0.0.1:5001:gpac:#Representation=normal-audio:#HLSGroup=normal:#HLSMExt=DEFAULT=YES \
        -o test_gpac/playlist.m3u8:segdur=2.0:cdur=0.5:llhls=sf:dmode=dynamic:pssh=mv:template=segment:hlsc \
        -threads=-1

The generated playlist is as follows:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS

#EXT-X-STREAM-INF:BANDWIDTH=2296,CODECS="mp4a.40.2",DEFAULT=YES
playlist_1.m3u8

However, if I change the level to 3.1, it functions correctly and generates the appropriate playlist:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS

#EXT-X-STREAM-INF:BANDWIDTH=1432283,CODECS="avc1.64001F,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=24,AUDIO="normal",AUDIO="normal"
playlist_1.m3u8

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="normal",DEFAULT=YES,NAME="normal-audio",URI="playlist_2.m3u8",CHANNELS="2"

It's important to note that the HLS tags are also missing when using x264 level 4.2.

This issue suggests a compatibility problem or a bug within Gpac when handling streams encoded at x264 level 4.2, specifically affecting the creation of LL HLS playlists. Any assistance in resolving this would be highly appreciated, as high resolution and frame rates enabled by level 4.2 are essential for our broadcasts.

Note: the command to generate the video :

ffmpeg -stream_loop 1000000 -re -i 1080.mp4 \
-filter_complex "fps=30,drawtext=:text='normal %{localtime}:box=1:fontcolor=black:boxcolor=white:fontsize=100':x=40:y=720'" \
-c:v h264_videotoolbox -c:a aac -f mpegts udp:https://239.0.0.1:8001
@JuanMorenoS
Copy link
Author

Also I'm testing with HEVC and is the same behaviour :/

ffmpeg -i "$URI" \
        -vf "scale=1280:720,fps=24,drawtext=text='%{localtime} ${FILTER}':x=10:y=10:fontsize=24:fontcolor=white:box=1:[email protected]" \
        -map 0:0 -c:v hevc_videotoolbox -g 48 -keyint_min 48 -sc_threshold 0 -b:v 3000k -maxrate 4000k -bufsize 6000k -f mpegts "udp:https://239.0.0.1:$VIDEO_PORT" \
        -map 0:1 -c:a aac -ac 2 -b:a 128k -f mpegts "udp:https://239.0.0.1:$AUDIO_PORT"

@jeanlf
Copy link
Member

jeanlf commented Dec 4, 2023

I cannot reproduce using the latest master, the only difference I can see is that sometimes the FPS is not detected (typically when the TS initializes on an IDR) so FRAME_RATE attribute is missing (but is optional).

Could you cross-check you have the same results ?

Also you don' need to add AUDIO=, this is done by default when you setup groups.

@rbouqueau
Copy link
Member

@JuanMorenoS Is it ok now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants