Opened 3 years ago

Last modified 5 weeks ago

#10775 reopened enhancement

More sensible HEVC handling for HLS creation

Reported by: amesrc Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: HLS hevc_nvenc libx265
Cc: Jack Lau, MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description (last modified by amesrc)

Summary of the bug:
I'm trying to create a multi-codec m3u8 playlist with a 1080p hevc track and a 720p h264 track, but the result is this:
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-STREAM-INF:BANDWIDTH=8263200,RESOLUTION=1920x960
stream_0/playlist.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2411200,RESOLUTION=1280x640,CODECS="avc1.4d401f,mp4a.40.2"
stream_1/playlist.m3u8

I already found other topics about this issue, but I've read it has been fixed around 2 or 3 years ago... so how come I can't get this command to work properly and output the CODECS attribute for the hevc track? I've also tried with libx265 but I get the same result.

How to reproduce:

% ffmpeg -i input.mkv -filter_complex "[0:v]split=2[v1][v2]; [v1]crop=1920:960:0:60[v1out]; [v2]scale=w=1280:h=720, crop=1280:640:0:40[v2out]" -map "[v1out]" -c:v:0 hevc_nvenc -b:v:0 7M -maxrate:v:0 7M -minrate:v:0 7M -bufsize:v:0 7M -preset slow -g 48 -keyint_min 48 -map "[v2out]" -c:v:1 h264_nvenc -b:v:1 2M -maxrate:v:1 2M -minrate:v:1 2M -bufsize:v:1 2M -preset slow -g 48 -keyint_min 48 -map a:0 -c:a:0 aac -b:a:0 512k -ac 2 -map a:0 -c:a:1 aac -b:a:1 192k -ac 2 -f hls -hls_time 2 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename stream_%v/data%02d.ts -master_pl_name master.m3u8 -var_stream_map "v:0,a:0 v:1,a:1" stream_%v/playlist.m3u8

ffmpeg version: 2024-01-01-git-e1c1dc8347-full_build-www.gyan.dev

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Change History (9)

comment:1 by amesrc, 3 years ago

Description: modified (diff)

comment:2 by Jack Lau, 16 months ago

Hi,

I think it's not a bug, because apple support only "hvc1" tag, so you need add -tag:v:0 hvc1 in your command if you want use hls, and you'll see the right codecs attribute

comment:3 by Jack Lau, 16 months ago

Analyzed by developer: set
Cc: Jack Lau added
Priority: importantwish
Resolution: fixed
Status: newclosed

comment:4 by Balling, 16 months ago

"think it's not a bug, because apple support only "hvc1" tag, so you need add -tag:v:0? hvc1 in your command if you want use hls, and you'll see the right codecs attribute"

It is not just a tag. hvc1 is a special style of writing coding parameters. LOL

Last edited 16 months ago by Balling (previous) (diff)

comment:5 by MasterQuestionable, 16 months ago

Cc: MasterQuestionable added
Component: ffmpegavformat
Resolution: fixed
Status: closedreopened
Summary: FFmpeg omitting the CODECS attribute again with hevc_nvenc and libx265More sensible HEVC handling for HLS creation
Type: defectenhancement

͏    If the HLS protocol only supports "hvc1" in such:
͏    Probably it's more sensible to automatically apply it.

comment:6 by Balling, 16 months ago

If the HLS protocol only supports "hvc1" in such:

No. OMG, it is not about HLS protocol even, this is not 2 bytes difference in metadata or header of fmp4 file!! HLS supports both hev1, hvc1, dvhe, dvh1

https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-HLS?language=en_US

But in Apple spec (see 1.10.) https://developer.apple.com/documentation/http-live-streaming/hls-authoring-specification-for-apple-devices

they say that

1.10. You SHOULD use video formats in which the parameter sets are stored in the sample descriptions, rather than the samples. (That is, use 'avc1', 'hvc1', or 'dvh1' rather than 'avc3', 'hev1', or 'dvhe'.)

That is what it means, it is a fmp4 where parameter sets (SPS, PPS) are stored in the sample descriptions.

Last edited 5 weeks ago by Balling (previous) (diff)

comment:7 by MasterQuestionable, 16 months ago

͏    If I understand correctly:
͏    Passing "-tag:v:0 hvc1" (for this case) shall work.
͏    And not passing would fail.
͏    .
͏    So why require alike extra circumlocution?

comment:8 by Balling, 16 months ago

why require alike extra circumlocution?

Because it is apple being stupid here, they only allow one type, and it is possible that tag:v:0? hvc1 alone will produce invalid files.

comment:9 by MasterQuestionable, 16 months ago

͏    I mean only special-case for HLS creation: as practical workaround.
͏    Not blindly apply generally.

Last edited 16 months ago by MasterQuestionable (previous) (diff)
Note: See TracTickets for help on using tickets.