szcf-weiya / techNotes

My notes about technology.
https://tech.hohoweiya.xyz/
11 stars 7 forks source link

ffmpeg #43

Open szcf-weiya opened 2 years ago

szcf-weiya commented 2 years ago

second way to speed up

https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

ffmpeg -i VID_20220623_183559.mp4 -map 0:v -c:v copy -bsf:v h264_mp4toannexb VID_20220623_183559_raw.h264
ffmpeg -fflags +genpts -r 120 -i VID_20220623_183559_raw.h264 -c:v copy VID_20220623_183559_r120.mp4

However, it might throw the following error,

not enough frames to estimate rate; consider increasing probesize

refer to https://stackoverflow.com/questions/57903639/why-getting-and-how-to-fix-the-warning-error-on-ffmpeg-not-enough-frames-to-es

try

ffmpeg -fflags +genpts -probesize 2G -r 120 -i VID_20220623_183559_raw.h264 -c:v copy VID_20220623_183559_r120.mp4

otherwise, it might behave like Peek 2022-07-07 21-57

but note that in this method, the size of the video would not decrease, i.e., no loss.

see also: https://zhuanlan.zhihu.com/p/142593316

szcf-weiya commented 1 year ago

add mosaic at a static position via crop and overlay

  1. create a snapshot and then open with geeqie, which can show the pixel coordinate of the cursor, determine the start position (left corner) and the width and height of the region to be blur
ffmpeg -i test.mp4 -filter_complex "[0:v]crop=210:20:47:233,avgblur=20[fg];[0:v][fg]overlay=47:233[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy -movflags +faststart test2.mp4

where

see also: https://superuser.com/questions/901099/ffmpeg-apply-blur-over-face

similarly, we add another mosaic region,

ffmpeg -i test2.mp4 -filter_complex "[0:v]crop=142:20:372:212,avgblur=20[fg];[0:v][fg]overlay=372:212[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy -movflags +faststart test3.mp4

since the right corner is empty, so crop them out

ffmpg -i test3.mp4 -filter:v "crop=680:630:1:1" -c:a copy test4.mp4

the resulting video is here

https://user-images.githubusercontent.com/13688320/196267281-a4e4780d-513a-4a47-9149-169e7aac2093.mp4