add --mp4fps=30 command line parameter for ExampleBrowser (and using pybullet.connect(p.GUI, options="--mp4fps=30 --mp4=\"testvideo.mp4\"")

This commit is contained in:
Erwin Coumans
2020-01-11 12:19:42 -08:00
parent 8ebdf7862c
commit 83bdef8254
4 changed files with 22 additions and 5 deletions

View File

@@ -66,6 +66,8 @@ struct SimpleInternalData
int m_upAxis; //y=1 or z=2 is supported
int m_customViewPortWidth;
int m_customViewPortHeight;
int m_mp4Fps;
SimpleInternalData()
: m_fontTextureId(0),
m_largeFontTextureId(0),
@@ -82,7 +84,8 @@ struct SimpleInternalData
m_userPointer(0),
m_upAxis(1),
m_customViewPortWidth(-1),
m_customViewPortHeight(-1)
m_customViewPortHeight(-1),
m_mp4Fps(60)
{
}
};
@@ -1089,6 +1092,11 @@ void SimpleOpenGL3App::swapBuffer()
m_window->startRendering();
}
void SimpleOpenGL3App::setMp4Fps(int fps)
{
m_data->m_mp4Fps = fps;
}
// see also http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/
void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName)
{
@@ -1100,12 +1108,12 @@ void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName)
#ifdef _WIN32
sprintf(cmd,
"ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - "
"ffmpeg -r %d -f rawvideo -pix_fmt rgba -s %dx%d -i - "
"-threads 0 -y -b:v 50000k -c:v libx264 -preset slow -crf 22 -an -pix_fmt yuv420p -vf vflip %s",
width, height, mp4FileName);
m_data->m_mp4Fps, width, height, mp4FileName);
//sprintf(cmd, "ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - "
// "-y -crf 0 -b:v 1500000 -an -vcodec h264 -vf vflip %s", width, height, mp4FileName);
//sprintf(cmd, "ffmpeg -r %d -f rawvideo -pix_fmt rgba -s %dx%d -i - "
// "-y -crf 0 -b:v 1500000 -an -vcodec h264 -vf vflip %s", m_data->m_mp4Fps, width, height, mp4FileName);
#else
sprintf(cmd,