<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13425" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2022-05-05T20:53:45+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13425</id>

		<entry>
		<author><name><![CDATA[yluo]]></name></author>
		<updated>2022-05-05T20:53:45+00:00</updated>

		<published>2022-05-05T20:53:45+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44006#p44006</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44006#p44006"/>
		<title type="html"><![CDATA[Re: Try to output videos using SimpleOpenGL3App::dumFramesToVideo()]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44006#p44006"><![CDATA[
I figured it out. <br><br>I'm running this on Windows OS. So I need to go to the source file "SimpleOpenGL3App.cpp" function <div class="codebox"><p>Code: </p><pre><code>void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName)</code></pre></div> and change <div class="codebox"><p>Code: </p><pre><code>m_data-&gt;m_ffmpegFile = popen(cmd, "w");</code></pre></div> into <div class="codebox"><p>Code: </p><pre><code>m_data-&gt;m_ffmpegFile = popen(cmd, "wb");</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13039">yluo</a> — Thu May 05, 2022 8:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[yluo]]></name></author>
		<updated>2022-04-22T22:23:00+00:00</updated>

		<published>2022-04-22T22:23:00+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43989#p43989</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43989#p43989"/>
		<title type="html"><![CDATA[Try to output videos using SimpleOpenGL3App::dumFramesToVideo()]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43989#p43989"><![CDATA[
Hi everyone,<br>I have a simple simulation running with a basic opengl app and now I want to output the simulation results into a video.<br><br>I followed the example <a href="https://cpp.hotexamples.com/examples/-/SimpleOpenGL3App/dumpFramesToVideo/cpp-simpleopengl3app-dumpframestovideo-method-examples.html" class="postlink">here</a>. Specifically, I used the built-in method SimpleOpenGL3App::dumFramesToVideo(Filename). To run this I downloaded the ffmpeg executables and added it to PATH. I'm getting error at the last frame. <div class="codebox"><p>Code: </p><pre><code>[rawvideo @ 000001f6a6c1c9c0] Packet corrupt (stream = 0, dts = 30).pipe:: corrupt input packet in stream 0[rawvideo @ 000001f6a6c309c0] Invalid buffer size, packet size 11490 &lt; expected frame_size 3145728Error while decoding stream #0:0: Invalid argumentframe=   30 fps= 14 q=-1.0 Lsize=     659kB time=00:00:00.45 bitrate=11997.1kbits/s speed=0.212xvideo:658kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.179747%[libx264 @ 000001f6a6c32b00] frame I:2     Avg QP:26.98  size: 25858[libx264 @ 000001f6a6c32b00] frame P:12    Avg QP:28.75  size: 20910[libx264 @ 000001f6a6c32b00] frame B:16    Avg QP:30.83  size: 23150[libx264 @ 000001f6a6c32b00] consecutive B-frames:  6.7% 66.7%  0.0% 26.7%[libx264 @ 000001f6a6c32b00] mb I  I16..4: 61.4%  7.4% 31.2%[libx264 @ 000001f6a6c32b00] mb P  I16..4: 17.2%  5.8% 10.9%  P16..4: 35.3% 11.1%  3.2%  0.0%  0.0%    skip:16.4%[libx264 @ 000001f6a6c32b00] mb B  I16..4: 21.7%  2.6%  9.6%  B16..8: 36.8%  9.9%  2.4%  direct: 7.2%  skip:10.0%  L0:45.6% L1:46.2% BI: 8.2%[libx264 @ 000001f6a6c32b00] 8x8 transform intra:11.0% inter:15.6%[libx264 @ 000001f6a6c32b00] direct mvs  spatial:62.5% temporal:37.5%[libx264 @ 000001f6a6c32b00] coded y,uvDC,uvAC intra: 24.3% 48.4% 37.9% inter: 10.9% 36.2% 23.7%[libx264 @ 000001f6a6c32b00] i16 v,h,dc,p: 46% 53%  1%  0%[libx264 @ 000001f6a6c32b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16%  8% 75%  0%  0%  0%  0%  0%  1%[libx264 @ 000001f6a6c32b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 37% 19%  2%  1%  1%  2%  2%  3%[libx264 @ 000001f6a6c32b00] i8c dc,h,v,p: 25% 45% 29%  1%[libx264 @ 000001f6a6c32b00] Weighted P-Frames: Y:0.0% UV:0.0%[libx264 @ 000001f6a6c32b00] ref P L0: 18.4%  0.8% 57.4%  6.6% 16.8%[libx264 @ 000001f6a6c32b00] ref B L0: 47.4% 36.9% 11.3%  4.5%[libx264 @ 000001f6a6c32b00] ref B L1: 97.1%  2.9%[libx264 @ 000001f6a6c32b00] kb/s:10768.56</code></pre></div>I tried to googled and it seems like a pretty common error that people get when they try to implement ffmpeg themselves. The output video is also twisted. I tried to make three screenshots and compare it to what the simulation should've looked like. There is a consistent offset from frame to frame, and the colors are too corrupted.<br><br><a href="https://www.linkpicture.com/view.php?img=LPic626329ef2961a1795933395" class="postlink"><img src="https://www.linkpicture.com/q/1_4.jpg" class="postimage" alt="Image"></a><br><br>I'm completely new to ffmpeg and since it's a built-in method in Bullet I don't think the best idea is to change the source code right? So I'm totally lost what I'm missing here. I'm also attaching my main.cpp for reference<br><div class="codebox"><p>Code: </p><pre><code>int main(int argc, char** argv){std::cout &lt;&lt; "main starts.\n";SimpleOpenGL3App *app = new SimpleOpenGL3App("Simulation test", 1024, 768, true);prevMouseButtonCallback = app-&gt;m_window-&gt;getMouseButtonCallback();prevMouseMoveCallback = app-&gt;m_window-&gt;getMouseMoveCallback();app-&gt;m_window-&gt;setMouseButtonCallback((b3MouseButtonCallback)OnMouseDown);app-&gt;m_window-&gt;setMouseMoveCallback((b3MouseMoveCallback)OnMouseMove);OpenGLGuiHelper gui(app, false);CommonExampleOptions options(&amp;gui);Parameter *param = new Parameter();simulation = new Simulation(options.m_guiHelper);simulation-&gt;processCommandLineArgs(argc, argv);simulation-&gt;initParameter(param);simulation-&gt;initPhysics();simulation-&gt;resetCamera();char bla[32];float clr_black[4] = { 1, 1, 1, 1 };const char* videoFileName = "../output/output_video.mp4";app-&gt;dumpFramesToVideo(videoFileName);app-&gt;m_renderer-&gt;writeTransforms();do {static int frameCount = 0;frameCount++;// initializing renderedapp-&gt;m_instancingRenderer-&gt;init();app-&gt;m_instancingRenderer-&gt;updateCamera(app-&gt;getUpAxis());// step simualtion//simulation-&gt;stepSimulation(param-&gt;m_time_step);simulation-&gt;stepSimulation(param-&gt;m_time_step);// render instancessimulation-&gt;renderScene();app-&gt;m_renderer-&gt;renderScene();// draw gridDrawGridData dg;dg.gridSize = 15;dg.upAxis = app-&gt;getUpAxis();app-&gt;setBackgroundColor(1, 1, 1);app-&gt;drawGrid(dg);// draw Textsprintf(bla, "Frame: %d", frameCount);app-&gt;drawText(bla, 10, 10, 0.5, clr_black);// end rendering this frameapp-&gt;swapBuffer();}while (!app-&gt;m_window-&gt;requestedExit() &amp;&amp; !(exitFlag || simulation-&gt;exitSim));simulation-&gt;exitPhysics();std::cout &lt;&lt; "Simulation terminated...\n";delete simulation;delete param;delete app;std::cout &lt;&lt; "Done. Exit Safe.\n";return 0;}</code></pre></div>Thank you for your kind help!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13039">yluo</a> — Fri Apr 22, 2022 10:23 pm</p><hr />
]]></content>
	</entry>
	</feed>
