<div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 13 Apr 2023 at 04:32, Gustav González <<a href="mailto:xtingray@gmail.com">xtingray@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div>Hi,</div><div>Currently, I am working on a little Libav example to split a small MP4 video into a PNG sequence.<br></div><div>So far, this is what I have right now:<br></div><div><a href="https://github.com/xtingray/MP4toPNG/blob/main/cutter.c" target="_blank">https://github.com/xtingray/MP4toPNG/blob/main/cutter.c</a></div><div><br></div><div>If you clone the repository on a Unix environment, it's effortless to test the example by running the build.sh script.</div><div>Most of the implementation is working: I load the MP4 input file, split the video into AVFrame variables, and then I use the libpng library to create the PNG files.</div><div>My only problem is that the images generated are misconfigured and gray-colored, just like this one: <br></div><div><a href="https://github.com/xtingray/MP4toPNG/blob/main/output/frame-1.png" target="_blank">https://github.com/xtingray/MP4toPNG/blob/main/output/frame-1.png</a></div><div><br></div><div>I am guessing the error is related to the way I take the AVFrame data and store it for the PNG file, but I am not sure at all:<br></div><div><br></div><div><table><tbody><tr><td id="m_-6385433217753284003gmail-LC317">  png_bytep *row_pointers = (png_bytep *) <span>malloc</span>(<span>sizeof</span>(png_bytep) * frame-><span>height</span>);</td>
        </tr>
        <tr>
          </tr></tbody></table><table><tbody><tr><td id="m_-6385433217753284003gmail-LC318">    <span>for</span> (<span>int</span> y = <span>0</span>; y < frame-><span>height</span>; y++) {</td>
        </tr>
        <tr>
          </tr></tbody></table><table><tbody><tr><td id="m_-6385433217753284003gmail-LC319">        row_pointers[y] = (png_bytep) (frame-><span>data</span>[<span>0</span>] + y * frame-><span>linesize</span>[<span>0</span>]);</td>
        </tr>
        <tr>
          </tr></tbody></table>    }</div><div><span><br></span></div>I appreciate any hint to fix the error. Thank you!<br><div><span><br></span></div><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div>--<br>  Gustav Gonzalez<br>  <a href="mailto:xtingray@gmail.com" target="_blank">xtingray@gmail.com</a><br><br></div></div></div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div><div dir="auto">Hi Gustav,</div><div dir="auto"><br></div><div dir="auto">Thats because you are only saving luminance component. There are also two more components for color, in following arrays frame->data[1] and frame->data[2].</div><div dir="auto"><br></div><div dir="auto">Kind regards,</div><div dir="auto">Strahinja</div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br>Regards<br>Strahinja Radman</div>