Код отслеживания Google Analytics.

Dec 26, 2020

ffmpeg jotting

  • crop detect:
ffplay -i v_rus.mp4 -vf "cropdetect=24:16:0"
cropdetect=limit:round:reset
limit = black threshold (default 24)
round = output resolution must be divisible to this
reset = after how many frames the detection process will start over
ffmpeg -i in.mp4 -vf "crop values" out.mp4

(source1, source2)

  • subtitle converters
SRT in WebVTT:
ffmpeg -i file.srt file.vtt
  • resize a video
ffmpeg -i "in.mp4" -vf scale="720:-1" out.mp4

(source1, source2)

  • get video info
ffprobe -i in.mp4 -show_format
Duration:
ffprobe -i in.mp4 -show_format 2>&1 | grep Duration
  • two pass H.264 Video Encoding
....
#bitrate = file size / duration
#(400 MiB * 8192 [converts MiB to kBit]) / 7136 seconds(01:58:56) = 459 kBit/s total bitrate
#459 - 128 kBit/s (desired audio bitrate) = 331 kBit/s video bitrate

readonly inFile="input file.mp4"
readonly outFile="output file.mp4"
readonly scale="736:304"
readonly preset="veryslow"
readonly video_bitrate="350k"
readonly audio_bitrate="128k"

ffmpeg -y -i "${inFile}" -c:v libx264 -vf "scale=${scale}" -preset "${preset}" -b:v "${video_bitrate}" -pass 1 -an -f null /dev/null
ffmpeg -y -i "${inFile}" -c:v libx264 -vf "scale=${scale}" -preset "${preset}" -b:v "${video_bitrate}" -pass 2 -c:a aac -b:a "${audio_bitrate}" "${outFile}"
....

(source)

No comments: