I would like to add black stroke to text in ffmpeg. Is it possible?
-c:v libx264 -vf "hue=h=0, drawtext=fontfile=../bin/RobotoCondensed-Bold.ttf:text='Hello.':fontcolor=white: fontsize=158: x=0+(w-text_w)/2: y=50+(h-text_h-line_h)/2" -c:a copy -shortest -pix_fmt yuv420p ../bin/ENG_01.mov
You can change border-color and width of border by using drawtext and adding these parameters
bordercolor=black:
borderw=5:
Your code will look
-c:v libx264 \
-vf "hue=h=0,\
drawtext=fontfile=../bin/RobotoCondensed-Bold.ttf:\
text='Hello.':\
bordercolor=white:\
borderw=5:\
fontcolor=white:\
fontsize=158:\
x=0+(w-text_w)/2: y=50+(h-text_h-line_h)/2"\
-c:a copy -shortest -pix_fmt yuv420p \
../bin/ENG_01.mov
It's easier to use the subtitles filter instead of drawtext to add a full stroke.
subtitles filter
ffmpeg will apply the Outline and OutlineColour options set in ASS files. Or you can manually set these in the ffmpeg command which is useful for other subtitle formats that don't support a stroke:
ffmpeg -i input -filter_complex "subtitles=your_subtitles_file.srt:force_style='Outline=5,OutlineColour=&H000000&'" output
From Advanced Substation Alpha Tags:
The color codes are given in hexadecimal in Blue Green Red order. Note
that this is the opposite order of HTML color codes. Color codes must
always start with &H and end with &. Default OutlineColour is
black (&H000000&).
drawtext filter
Use the borderw and bordercolor options:
ffmpeg -i input -filter_complex "drawtext=text='drawtext stroke':fontsize=36:fontcolor=white:borderw=4:bordercolor=black:x=(w-text_w)/2:y=(h-text_h)/2" output
bordercolor can accept hexadecimal values and you can also change the stroke opacity, such as with bordercolor=#ffcc00#0.5.
See the drawtext filter documentation for more info.
Related
At the moment I can convert image sequence to video. But the current requirement is to convert one image into a video. And can achieve some special effects.
For example:
fade in/out
flash in/out
pan top/bottom/left/right
zoom in/out
zoomin example:
ffmpeg -i infile -filter_complex "scale=iw*10:-1,zoompan=z='zoom+0.01':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':s={output_width}x{output_height}" -t {duration} -y -shortest -c:v libx264 outfile
I'm trying to correctly map and centrally-orient a single showwaves (or showfreqs) overlay against two symmetrically-scrolling showspectrum overlays with ffmpeg, e.g.
ffmpeg -i input.mp3 -filter_complex "[0:a]showspectrum=color=fiery:saturation=1:slide=scroll:scale=log:win_func=gauss:overlap=1:s=960x1080,pad=1920:1080[vs]; [0:a]showspectrum=color=fiery:saturation=2:slide=rscroll:scale=log:win_func=gauss:overlap=1:s=960x1080[ss]; [0:a]showwaves=s=960x540:mode=p2p[sw]; [vs][ss]overlay=w[out]; [out][sw]overlay=w[out]" -map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy output.mkv
As shown in the screen capture above, the showwaves overlay is stubbornly fixed in the upper right quadrant. The intent is to have it display horizontally across the center.
Bonus points if you can help me thicken the lines drawn by the showwaves filter.
Use
ffmpeg -i input.mp3 -filter_complex "[0:a]showspectrum=color=fiery:saturation=1:slide=scroll:scale=log:win_func=gauss:overlap=1:s=960x1080,pad=1920:1080[vs]; [0:a]showspectrum=color=fiery:saturation=2:slide=rscroll:scale=log:win_func=gauss:overlap=1:s=960x1080[ss]; [0:a]showwaves=s=1920x540:mode=p2p,inflate[sw]; [vs][ss]overlay=w[out]; [out][sw]overlay=0:(H-h)/2[out]" -map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy output.mkv
Co-ordinates set for the overlay of showwaves. showwaves size also changed to span full width. Added inflate filter to simulate "thickness" but in terms of quality, YMMV.
I'm trying to utilize ffmpeg as a video editor and this is mostly due to that the regular video editor dropped more frames than I was comfortable with.
ffmpeg -i "videoplayback1" -t 00:09:51 -i "audioplayback1" -t 00:09:54.38 -vcodec libx264 -crf 20 -acodec copy "playback1.mp4"
As you can see, I'm trimming the video shorter than the audio, but what I want is something that is the opposite of the -shortest command switch, to have the file continue for the duration of the audio -t, and adding physical black frames for the remainder of that time.
As it is now, the video is still clipped as if I was using the -shortest switch. I tried some -vf and filter_complex but either I get errors, or that the audio is still chopped, the video frozen, but the duration is that of the longest -t.
How would I go about adding black frames for as long as the audio is playing?
Your command is malformed in that it's not trimming the video shorter than the audio. Option placement matters. Input options for an input go before that input, so
ffmpeg -t 00:09:51 -i "videoplayback1" -t 00:09:54.38 -i "audioplayback1" -vcodec libx264 ...
For your editing requirement, I would drop the video trim and use the drawbox filter to blacken the frame after the desired video trim point.
ffmpeg -i "videoplayback1" -t 00:09:54.38 -i "audioplayback1" -vf drawbox=t=fill:enable='gt(t,591)' -shortest -c:v libx264 -crf 20 -c:a copy "playback1.mp4"
drawboxis set to draw over the whole frame with the default color of black after 591 seconds of video. -shortest terminates the output.
I have a series of BMPs (or PNG) images that I want to convert to XVID and MP5 movie formats.
Encoding works but the resulting movie has a washed out color look to it and the blacks are somehow moved to RGB 16 and the brightest 255 values are moved down to 235. I want the output movie to use the same 0 to 255 colors as the source frames.
Now there are all sorts of conflicting doco out there for FFMPEG so I am hopinbg someone has an example command line that does what I need. I have tried all sorts of pix_fmt flags but none of them get the output movie in the full color range.
For XVID
ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -c:v mpeg4 -vtag xvid -qscale 1 -y "D:\OUTPUT.AVI""
For H265
ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -c:v libx265 -x265-params lossless=1 -s 3840x2160 -pix_fmt yuvj420p -an -y "D:\OUTPUT.MP4""
The yuvj420p is supposed to give the full color range but ffmpeg complains "Incompatible pixel format 'yuvj420p' for codec 'libx265', auto-selecting format 'yuv420p'"
So, are there any FFMPEG gurus out there that can give me the magic switches to get my output movies with black blacks and colors that maintain the original frame files 0-255 RGB values.
The output range can be forced, as can the color range metadata, but your player or editor may force a limited range interpretation, So, caveat transcoder.
With that said, you have to set two flags: first one for the scaler, and then for the metadata.
ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -vf format=yuv420p -dst_range 1 -color_range 2 -c:v mpeg4 -vtag xvid -qscale 1 -y "D:\OUTPUT.AVI""
(since you're using mpeg4 encoder, this is not Xvid, which would be -c:v libxvid; you need to have this lib linked in order to to use it.)
For x265, range can be set using an encoder flag.
ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -c:v libx265 -x265-params lossless=1:range=full -s 3840x2160 -dst_range 1 -pix_fmt yuv420p -an -y "D:\OUTPUT.MP4""
I have a video which hasn't 1920x1080 so I need to make it.
I try to use next command:
ffmpeg -i "video.avi" -filter_complex "nullsrc=size=1920x1080 [0:v]; [0:v] overlay=shortest=1:x=200:y=100" -r 30 -c:v libx264 -preset fast -crf 18 -profile:v high -bf 2 -flags +cgop -coder 1 -pix_fmt yuv420p -strict -2 -c:a aac -b:a 384k "video.mp4"
But I got a green frame over the video like this - http://i.imgur.com/QNVUGb5.jpg
I dont find a solution to make a green in any other color.
How possible to make green frame to black frame?
Thanks.
Use the pad filter instead
It is simpler to just use the pad filter to add the frame:
ffmpeg -i input -filter_complex "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output
Not as efficient alternatives
Alternatively, if you want to use the overlay filter to add padding then you can use the color source filter instead of nullsrc:
ffmpeg -f lavfi -i color=s=1920x1080:c=black -i video.mp4 -filter_complex "[0][1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1" output.mp4
If you still want to use nullsrc then refer to the chromakey filter, but this is inefficient and not a recommend method.