This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Debugging with vscode and conda python: | |
- Install vs code | |
- Follow https://medium.com/analytics-vidhya/efficient-way-to-activate-conda-in-vscode-ef21c4c231f2 to add conda terminal to vs code via launch.json. Args have to be added like | |
"args": ["--aa=2", "--ab=1", "--sm", "--input=asd.img"] | |
- Close vscode | |
-- open conda prompt, activate required environment via conda activate myEnv | |
- launch vscode from the command prompt, using "code" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Creating SBS (side by side) videos: | |
ffmpeg -i input_file -i input_file2 -filter_complex hstack -vcodec libx264 -b:v 30M -vsync 0 output.mp4 | |
#MP4 from raw YUV | |
ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -pix_fmt yuv420p -i input.yuv -c:v libx264 -preset slow -qp 0 -vsync 0 -pix_fmt nv12 output.mp4 | |
#Scaling: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Building C++ application with static build of libcurl: | |
/* | |
1. In the project, C++ preprocessor to be defined - "CURL_STATICLIB" | |
2. CURL itself should be built with: | |
- static option | |
- SSL static | |
- IPV6 static | |
- SSPI static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// av_log_set_callback(ffmpeg_avcodec_log); | |
static void ffmpeg_avcodec_log(void *ptr, int val, const char * msg, va_list | |
ap) | |
{ | |
AVClass* avc = ptr ? *(AVClass**)ptr : NULL; | |
FILE *flog = fopen("stream-receiver.log", "a"); | |
if (avc) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define OUTPUT_W 1920 | |
#define OUTPUT_H 1080 | |
#define OUTPUT_FPS 25 | |
int main() | |
{ | |
int ret = 0; | |
bool bUseHW = false; | |
bool bNv = false; | |
Encoder* pEnc = new Encoder(bUseHW, bNv, OUTPUT_W, OUTPUT_H, OUTPUT_FPS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a texture and register it for sharing with CUDA. | |
int setup_external_texture_oes(nengl_ws* ws, void* window) | |
{ | |
int isSupported = -1; | |
isSupported = ws->check_extension("EGL_KHR_gl_texture_2D_image"); | |
isSupported = ws->check_extension("GL_OES_EGL_image_external"); | |
constexpr GLsizei texSize = 32; | |
GLubyte data[texSize * texSize * 4]; | |
GLuint mSourceTexture, mExternalTexture; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLuint positionsVBO; | |
struct cudaGraphicsResource* positionsVBO_CUDA; | |
int main() { | |
// Explicitly set device | |
cudaGLSetGLDevice(0); | |
// Initialize OpenGL and GLUT | |
... | |
glutDisplayFunc(display); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://stackoverflow.com/questions/59666753/encode-video-from-c-using-libavcodec-and-vaapi | |
#ifndef ENCODER_H | |
#define ENCODER_H | |
#include <cassert> | |
extern "C" { | |
#include <libavcodec/avcodec.h> | |
#include <libavformat/avformat.h> | |
#include <libavutil/opt.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/62279768/avcodec-encode-video2-the-memory-usage-is-very-high | |
extern "C" | |
{ | |
#ifndef __STDC_CONSTANT_MACROS | |
#define __STDC_CONSTANT_MACROS | |
#endif | |
#include <libavcodec/avcodec.h> | |
#include "libavformat/avformat.h" | |
#include "libswscale/swscale.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Snippet from https://stackoverflow.com/questions/16252905/why-do-i-get-a-crash-only-sometimes-when-closing-input-file-with-ffmpeg | |
// save the frame to file | |
int Bytes = avpicture_get_size(PIX_FMT_YUVJ420P, CodecCtx->width, CodecCtx->height); | |
BufferHandle buffer((uint8_t*)av_malloc(Bytes*sizeof(uint8_t)), av_free); | |
CodecContextHandle OutContext(avcodec_alloc_context3(NULL), free_context); | |
OutContext->bit_rate = CodecCtx->bit_rate; | |
OutContext->width = CodecCtx->width; | |
OutContext->height = CodecCtx->height; | |
OutContext->pix_fmt = PIX_FMT_YUVJ420P; | |
OutContext->codec_id = CODEC_ID_MJPEG; |
NewerOlder