video

tools

youtube-dl

Download best video + audio

List all available formats youtube-d -F <id>

Download and mux the selected IDs youtube-dl -f <video_id>+<audio_id> <id>

ffmpeg

Add language information to audio

ffmpeg -i audio.m4a -metadata:s:a:0 language=<iso code> output.m4a

Add audiotracks to mp4

ffmpeg -i video.mp4 -i audio_1.m4a -i audio_2.m4a -map 0:0 -map 1:0 -map 2:0 -c:v copy -c:a copy output.mp4

Remove audio

ffmpeg -i $input_file -vcodec copy -an $output_file

Low Latency ScreenGrab

ffmpeg -f avfoundation -capture_cursor 1 -i 3 -r 30 -c:v libx264 -an -tune zerolatency -preset ultrafast -pix_fmt yuv420p -fflags flush_packets -f mpegts - | mpv - --no-cache --untimed --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1

List encoder options

ffmpeg -h encoder=h264_videotoolbox

ffprobe fmp4

cat ./init.mp4 ./test0.m4s | ffprobe -show_frames -

cut video

ffmpeg -ss <starttime> -i <mp4> -t <duration> output.mp4

Scale video w. same aspect ratio

ffmpeg -i <input> -vf scale=320:-1 <output>

Loop mp4 as hls/dash

Dash: ffmpeg -re -stream_loop -1 -i ForBiggerBlazes.mp4 -c:v copy -c:a copy -f dash live.mpd Hls: ffmpeg -re -stream_loop -1 -i ForBiggerBlazes.mp4 -c:v copy -c:a copy -f hls live.m3u8

MPV

Play stream low latency

mpv <input> --no-cache --untimed --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1

formats

mss

FourCC AVC1 vs H.264

https://docs.microsoft.com/en-us/windows/win32/directshow/h-264-video-types?redirectedfrom=MSDN

get avc codec from CodecPrivateData

 // Copyright (c) 2015, Dash Industry Forum
 function getH264Codec(codecPrivateData) {
    // Extract from the CodecPrivateData field the hexadecimal representation of the following
    // three bytes in the sequence parameter set NAL unit.
    // => Find the SPS nal header
    nalHeader = /00000001[0-9]7/.exec(codecPrivateData);
    // => Find the 6 characters after the SPS nalHeader (if it exists)
    avcoti = nalHeader && nalHeader[0] ? (codecPrivateData.substr(codecPrivateData.indexOf(nalHeader[0]) + 10, 6)) : undefined;

    return 'avc1.' + avcoti;
}