I have read this question in toppic:
FFMPEG overlay two video and add text
ffmpeg -i raw_video.mp4 -i watermark.png -i watermark2.png -filter_complex [0:v]drawtext=fontfile=font.ttf:text='text1':fontcolor=black#1.0:fontsize=24:x=20:y=259, drawtext=fontfile=font.ttf:text='text2':fontcolor=black#1.0:fontsize=24:x=500:y=500[text]; [text][1:v]overlay=215:0[ol1];[ol1][2:v]overlay=400:300[filtered]"-map "[filtered]" -codec:v libx264 -codec:a copy output.mp4 "
I try to using this ffmpeg but it error .
Please help me
Your first command
Problem 1: The command has a trailing " resulting in an error:
[AVFilterGraph # 0x55f096873c40] No such filter: ''
Error initializing complex filters.
Invalid argument
Remove the trailing ".
Problem 2: Missing space
Change [filtered]"-map to [filtered]" -map.
Problem 3: Filtergraph not quoted
Enclose the filtergraph in quotes: "[0:v]drawtext...overlay=400:300[filtered]"
Your second command
Problem: Unlabeled filterchain is ignored
Change enable='between(t,0,20)';[v]drawtext to enable='between(t,0,20)',drawtext and read Filtering Introduction and Filtergraph description.
Related
I need to add the logo and telephone number on video, therefore I run the following command twice with different parameters:
ffmpeg -i input.mp4 -i ./assets/logo.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[wm][vid];[vid][wm]overlay=main_w-overlay_w-5:5" 'uploads/output.mp4' 2>&1
ffmpeg -i ./uploads/output.mp4 -i ./assets/telephone.png -filter_complex "[1][0]scale2ref=w='iw*9/10':h='ow/mdar'[wm][vid];[vid][wm]overlay=10:main_h-overlay_h-10" './uploads/output2.mp4'
I'm looking to optimize speed, maybe is possible to have a single file pass instead of 2?
Thank you very much!
I tried
ffmpeg -i input.mp4 -i ./assets/logo.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[wm][vid];[vid][wm]overlay=main_w-overlay_w-5:5" -i ./assets/telephone.png -filter_complex "[1][0]scale2ref=w='iw*9/10':h='ow/mdar'[wm][vid];[vid][wm]overlay=10:main_h-overlay_h-10" './uploads/output2.mp4'
but does not add the telephone number.
I found a way:
ffmpeg -i uploads/input.mp4 -i ./assets/logo.png -i ./assets/telefon.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[v1];[2][0]scale2ref=w='iw*9/10':h='ow/mdar'[v2];[0][v1]overlay=main_w-overlay_w-5:5[vid];[vid][v2]overlay=10:main_h-overlay_h-10" uploads/output.mp4
BUT
if input file type is an image
ffmpeg -i uploads/input.png -i ./assets/logo.png -i ./assets/telefon.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[v1];[2][0]scale2ref=w='iw*9/10':h='ow/mdar'[v2];[0][v1]overlay=main_w-overlay_w-5:5[vid];[vid][v2]overlay=10:main_h-overlay_h-10" uploads/output%d.png
without %d in the output file name I get this error:
[image2 # 0x55fff1a6af80] Could not get frame filename number 2 from pattern 'uploads/output.png'. Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %03d within the filename.
Error writing trailer of uploads/output.png: Invalid argument
Now I have 3 output files but a single file pass, could you please give me an ideea to have only one output image file?
I was able to add a watermark to 2 position(top left & bottom right) of a video with scaling image height to tenth of the video height in one command
ffmpeg -hide_banner -i /path/to/input.mp4 -i /path/to/watermark.jpg -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih/10[logo-out][video-out];[video-out][logo-out]overlay=10:10[flag];[1:v][flag]scale2ref=oh*mdar:ih/10[logo-out2][video-out2];[video-out2][logo-out2]overlay=W-w-10:H-h-10" -c:a copy /path/to/output.mp4
But the above command is too redundant, so I remove the second scale2ref
ffmpeg -hide_banner -i /path/to/input.mp4 -i /path/to/watermark.jpg -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih/10[logo-out][video-out];[video-out][logo-out]overlay=10:10[flag];[flag][logo-out]overlay=W-w-10:H-h-10" -c:a copy /path/to/output.mp4
But sadly, error occurs
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb195013c00] Invalid stream specifier: logo-out.
Last message repeated 1 times
Stream specifier 'logo-out' in filtergraph description [1:v][0:v]scale2ref=oh*mdar:ih/10[logo-out][video-out];[video-out][logo-out]overlay=10:10[flag];[flag][logo-out]overlay=W-w-10:H-h-10 matches no streams
I know error occurs because of the first overlay didn't set an image output specifier, but it seems we can't do this? I only know overlay can set a video stream specifier.
How can I use the [logo-out] specifier which output from scale2ref in the second overlay?
An output generated inside a filtergraph can only be consumed once. To reuse it, split it first.
ffmpeg -hide_banner -i /path/to/input.mp4 -i /path/to/watermark.jpg -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih/10[logo-out][video-out];[logo-out]split=2[logo-left][logo-right];[video-out][logo-left]overlay=10:10[flag];[flag][logo-right]overlay=W-w-10:H-h-10" -c:a copy /path/to/output.mp4
I am getting an error "Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_drawtext_3" for the below command, I don't know where it is going wrong. Can anyone help with this issue?
ffmpeg -i test.png -i test.mp4 -y -filter_complex [1:v]scale=1152:648[scale0];[scale0]rotate=0:c=black#0:ow=rotw(0):oh=roth(0)[rotate0];[0:v][rotate0]overlay=304.2:172.29;drawtext=fontfile=test.ttf:text=hi text:fontsize=40:fontcolor=white:x=426.05:y=852.04 -pix_fmt yuv420p est.mp4
ffmpeg -y -i test.png -i test.mp4 -filter_complex "[1:v]scale=1152:648,rotate=0:c=black#0:ow=rotw(0):oh=roth(0)[rotate0];[0:v][rotate0]overlay=304.2:172.29,drawtext=fontfile=test.ttf:text='hi text':fontsize=40:fontcolor=white:x=426.05:y=852.04,format=yuv420p" est.mp4
Join simple filters with a comma. This makes a filterchain.
Join filterchains or complex filters with a semicolon (;).
Wrap the filtergraph (the complete line of filters) in double quotes (") and the drawtext text in single quotes (').
I'm new to FFmepg so please forgive me if the terminology is wrong.
I would like to add text and audio to an existing video file. I'm chaining together 2 drawTexts, then in a different filter, I want to merge audio tracks of the original source video and some background music.
ffmpeg -i sourceNoText.mp4 -i backgroundMusic.mp3 -filter_complex "drawtext=enable='between(t,0,3.5)':fontfile=burbank.ttf:text='Your name - PETER':fontsize=90:x=(w-text_w)/2:y=(h-th-(h/10)-20):fontcolor='White', drawtext=enable='between(t,11.5,14.75)':fontfile=burbank.ttf:text='You couldn't have done it without Peter':fontcolor='White':fontsize=90:x=(w-text_w)/2:y=(h-th-(h/10)-20);[0:a][1:a]amerge,pan=stero:c0<c0+c2:c1<c1+c3[outMergedAudio]" -map 0:v -map "[outMergedAudio]" -c:a aac edited.mp4
My understanding is filters are separated by a semicolon, yet when I try to do the audio merging, that portion of the command is being interpreted in the drawtext filter.
[drawtext # 0000020fe395bec0] Cannot find color 'c0<c0+c2'
[drawtext # 0000020fe395bec0] Unable to parse option value "c0<c0+c2" as color
[drawtext # 0000020fe395bec0] Cannot find color 'c0<c0+c2'
[drawtext # 0000020fe395bec0] Unable to parse option value "c0<c0+c2" as color
[drawtext # 0000020fe395bec0] Error setting option fontcolor to value c0<c0+c2.
[Parsed_drawtext_1 # 0000020fe395ad00] Error applying options to the filter.
[AVFilterGraph # 0000020fe3892e00] Error initializing filter 'drawtext' with args 'enable=between(t,11.5,14.75):fontfile=burbank.ttf:text=You couldnt have done it without Peter:fontcolor=White:fontsize=90:x=(w-text_w)/2:y=(h-th-(h/10)-20);[0:a][1:a]amerge,pan=stero:c0<c0+c2:c1<c1+c3[outMergedAudio]'
Error initializing complex filters.
Running without the audio filter works well, so I don't believe there to be a syntax error. What am I missing? Specifying an input and output stream for the drawText chain still produces the same problem.
I'm using ffmpeg version 4.2.1.
Thanks in advance.
Because you have a single quote in the text string of your 2nd drawtext, enclosed in single quotes, that's throwing off some parser state. Enclose the text in escaped double quotes and escape the single quote within.
Additionally, the pan syntax is deprecated.
ffmpeg -i sourceNoText.mp4 -i backgroundMusic.mp3 -filter_complex "drawtext=enable='between(t,0,3.5)':fontfile=burbank.ttf:text='Your name - PETER':fontsize=90:x=(w-text_w)/2:y=(h-th-(h/10)-20):fontcolor='White', drawtext=enable='between(t,11.5,14.75)':fontfile=burbank.ttf:text=\"You couldn\'t have done it without Peter\":fontcolor='White':fontsize=90:x=(w-text_w)/2:y=(h-th-(h/10)-20);[0:a][1:a]amerge,pan=stereo|c0<c0+c2|c1<c1+c3[outMergedAudio]" -map 0:v -map "[outMergedAudio]" -c:a aac edited.mp4
I would like to convert 16 bits grayscale images in an HEVC/mkv video with the x265 encoder without loss, using ffmpeg. I use the monochrome12 profile. My first step is to convert images into yuv format:
ffmpeg -f image2 -i "C:\DATA FOLDER\images%d.png" video.yuv
And I try to convert it as a .mkv file, losslessly:
ffmpeg video.yuv video.mkv -c:v libx265 -x265-params "profile=monochrome12:crf=0:lossless=1:preset=veryslow:qp=0"
But I get
Unrecognized option '-lossless'
Error splitting the argument list : Option not found
When I don't write lossless=1 everything's right, but I don't manage to have a lossless video by this way.
thank you for your help.
It works for me if I make a few changes:
ffmpeg -i video.avi -c:v libx265 \
-x265-params "profile=monochrome12:crf=0:lossless=1:preset=veryslow:qp=0" \
video.mkv
This is like the command you've provided, except I'm using a different input format, and prepend -i to mark it as an input file.
I also put the output filename at the end, after the output options, otherwise they are not applied, and I get this warning among the output:
Trailing options were found on the commandline.
I don't think the command you gave would cause the error you get though.
libx265 will not give an error on params it doesn't recognise, but show a warning like:
[libx265 # 0x563e4520e740] Unknown option: lessloss.
I can reproduce your exact error by trying to add --lossless as a parameter to ffmpeg:
ffmpeg --lossless -i video.avi video.mkv
Unrecognized option '-lossless'.
Error splitting the argument list: Option not found