Opened 6 years ago
Last modified 2 weeks ago
#7799 open defect
hevc_mp4toannexb filter inserts extradata wrong position (hevc_cuvid ffplay too)
Reported by: | Hyemin Lee | Owned by: | Carl Eugen Hoyos |
---|---|---|---|
Priority: | normal | Component: | avcodec |
Version: | git-master | Keywords: | hevc |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
After applied hevc_mp4toannexb filter to the attached video (refer to the below link),
the frames become broken from the video players (e.g. VLC, ffplay)
The problem is caused by prepending the extra-data to IRAP frames in libavcodec/hevc_mp4toannexb_bsf.c.
This video contains own vps/sps/pps for every IRAP frames.
The extradata from hevcc is slightly different from every IRAP frames have (in this case QP value is different) and the hevc_mp4toannexb filter prepends the different extradata to every IRAP frames, causing the broken frames.
Video File Repo :
https://www.dropbox.com/s/tpyohk6vf096zxm/hevc_after_mp4toannexb_conversion_qp_value_modified.mp4?dl=0
I am afraid that I can't connect to ftp://upload.ffmpeg.org, so I just attached to the dropbox url
How to reproduce:
% ffmpeg -i hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 -codec copy -bsf:v hevc_mp4toannexb output.hevc $vlc output.hevc
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Attachments (2)
Change History (30)
by , 6 years ago
Attachment: | hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 added |
---|
follow-ups: 3 2 comment:1 by , 6 years ago
follow-up: 3 comment:3 by , 6 years ago
Replying to cehoyos:
How did you create the input file?
Unfortunately, I did not create the video. It is automatically transcoded via a messenger application. (I do not exactly know how they transcode)
I know how to avoid this issue, (just not prepend the extra-data, if the extra-data has already existed on IRAP frames)
However, I do not exactly know whether this solution is correct or not.
follow-up: 3 comment:3 by , 6 years ago
comment:4 by , 6 years ago
The file I uploaded (hevc_after_mp4toannexb_conversion_qp_value_modified.mp4).
comment:6 by , 6 years ago
The messenger application called KAKAO-TALK, which is the famous app in Korea
The original one is H.264 encoded Video transcoded by Xiomi video editing application.
comment:7 by , 6 years ago
Keywords: | hevc added |
---|---|
Version: | unspecified → git-master |
follow-up: 9 comment:8 by , 5 years ago
hevc_mp4toannexb bsf doesn't insert correct parameter sets if they change in-band. For now, you can just use hevc_metadata filter to do the same job:
./ffmpeg -i hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 -bsf:v hevc_metadata -codec:v copy output.hevc
comment:9 by , 5 years ago
Replying to taliho:
hevc_mp4toannexb bsf doesn't insert correct parameter sets if they change in-band. For now, you can just use hevc_metadata filter to do the same job:
./ffmpeg -i hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 -bsf:v hevc_metadata -codec:v copy output.hevc
Thanks, I will try it and let you know
comment:10 by , 4 years ago
Status: | new → open |
---|
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20191016025040.31273-2-andriy.gelman@gmail.com/
Apply that already.
Issue showed itself here:
https://github.com/rigaya/NVEnc/issues/237
Actually with warning!
[hevc_mp4toannexb @ 000001cea55b2f00] No parameter sets in the extradata
So maybe other issue??
comment:12 by , 3 years ago
comment:13 by , 3 years ago
Sorry, it does NOT just look related, it is the "same" patch since FATE had the same change!! PLEASE APPLY!!!
-fate-hevc-bsf-mp4toannexb: REF = 1873662a3af1848c37e4eb25722c8df9 +fate-hevc-bsf-mp4toannexb: REF = 3c9d998a3aa2b9e0fb1c1f434952bf8b
follow-up: 17 comment:16 by , 3 years ago
follow-up: 18 comment:17 by , 3 years ago
Replying to Balling:
New patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220317063546.7429-1-haihao.xiang@intel.com/
Does this patch work for you ? Could you please comment on FFmpeg mailing list if it works ? thx
comment:18 by , 3 years ago
Replying to haihao:
Replying to Balling:
New patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220317063546.7429-1-haihao.xiang@intel.com/
Does this patch work for you ? Could you please comment on FFmpeg mailing list if it works ? thx
Please note that there is workaround with hevc_metadata, that is not affected, but in 2019 at least it could not "-c copy" nuh_layer_id != 0
One difference is that hevc_metadata currently only keeps the base layers
(nuh_layer_id == 0), whereas hevc_mp4toannexb copies everything (before my
patch). hevc_metadata will have a slightly higher complexity as it parses the full
parameter sets.
I will just point out how to test this bug on latest master:
Bad:
ffmpeg.exe -i hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 -c copy ajcwsaq.h265 ffplay.exe ajcwsaq.h265
Good:
ffmpeg.exe -i hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 -bsf:v hevc_metadata -c copy ajcwsaq1.h265 ffplay ajcwsaq1.h265
Also bad for ffplay.exe -vcodec hevc_cuvid hevc_after_mp4toannexb_conversion_qp_value_modified.mp4 since hw decoder in ffplay automatically insert Annex B convertion. Why, BTW???
comment:19 by , 3 years ago
Summary: | hevc_mp4toannexb filter inserts extradata wrong position → hevc_mp4toannexb filter inserts extradata wrong position (hevc_cuvid ffplay too) |
---|
I can verify that your patch, Haihao, did fix the bug and additional bug in ffplay -vcodec hevc_cuvid! I will attach the original file and fixed one. I am not sure whether it is a good idea to put data right behind "x265 (build 110) - 2.3:[Linux][GCC 5.4.0] ..." decoder info... But what do I know.
hevc_metadata does not appear to be able to handle the file perfectly, it looks like it truncates some 00 00 00 01 from
00 00 00 01 40 01 0C 01 FF FF 01 60 00 00 03 00 90 00 00 03 00 00 03 00 5D 95 94 09 00 00 00 01 42 01 01 01 60 00 00 03 00 90 00 00 03 00 00 03 00 5D A0 02 80 80 2D 16 59 59 52 93 0B C0 40 40 00 00 03 00 40 00 00 07 82 00 00 00 01 44 01 C0 73 C1 89}}}
by , 3 years ago
Attachment: | 3files.zip added |
---|
comment:20 by , 3 years ago
So the first file in 3files.zip is old broken one, second is old hevc_metadata (looks like missing some stuff in bitstream, but it plays) and third is with new patch from Intel guy.
The build is here on my github https://github.com/ValZapod/FFmpeg-Builds/actions/runs/2005445270 (click on artifacts)
comment:21 by , 3 years ago
Owner: | set to |
---|
Please merge the patch. The only issue is that it writes stuff before x265 internal SEI, but who cares.
comment:23 by , 2 years ago
Owner: | changed from | to
---|
So mkver, where is this genious sample
This only mitigates a certain case of wrongly inserted extradata; it
does not fix the underlying issue
Also
complexity emanating from HEVC's layers.
is hevc_metadata problem.
And to Soft Works:
I had missed this conversation and just recently noticed that Haihao's
Patch fixes HEVC decoding issues with certain files that I'm seeing
for a long time already
Where are the samples?
comment:27 by , 2 weeks ago
https://github.com/FFmpeg/FFmpeg/commit/0f824d792d20783fda64279ab94e16676e48c2e6
Chabged the md5 in FATE, but https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210910040948.14186-1-haihao.xiang@intel.com/ is still to be applied. So we need a new patch, btw this does not fix this issue, it is the other patch.
How did you create the input file?