sprintf / snprintf Problem on Arduino.

What a day. Spent the day hunting a bug in my code, only to find out that it wasn’t in my code. (Update: Turns out my code was wrong in two ways, more below the original entry.) (Update 2: There are options to set this in the Arduino IDE Preferences)

There’s an error in the sprintf and snprintf implementation on Arduino that occurs when more than 8 varargs are passed in after the format specifier.

Continue reading sprintf / snprintf Problem on Arduino.

ffmpeg: Stripping Audio and Scaling Down Video

Rather than use animated GIFs when I’m trying to show a video without sound, I prefer to use ffmpeg to strip out the audio and scale down the video. I’ve looked this command up way too many times:

ffmpeg -i test.mp4 -c:v libx264 -profile:v baseline -vf scale=640:-1 -an test-640.mp4

Update 7 October 2018:

Twitter has some video requirements such as a maximum framerate, that need to be accounted for:

ffmpeg -i test.mp4 -c:v libx264 -profile:v baseline -vf scale=540:-1 -t 30 -r:0.0 30 test-540.mp4

The above command will rescale the video to a quarter of Full HD resolution in portrait orientation, set a duration of 30 seconds (the -t option) and set the output video stream 0.0 framerate to 30 frames per second.

Update 2 July 2019:

ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline -vf scale=1280:-1 -an -ss 5.5 test-1280.mp4

Set the start time at 5.500 seconds and scale to 1280px width.

ffmpeg -i input.mp4 -vframes 1 -vf scale=1280:-1 “poster.jpg”

Create a poster image for the video file.

Update 30 August 2019:

Measure-Command { ffmpeg -i video-nonoisereduct-noedgeenhance-with-log-medium.mp4 -c:v ffvhuff -an -filter:v “scale=640:-1” test-output-ffvhuff-640.mkv }

Measuring the amount of time ffmpeg takes to transcode on Windows using Powershell (similar to the time command on Linux).

This was a test of ffvhuff as a codec, and pushing the file down into a proxy-file sized format, something I’ll be learning more about in the future.

Update 11 December 2019:

This one had a bit of audio hum in it that I wanted to remove using Audacity.

Step 1: Copy and Trim Off 15s

ffmpeg -i “input.avi” -c:a copy -c:v copy -ss 15 output-1.mkv

Step 2: Copy audio out

ffmpeg -i output-1.mkv -c:a copy output-2.wav

Step 3: Edit in Audacity

Amplify:

Remove the 60Hz hum using https://wiki.audacityteam.org/wiki/Nyquist_Effect_Plug-ins#Hum_Remover and the following settings:

Remove remaining noise with Noise Reduction effect:

Step 4: Remerge audio, replacing existing audio, re-encode video, and deinterlace.

ffmpeg -i output-1.mkv -i output-3.wav -ar 32k -c:a aac -b:a 128k -c:v libx264 -profile:v main -pix_fmt yuv420p -movflags +faststart -preset veryslow -crf 17 -vf “yadif=mode=1” -map 0:v:0 -map 1:a:0 -t 10 output-4.mp4