<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi there, </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I made some progress and now I can create a 10 MB file in .mp4 or mpeg , that opens in VLC without any warnings and I can see my target. But the file doesn't open in VirtualDub, should I worry ? also the first 12 frames are written to the encoding buffere but
 not written to the file and that is very disturbing because I need the very first frame. </div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Van:</b> Libav-user <libav-user-bounces@ffmpeg.org> namens laddoe <xyfix@hotmail.com><br>
<b>Verzonden:</b> vrijdag 26 februari 2021 16:15<br>
<b>Aan:</b> libav-user@ffmpeg.org <libav-user@ffmpeg.org><br>
<b>Onderwerp:</b> Re: [Libav-user] help needed on "Encoding .png images with h264 to a file on disk"</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Can somebody please have a look at my issue, it must be something small that I'm missing. I have posted my code previously, I'm missing a couple of frames in the movie output file and I can't open the movie with VLC , so I tried this:</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:#c0c0c0"></span>m_codecCtx<span style="color:#aaaaaa">-></span>gop_size<span style="color:#c0c0c0">
</span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span><span style="color:#ff55ff">0</span>;
<pre style="margin-top:0px; margin-bottom:0px">m_codecCtx<span style="color:#aaaaaa">-></span>max_b_frames<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span><span style="color:#ff55ff">0</span>;</pre>
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
and now it starts writing to the file from the 13th frame while it was from 26th with my previous code but the file still can't be opened in VLC. I expect in total 120 frames (5 sec at 24 fps ). </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I have ran also "recover_mp4.exe on the output video file: </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
recover_mp4.exe c:\tmp\outputVideo.mp4 result.h264 --noaudio --lav<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
and got this : </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
recover_mp4 v1.92 (C) 2011-2017 Dmitry Vasilyev <slydiman@mail.ru>
<div>http://slydiman.me</div>
<div><br>
</div>
<div>Writing H264 video file 'result.h264'...</div>
<div>Video format: Invalid AVC Configuration: Version 64</div>
<div>Invalid AVC Configuration: Size 0</div>
<div>Assuming max AVC/HEVC NAL unit size (IDR) 0x3FFFFF, (non IDR) 0xFFFFF</div>
<div>Used AVC templates: LAV/FFMPEG</div>
<div>Cannot open file 'audio.hdr'</div>
<div>Ignoring audio</div>
<div>Audio format: None</div>
<div>Searching 'mdat' atom in 'c:\tmp\outputVideo.mp4'...</div>
<div>mdat (32-bit) payload from 0x30 to 0x928FF9</div>
<div>%0.000</div>
<div>H264: 0x00000030 [0x     272] -> 0x       0 {06 05 FF FF} SEI</div>
<div>H264: 0x000002A2 [0x    4663] -> 0x     272 {65 88 84 17} IDR frame</div>
<div>H264: 0x00004905 [0x    AECE] -> 0x    48D5 {65 88 82 02} IDR frame</div>
<div>H264: 0x0000F7D3 [0x    AD96] -> 0x    F7A3 {65 88 84 0B} IDR frame</div>
<div>H264: 0x0001A569 [0x    AF83] -> 0x   1A539 {65 88 82 02} IDR frame</div>
<div>H264: 0x000254EC [0x    AF6E] -> 0x   254BC {65 88 84 0B} IDR frame</div>
<div>H264: 0x0003045A [0x    AE62] -> 0x   3042A {65 88 82 02} IDR frame</div>
<div>H264: 0x0003B2BC [0x    AF72] -> 0x   3B28C {65 88 84 0B} IDR frame</div>
<div>H264: 0x0004622E [0x    B119] -> 0x   461FE {65 88 82 02} IDR frame</div>
H264: 0x00051347 [0x    AF49] -> 0x   51317 {65 88 84 0B} IDR frame<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
..... </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
In total there are 107 IDR frames detected in the movie so I'm missing 13 frames( probablye the 13 mentioned above)</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
If I open my output video file with virtualdub hexeditor I got this : </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<img size="92937" tabindex="-1" style="max-width:100%" data-outlook-trace="F:2|T:2" src="cid:7056d579-cdb1-4275-bf15-96a14e20c86f"><br>
</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Van:</b> Libav-user <libav-user-bounces@ffmpeg.org> namens laddoe <xyfix@hotmail.com><br>
<b>Verzonden:</b> donderdag 25 februari 2021 15:07<br>
<b>Aan:</b> libav-user@ffmpeg.org <libav-user@ffmpeg.org><br>
<b>Onderwerp:</b> Re: [Libav-user] help needed on "Encoding .png images with h264 to a file on disk"</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi Gonzalo, all, </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
thanks for pointing out what I did wrong. I now get files that are of reasonable sizes 20 MB, something that one would expect. I have added the .h and .cpp file that I have modified according to your feedback and I have also added the .h file for the image
 class. But the generated videofiles that I get can not be read by VLC or any other application. </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
When I run "ffmpeg.exe -v error -i c:\tmp\myVideo.mp4 -f null - >error.log 2>&1 " , I get the following error lines multiple times :</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
[h264 @ 05c0c780] No start code is found.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
[h264 @ 05c0c780] Error splitting the input into NAL units.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Error while decoding stream #0:0: Invalid data found when processing input<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I have also attached a debug output file that is created by my C++/Qt application in which you'll see which images are send to the encoder. What I don't understand is that the first 26 frames are send to the encoder but not written to the file, I know that
 the H264 needs some frames before it starts encoding but I would like those frames to be written to the videofile as well. </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Your help is greatly appreciated. </div>
<div id="x_x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Van:</b> Libav-user <libav-user-bounces@ffmpeg.org> namens Gonzalo Garramuño <ggarra13@gmail.com><br>
<b>Verzonden:</b> maandag 22 februari 2021 17:55<br>
<b>Aan:</b> libav-user@ffmpeg.org <libav-user@ffmpeg.org><br>
<b>Onderwerp:</b> Re: [Libav-user] help needed on "Encoding .png images with h264 to a file on disk"</font>
<div> </div>
</div>
<div style="background-color:#FFFFFF">
<p><br>
</p>
<div class="x_x_x_moz-cite-prefix">El 22/2/21 a las 05:25, laddoe escribió:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
can anybody please help me with my post of 2 days ago, I'm really stuck but not able to understand what is wrong. I have also tried several different code examples but it all ends up the same as mentioned in the post. Am I not understanding this ? Are my expectations
 of the results incorrect? I'm new to this so please bear with me. </div>
<br>
</blockquote>
<p><br>
</p>
<p>One thing that is wrong in your code is that you never call av_write_trailer(), which should be called before avio_close().</p>
<p>Also, there's no need for m_file in your code.  avformat handles the file for you.</p>
<p>Other things are hard to say, as you don't provide the code to the Image or cv::Mat classes.  You should provide a self-compilable example for us to help you.<br>
</p>
</div>
</div>
</div>
</body>
</html>