How to convert RGB from YUV420p for ffmpeg encoder?

You can use libswscale from FFmpeg like this: #include <libswscale/swscale.h> SwsContext * ctx = sws_getContext(imgWidth, imgHeight, AV_PIX_FMT_RGB24, imgWidth, imgHeight, AV_PIX_FMT_YUV420P, 0, 0, 0, 0); uint8_t * inData[1] = { rgb24Data }; // RGB24 have one plane int inLinesize[1] = { 3*imgWidth }; // RGB stride sws_scale(ctx, inData, inLinesize, 0, imgHeight, dst_picture.data, dst_picture.linesize); Note that you … Read more

How to resize a picture using ffmpeg’s sws_scale()?

First you need to create a SwsContext (you need to do this only once) : struct SwsContext *resize; resize = sws_getContext(width1, height1, AV_PIX_FMT_YUV420P, width2, height2, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL); You need two frames for conversion, frame1 is the original frame, you need to explicitly allocate frame2 : AVFrame* frame1 = avcodec_alloc_frame(); // this is … Read more

Using ffmpeg to change framerate

With re-encoding: ffmpeg -y -i seeing_noaudio.mp4 -vf “setpts=1.25*PTS” -r 24 seeing.mp4 Without re-encoding: First step – extract video to raw bitstream ffmpeg -y -i seeing_noaudio.mp4 -c copy -f h264 seeing_noaudio.h264 Remux with new framerate ffmpeg -y -r 24 -i seeing_noaudio.h264 -c copy seeing.mp4

How to install and run phpize

For recent versions of Debian/Ubuntu (Debian 9+ or Ubuntu 16.04+) install the php-dev dependency package, which will automatically install the correct version of php{x}-dev for your distribution: sudo apt install php-dev Older versions of Debian/Ubuntu: For PHP 5, it’s in the php5-dev package. sudo apt-get install php5-dev For PHP 7.x (from rahilwazir comment): sudo apt-get … Read more

Text on video ffmpeg

Use the drawtext filter for simple text on video. If you need more complex timing, formatting, or dynamic text see the subtitles filter. This answer focuses on the drawtext filter. Example Print Stack Overflow in white text onto center of video, with black background box of 50% opacity: ffmpeg -i input.mp4 -vf “drawtext=fontfile=/path/to/font.ttf:text=”Stack Overflow”:fontcolor=white:fontsize=24:box=1:[email protected]:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2″ -codec:a … Read more

How to output fragmented mp4 with ffmpeg?

This should do the trick: ffmpeg -re -i infile.ext -g 52 \ -c:a aac -b:a 64k -c:v libx264 -b:v 448k \ -f mp4 -movflags frag_keyframe+empty_moov \ output.mp4 frag_keyframe causes fragmented output, empty_moov will cause output to be 100% fragmented; without this the first fragment will be muxed as a short movie (using moov) followed by … Read more