FFmpeg can optimally re-encode video from numerous formats for YouTube (or other service) upload.
YouTube suggested settings
for SDR video are implemented below.
There are additional settings for
HDR Video.
BT.709 color space for SDR video. HDR should not use this flag.
-i in.avi
input file
-b:v 8M -bufsize 16M
8 Mbps video bitrate with 16 Mbps buffer size. This assumes 1080p input video–adjust this to the actual resolution of the input video. Use the bitrate table to choose appropriately.
When CMake fails on the configure or generate steps in a CI workflow, having CMakeConfigureLog.yaml uploaded a as a file can help debug the issue.
Add this step to the GitHub Actions workflow YAML file:
The “retention-days” parameter is optional.
Ensure the “name” parameter is unique to avoid conflicts with other jobs in the workflow.
Here we assume that the OS and C compiler are unique between jobs.
Fortran programs, like most other programming languages, can access the standard input, output, and error streams, which usually connect to the terminal.
Stream buffering generally increases efficiency of small bursts or groups of text typical to interactive applications.
Buffering means that data is not immediately written to the terminal or console until the buffer is full or flushed.
The Fortran statement to flush is flush(unit), where unit is the unit number of the stream to flush.
Fortran statement print automatically flush the stream.
Fortran statement write flushes the stream unless the advance specifier is set to no.
Different compilers have distinct default stream buffering behavior.
Gfortran: streams buffered by default. Environment variable GFORTRAN_UNBUFFERED_PRECONNECTED can be set to “y” to disable buffering.
Intel Fortran “ifx”: streams unbuffered by default. Environment variable FORT_BUFFERED can be set to “TRUE” to enable buffering.
NASA CDF data file format can be read in many languages including Matlab.
Matlab data file interfaces don’t always yield an obvious error message if something is wrong like a data file doesn’t exist or a variable doesn’t exist in a data file.
For CDF, the message for
cdfread
of a non-existent variable is like:
Error using matlab.internal.imagesci.cdflib
CDF library failure encountered when executing the CDFclosezVar routine: “ILLEGAL_IN_zMODE: Operation is illegal while in zMode.”
One can use try-catch or check that the variable name exists with
cdfinfo.Variables column 1.
The Clang / Flang compiler versions on GitHub Actions might be older than desired.
While GCC is usually the latest release on GA, LLVM might be a couple versions behind latest.
This example shows how to install a range of LLVM versions in a GitHub Actions workflow.
Matlab built-in functions can be overloaded in classes or in general.
This can be useful when making code compatible with both Matlab and GNU Octave, or to be compatible with older Matlab versions.
For example, the Matlab built-in function
strlength
gets the length of char and string arrays, but older Matlab and GNU Octave don’t have this function.
We made a function in strlength.m in a project’s private/ directory like:
%% STRLENGTH get length of character vector or scalar stringfunctionL =strlength(s)L = [];
if ischar(s)
L = length(s);
elseif isstring(s)
L = builtin('strlength', char(s));
% char() is workaround for bug described belowendend
A bug we found and confirmed by Xinyue Xia of Mathworks Technical Support is as follows:
strlength() works with char, or string scalars or N-D arrays.
However, when using
builtin('strlength')
only char is accepted.
Scalar or N-D string array errors unexpectedly.
Example:
builtin('strlength', ["hi", "there"])
we expect to get [2,5] but instead get:
Error using strlength
First argument must be text.
builtin('strlength', "hi")
expect value 2, but instead get
Error using strlength
First argument must be text.
Matlab graphics rendering can break with remote desktop via VNC or X11 forwarding.
Local Matlab plots can break due to GPU graphics driver problems.
Before Matlab R2025a, setting Matlab figure
renderer
could workaround Matlab plot issues.
Consider using Matlab Online for remote development if available.
f = figure;
% Obsolete as of Matlab R2025aset(f, Renderer='painters', RendererMode='manual')
Matlab
rendererinfo()
provides extensive details about the rendering backend.
The POSIX epoch time is the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.
Operations involving POSIX epoch time, particularly on Windows, may run into Year 2038 problems if “long” type is used to store the epoch time in seconds.
The
“long” int type
only guarantees 32-bit integers, which can store values up to 2,147,483,647.
The maximum value that can be stored in a 32-bit signed integer is 2,147,483,647, which corresponds to 03:14:07 UTC on Tuesday, 19 January 2038.
After this time, a 32-bit “long” value will overflow, which can cause unexpected behavior in applications that rely on the epoch time.
To avoid this problem in a cross-platform compatible manner, consider the explicit 64-bit integer type
int64_t
to store the epoch time in programs written in C, C++ or likewise in other code languages to store POSIX epoch time.
We chose “int64_t” instead of “long long” to be explicit about the integer size needed and useful, which is a general best practice in C / C++.
Example using std::difftime to calculate the difference between two time points:
#include<cstdint>#include<ctime>#include<string>#include<iostream>intmain() {
std::time_t t1 = 0;
std::time_t t2 = 2147483648; // 03:14:08 UTC on Tuesday, 19 January 2038
std::string posix = std::to_string(static_cast<std::int64_t>(std::difftime(t2, t1)));
std::cout << "POSIX time difference: " << posix << " seconds\n";
return0;
}
CMake 4.0 introduced a formal end of support
schedule
for older CMake versions.
This schedule impacts
cmake_minimum_required
in that a CMake project will not configure if
CMAKE_POLICY_VERSION_MINIMUM
is older than the minimum version of CMake that is still supported.
Practical observations of CMake projects are that projects too often have CMake minimum versions that aren’t actually usable, or set to CMake versions so old that they are difficult to run on modern computers.
A good CI test is to have an old CMake version that matches cmake_minimum_required(VERSION) to see if the project actually works with such an old CMake version.
Find the date of a CMake release under
Milestones.