ffmpeg draw 3d object on image
ffmpeg examples
ffmpeg's documentation: ffmpeg.org/documentation.html
gluing video files together
inline, with different-sized video inputs:
ffmpeg -i IMG_3198.MOV -i IMG_3199.MOV -i IMG_3201.MOV -i IMG_3202.MOV -i IMG_3203.MOV -i title.mp4 -filter_complex "[0:0] [0:ane] [one:0] [1:1] [two:0] [2:ane] [3:0] [3:1] [4:0] [iv:one] [v:0] [v:1] concat=n=6:v=1:a=1:unsafe=one [v] [a]" -map "[v]" -map "[a]" -south 960x540 output.mp4
inline, with similar inputs:
ffmpeg -hide_banner -i "Wow-64 2015-01-19 22-08-49-73.avi" -i "Wow-64 2015-01-19 22-08-49-73.avi" -filter concat=north=two:v=1:a=1 -c:5 libx264 -crf 24 -preset ho-hum -b:a 96k turning_in_10_onyx_eggs.mp4
with a file:
ffmpeg -f concat -i filelist.txt output.webm
fixing "Unsafe filename": ffmpeg -safe 0 -f concat -i filelist.txt ...
; remember to use unmarried quotes in filelist.txt. concat demuxer documentation
video duration
finish encoding afterwards output elapsing reaches i minute: ffmpeg -i longvid.avi -t 00:01:00 "kickoff minute.mp4"
stop encoding afterwards reading 1 minute from input: ffmpeg -t 00:01:00 longvid.avi "first minute.mp4"
stop writing output once information technology is 4 minutes long: ffmpeg -i longvid.avi -t 04:00 out.avi
stop encoding after N frames take been output: ffmpeg -i vid.avi -frames:5 N out.mp4
seek past the first ~20.3 seconds of input: ffmpeg -ss 00:00:20.three -i infile.avi outfile.avi
send start 20.4 seconds processed to /dev/cypher: ffmpeg -i infile.avi -ss xx.4 outfile.avi
combining both: skip 11 seconds of input and stop reading input at position three:forty (=input elapsing is iii:29): ffmpeg -ss eleven -to iii:40 -i longvid.mp4 -c:5 libx264 -crf 20 out.mp4
and a modification: read and encode those 11 seconds in the beginning simply don't include them in the output (this avoids the input existence weird because office of information technology was cutting off): ffmpeg -to 3:40 -i longvid.mp4 -c:v libx264 -crf twenty -ss 11 out.mp4
video size
specifying resolution: ffmpeg -i large.avi -s 1280x720 out_small.webm
scaling while keeping aspect ratio: ffmpeg -i large.avi -vf "calibration=westward=-i:h=320" out_small.webm
(relevant doc section)
resolution as memnonics: ffmpeg -i large.avi -s hvga "480 by 320.mp4"
| relevant physician department | vga (640x480), hvga (480x320), qvga (320x240), cif (352x288), qcif (176x144), hd480 (852x480), hd720 (1280x720), hd1080 (1920x1080), qhd (960x540), nhd (640x360) pal (720x576), ntsc (720x480)
cropping: ffmpeg -i in.avi -filter:v "crop=out_w=702:out_h=540:x=129:y=0" out.avi
| relevant doc section
an example with everything: ffmpeg -i cbnxcn.mp4 -filter:five "crop=x=115:y=145:out_w=(in_w-405-115):out_h=(in_h-115-145), calibration=w=1280:h=720" -c:5 libx264 -crf 24 -preset deadening -c:a copy -t 15 -ss 2.3 ekjkbdko.mp4
add padding (in black) to the sides of the video so that the output is 1280x720, and eye the video in both directions: ffmpeg -i oddsize.mov -filter:5 "pad=w=1280:h=720:x=-ane:y=-1" -c:v libx264 -crf 23 -movflags +faststart youtube_ready.mp4
video quality
specifying bitrate: ffmpeg -i in.avi -b:5 500k out.avi
| documentation doesn't like this though
specifying quality, for h.264: ffmpeg -i in.avi -c:v libx264 -crf 23 out.mp4
| crf values of xviii-28 are considered "sane" | crf 0 is lossless, 23 default, 51 worst | relevant wiki link
generic quality options: ffmpeg -i in.avi -q:v Northward out.avi
| ffmpeg -i in.avi qscale:five North out.avi
| meaning of -q and -qscale is codec-dependent
drawtext
relevant dr. department | an instance where the video'due south timecode is burned in in seconds.frame format:
ffmpeg -i infile.avi -filter:v drawtext=" fix_bounds=ane: fontfile='//Estimator/Users/oatcookies/Desktop/DejaVuSansMono-Assuming.ttf': fontcolor=white: fontsize=24: bordercolor=black: borderw=one: textfile=burn-in.txt: x=1: y=main_h-line_h-1:" outfile.avi
where burn-in.txt
has the following contents: %{expr: (floor(n/thirty)) + (modern(north, xxx)/100)}
of grade, that specific expression applies to a 30 fps video. the odd fontfile path is considering ffmpeg doesn't exactly like windows' bulldoze letters: trying 'C\:\\Windows\\Fonts\\x.ttf' (with varying amounts of (back)slashes) ever resulted in an error.
a different fire-in.txt: %{expr_int_format: floor((due north/30)/threescore) : d : 2}:%{eif: mod(floor(n/30), sixty) :d:2}.%{eif: modernistic(due north, 30)+one :d:2}
| this shows the timecode in minutes:seconds.frames format.
time code for text-called-for filters
%{expr_int_format:floor((n/60)/threescore):d:ii}:%{eif:mod(floor(n/lx),60):d:2}
screen capture
from Windows
ffmpeg -f gdigrab -show_region one -framerate thirty -video_size 942x1003 -offset_x 8 -offset_y xxx -i desktop out.avi
With h264 pinch just non a lot of information technology:
ffmpeg -f gdigrab -show_region one -framerate 25 -video_size 800x600 -offset_x one -offset_y 30 -i desktop -c:v libx264 -crf eighteen -preset veryfast out.mp4
from linux
ffmpeg -f x11grab -framerate 25 -video_size 218x148 -i :0.0+0,95 -c:v libx264 -crf 21 -preset superfast screencast.mp4
sound
making louder: ffmpeg -hide_banner -i "serenity input.mp4" -af "book=40dB" -vcodec copy "louder output.mp4"
removing entirely: ffmpeg -i with_sound.mp4 -vcodec copy -an no_sound.mp4
sound quality: ffmpeg -i in.mp4 -b:a 64k out.mp4
example filelist.txt
file 'G:\ff\day1\2015-05-15 21-53-49-96.avi'
file 'Yard:\ff\day1\2015-05-xv 22-03-57-86.avi'
file 'Chiliad:\ff\day2\2015-05-16 22-08-42-72.avi'
perl script to generate a file list:
my $prefix = 'G:\\ff\\'; foreach my $subdir (("day1", "day2")) { my $dirname = "$prefix\\$subdir"; print("# $dirname\northward"); opendir(my $dirhandle, $dirname) || die "Can't opendir $dirname: $!\n"; open(my $outfile, '>', "$subdir.txt") || die "Tin't open up > $subdir.txt: $!\northward"; my $i = 1; while (readdir $dirhandle) { if ($_ =~ /*.avi$/ ) { print( $outfile "file '$dirname\\$_'\n"); $i++; } } closedir($dirhandle); shut($outfile); }
sed -E "s/(.*)/file '\one'/"
viewing file information
ffprobe infile.mp4
framerate dispatch
instance: input was recorded at 5 fps. output should be the same frames only at 25 fps, making the output video 5x faster.
ffmpeg -i input_5fps.mp4 -r 25 -filter setpts=PTS/v output_25fps.mp4
instance: a spider web rip had borders and a speedup to avoid algorims.
ffmpeg -i inrip.mp4 -r 30 -ar 44100 -filter:v "crop=out_w=640:out_h=360:10=345:y=235, setpts=PTS/0.ix" -filter:a "asetrate=39690" -c:v libx264 -crf 24 "output.mp4"
example: speeding upward a video 16-fold but keeping its framerate
ffmpeg -hide_banner -i 1x.mp4 -filter:v "setpts=PTS/16" -r 30 16x.mp4
speed-up past twenty× and scale down
ffmpeg -hide_banner -i $file -filter_complex "[0:v] setpts=PTS/20, scale=h=360:w=-ii, pad=due west=640:h=360:x=-ane:y=-1, minterpolate=fps=threescore:mi_mode=alloy [v]; [0:a] atempo=2, atempo=2, atempo=ii, atempo=ii, atempo=one.25 [a]" -map "[v]" -map "[a]" -c:five libx264 -crf 22 -preset veryfast -b:a 128k S/$file
one could also do atempo=20 instead of the two,ii,2,2,one.25 washed here; the doc on atempo says "note that tempo greater than two will skip some samples rather than alloy them in"; i didn't really hear a departure but i wanted to "alloy it in" anyway. too, i noticed that if this speedup is washed in two separate filters, with -filter:v
and -filter:a
, the encoding will kind of like hang on to the concluding frame and make the unabridged video as long every bit the input even tho it's speeded up in its entirety: information technology'll be the speeded upward video and and then cipher until the file is equally long as the input, actually weird. doing video and audio simultaneously in one filtergraph with -filter_complex
fixes this.
speedup video (which lacks audio) and add silent audio: ffmpeg -hide_banner -i $file -f lavfi -i anullsrc -filter_complex "[0:5] setpts=PTS/20, calibration=h=360:westward=-2, pad=west=640:h=360:x=-1:y=-1, minterpolate=fps=60:mi_mode=blend" -shortest -c:v libx264 -crf 22 -preset veryfast -b:a 128k Due south/$file
selective muting
ffmpeg -i copyright_trolled.mp4 -c:5 copy -filter:a "volume='ifnot(between(t,20834,20987),1)':eval=frame" part_muted.mp4
mp3 metadata
ffmpeg -i in.mp3 -c:a copy -metadata TSOT="sort by this cord" out.mp3
ffmpeg -hide_banner -i "424745724.mp3" -c:a copy -metadata Championship="The Title" -metadata ARTIST="Whoever" -metadata Date=2018 -metadata LYRICS="a windows command line cannot include a newline but a unix one can" -metadata TSOT="Title, The" forarchive.mp3
deshake
doc section
ffmpeg -hide_banner -i shaky.mp4 -filter:v "deshake" -c:v libx264 -crf 23 -c:a copy lessshaky.mp4
ffmpeg -hide_banner -i shaky -filter:v "deshake=edge=original:rx=32:ry=32:blocksize=iv" -c:v libx264 -crf 22 -c:a copy -t xv less_shaky.mp4
compare videos side-past-side
ffmpeg -hide_banner -i a.mp4 -i b.mp4 -filter_complex "[0:v]pad=iw*two:ih[int];[int][one:five]overlay=Due west/2:0[vid]" -map [vid] -c:v libx264 -crf 22 -map 0:a -c:a copy ab.mp4
palettize and export as gif
ffmpeg -i 2020-02-24.mkv -vf palettegen palette.png
y'all tin at present edit palette.png if y'all want to change information technology, reduce the number of colours and stuff (but keeping information technology as a 16×16 image)
ffmpeg -i 2020-02-24.mkv -i palette2.png -filter_complex "[0] ingather=w=1180:h=720:x=0:y=0,scale=472x288,crop=w=449:h=265:x=10:y=12 [x] ; [10] [1] paletteuse=dither=none:diff_mode=rectangle" -t 3 thing3sec.gif
generate test screen with text and a silent audio track
ffmpeg -f lavfi -i anullsrc -f lavfi -i "yuvtestsrc=rate=lx:size=1280x720,drawtext=text='lol ┐(´∀\` )┌':fontcolor=white:fontsize=48:bordercolor=black:borderw=3:ten=(w-text_w)/2:y=(h-text_h)/2" -c:v libx264 -crf 22 -b:a 256k -t v testfoo.mp4
generate just a test screen, play information technology back immediately
ffplay -f lavfi "yuvtestsrc"
or instead of yuvtestsrc
try testsrc
(which has a congenital-in seconds counter) or pal75bars
or rgbtestsrc
or smptehdbars
.
generate a mandelbrot fix, zooming in
ffplay -f lavfi "mandelbrot=size=1024x768:inner=convergence"
; doctor section
burn subtitles
ffmpeg -i video.mp4 -vf "subtitles='subs.srt'" (-c:a copy -c:5 libx264 etc...) video_sub.mp4
(filter documentation, ffmpeg wiki link)
youtube-dl
youtube-dl https://world wide web.youtube.com/watch?5=dQw4w9WgXcQ -f 137+140 -o "%(title)s.%(ext)south" --get-filename
-o "%(upload_date)s %(title)s %(id)s.%(ext)s"
turn an image file and an audio file into a video file
ffmpeg -loop 1 -i picture.png -i audio.mp3 -map 0:v -map 1:a -c:v libx264 -crf 24 -b:a 320k -r 30 video.mp4
This'll brand the video the resolution of the prototype, and at 30 frames per second (the -r thirty
function). For a different size video, use (for example) -s 1080x1080
after the -map 1:a
flag simply earlier -c:v
.
Note that this volition go on calculation soundless frames of the picture to the finish of the video until you quit the programme (by pressing q); it doesn't stop when the input audio stops. I haven't figured out how to stop when the audio stops, just you can get effectually this past first running ffprobe
on the sound, getting its exact length, and then adding (for example) -t 03:xiv.15
right before the output file proper name to brand the video exactly iii minutes and 14.15 seconds long.
originally created , last edited · alphabetize
Source: http://oatcookies.tx0.org/ffmpeg.html
0 Response to "ffmpeg draw 3d object on image"
Post a Comment