<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hi all,<o:p></o:p></p><p>I am hoping someone may be able to help with this issue.<o:p></o:p></p><p>I am trying to generate an mp4 file using ffmpeg containing already encoded H265 data. I am providing the H265 nal units to <code><span style='font-size:10.0pt'>av_write_frame</span></code> with the VPS, SPS and PPS already in the stream before each I frame.<o:p></o:p></p><p>When I extract the nal units back out of the mp4 file and look at them, there are extra VPS, SPS and PPS before each I frame. For most streams this is inefficient but not a problem, however some of the streams use sliced I frames and the extra nal units are inserted before each slice of the I frame which causes only the first slice to be decodable as the VPS, SPS and PPS are not allowed to be included between slices of the same frame.<o:p></o:p></p><p>We also process H264 video and ffmpeg does not add extra SPS or PPS in front of I frames in H264 streams. We are not providing the VPS, SPS and PPS as side data in the packets, but rather as individual packets for each nal unit. We do use ffmpeg to scan the input to get the codec parameters to use to configure but do not use ffmpeg to encode or decode the video or in any other way process the nal units with ffmpeg.<o:p></o:p></p><p>I have a minimal sample program that shows the issue and have included the code below. We are using different code to load and process the data before passing the data to ffmpeg but I have hard coded the properties of the video for this sample. The video file is also attached. If a different input is required, the <code><span style='font-size:10.0pt'>nalUnits</span></code> array will need to be re-generated for the new input file.<o:p></o:p></p><p>I am compiling in Visual Studio 2019 with ffmpeg version 4.4.1 from <a href="http://www.gyan.dev">www.gyan.dev</a> (<a href="https://github.com/FFmpeg/FFmpeg/commit/7e0d640edf">https://github.com/FFmpeg/FFmpeg/commit/7e0d640edf</a>)<o:p></o:p></p><p>I have tried ensuring that the read codec parameters do not include the metadata frames and messing with the timestamps (so that all the slices have the same pts but not dts) but with no progress.<o:p></o:p></p><p>Any suggestions of things to try or comments on the code would be very much appreciated.<o:p></o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Simon<o:p></o:p></p></div></body></html>