Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#7480 closed defect (fixed)

HEVC codec info string

Reported by: tbucher Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: hls
Cc: bucher@seznam.cz Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

ffmpeg -f lavfi -i testsrc -t 4 -c:v libx265 -tag:v hvc1 -x265-params no-opengop=1:no-scenecut=1:keyint=100:strict-cbr=1 -b:v 3M -bufsize 1500k -vf scale=-2:1080,format=yuv420p -use_timeline 1 -use_template 1 -single_file 0 -adaptation_sets "id=0,streams=0" -seg_duration 4 -hls_playlist 1 -init_seg_name "init_$RepresentationID$.m4s" -media_seg_name "seg_$RepresentationID$_$Number%06d$.m4s" -y -f dash manifest.mpd

should insert proper codec info string for HEVC both into master.m3u8 and manifest.mpd.

However, even though the tag is forced as hvc1, the resulting codec info string is hev1 in both manifest types, which is ignoring the forced tag or generated hvc1 box and it is not complete as specified by ISO, it is missing profile, level, etc.

resulting truncated master.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3002056,RESOLUTION=1440x1080,CODECS="hev1"

resulting truncated manifest.mpd
<Representation id="0" mimeType="video/mp4" codecs="hev1" bandwidth="3000000" width="1440" height="1080" frameRate="25/1">

Especially m3u8 is now problematic since native decoder in Safari is refusing such m3u8 playlist.
Inserting CODECS tag into master.m3u8 playlist is a recently commited feature, removing this tag or replacing the hev1 value with one based on ISO makes the stream in Safari playable again.

Not including FFmpeg log as it is irrelevant.

Change History (13)

comment:1 by tbucher, 6 years ago

Keywords: hls mpeg-dash hevc added

comment:2 by Carl Eugen Hoyos, 6 years ago

Keywords: mpeg-dash hevc removed

comment:3 by Karthick Jeyapal, 6 years ago

I have just now sent a patch to include the forced tag hvc1 instead of hev1.
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235037.html

Will the above patch solve this playout issue? Or does it require the profile, level etc., If it requires profile, level could you please point me to relevant spec, so that I can try to implement it.

comment:4 by tbucher, 6 years ago

Thank you.

With regards to the rest, yes, Apple apparently requires the whole codec info based on my trial & error attempts as long as native Safari player is involved, playback via MSE in Safari is more lenient.
I've cobbled up the codec info for my succesful playback based on https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices. This page lists ISO/IEC 14496-15 as the standard the development should refer to.

comment:5 by Karthick Jeyapal, 5 years ago

I have sent a patch to disable CODECS tag for HEVC streams. http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235390.html
I have tested that it plays in native Safari and things are back the way it was for HEVC streams.
Hope this fixes your issue.

Last edited 5 years ago by Karthick Jeyapal (previous) (diff)

comment:6 by tbucher, 5 years ago

Appreciated. I haven't tested it yet, but if its purpose is to remove CODECS tag for HEVC from master m3u8 to make them playable again, that should be fine for the time being.

However, HLS Pantos RFC specification says that CODECS tag SHOULD be present while Apple guidelines say the it MUST be present, so using it also for HEVC should be a given in the near future.

I read your comments on that patch why it is not implemented now, should we keep the ticket open in order to track this?

comment:7 by Karthick Jeyapal, 5 years ago

Sure, Let us keep this ticket open to track this issue.

comment:8 by tbucher, 5 years ago

Cc: bucher@seznam.cz added

comment:9 by Balling, 3 years ago

Status: newopen

"I was not sure what is the right format of that string. I saw some examples, like hvc1.2.4.L123.B0. But I didn't know what that meant"

That part is implemented in a2b1dd0ce301450a47c972745a6b33c4c273aa5d.

snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", av_fourcc2str(st->codecpar->codec_tag), profile, level);

and looks like it works with command in #8904. no-opengop=1, BTW, does not work here in x265...

P.S. It does exist. See https://bitbucket.org/multicoreware/x265_git/src/82786fccce10379be439243b6a776dc2f5918cb4/source/x265cli.h?at=master#x265cli.h-136

That other issue with "for 2K and 4K resolution Apple clients don't playout properly even when properly constructed CODEC tag is there(hvc1.2.4.L153)" I do not think we should care. Apple 4K TV and not 4K cannot even play 24.000 video correctly, playing it as 24/1.001 and losing frames there every 41 seconds, so who cares. See https://www.avsforum.com/threads/apple-tv-4k-lacks-support-for-24-000-video.2961262/ Though Macbooks play that correctly even on MacOS, so that part does not suck.
P.S. Latest beta changed that to always output 24.000, LOL. It is even worse, of course.
P.S.2 they fixed it. Wow.
Now the issue that is still not there is

#EXT-X-STREAM-INF:BANDWIDTH=3002024,RESOLUTION=1440x1080

and not

#EXT-X-STREAM-INF:BANDWIDTH=3002056,RESOLUTION=1440x1080,CODECS="hvc1"

Last edited 3 years ago by Balling (previous) (diff)

comment:10 by gordon, 3 years ago

According to https://chromium.googlesource.com/chromium/src/media/+/master/base/video_codecs.cc#655

The specification for HEVC codec id strings can be found in ISO IEC 14496-15 dated 2012 or newer in the Annex E.3

comment:11 by Balling, 3 years ago

Okay, lets finalise this. Apple 4K 2021 fixed raised black in DV and previous models inluding not 4K got 24.000 integer and non-integer 24/1.001 support. Nuts! Cool, of course.

So who is going to add CODECS="hvc1"? Hey?

comment:12 by Balling, 3 years ago

So who is going to add CODECS="hvc1"? Hey?

Okay, I sent a patch. https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210607063205.180031-1-val.zapod.vz@gmail.com/

Last edited 3 years ago by Balling (previous) (diff)

comment:13 by Balling, 3 years ago

Resolution: fixed
Status: openclosed
Last edited 3 years ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.