see also http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/
| 1099 | |
| 1100 | // see also http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/ |
| 1101 | void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName) |
| 1102 | { |
| 1103 | if (mp4FileName) |
| 1104 | { |
| 1105 | int width = (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenWidth(); |
| 1106 | int height = (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenHeight(); |
| 1107 | char cmd[8192]; |
| 1108 | |
| 1109 | sprintf(cmd, |
| 1110 | "ffmpeg -r %d -f rawvideo -pix_fmt rgba -s %dx%d -i - " |
| 1111 | "-threads 0 -y -b:v 50000k -c:v libx264 -preset slow -crf 22 -an -pix_fmt yuv420p -vf vflip %s", |
| 1112 | m_data->m_mp4Fps, width, height, mp4FileName); |
| 1113 | |
| 1114 | |
| 1115 | if (m_data->m_ffmpegFile) |
| 1116 | { |
| 1117 | pclose(m_data->m_ffmpegFile); |
| 1118 | } |
| 1119 | if (mp4FileName) |
| 1120 | { |
| 1121 | m_data->m_ffmpegFile = popen(cmd, "w"); |
| 1122 | |
| 1123 | m_data->m_frameDumpPngFileName = mp4FileName; |
| 1124 | } |
| 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | if (m_data->m_ffmpegFile) |
| 1129 | { |
| 1130 | fflush(m_data->m_ffmpegFile); |
| 1131 | pclose(m_data->m_ffmpegFile); |
| 1132 | m_data->m_frameDumpPngFileName = 0; |
| 1133 | } |
| 1134 | m_data->m_ffmpegFile = 0; |
| 1135 | } |
| 1136 | } |
| 1137 | void SimpleOpenGL3App::dumpNextFrameToPng(const char* filename) |
| 1138 | { |
| 1139 | // open pipe to ffmpeg's stdin in binary write mode |
no test coverage detected