ffmpeg only drawing last text - ffmpeg

Im using ffmpeg in flutter using the flutter ffmpeg plugin. While experimenting with it this is what I am trying to do: Show text between 1 to 2 seconds and a different text between 3 to 4 seconds in video.
Only the text mentioned between 3 to 4 seconds is shown. So for me only the last drawText would work. What am I missing here?
The is the list of arguments generated
Running FFmpeg with arguments: [-y, -i, /storage/emulated/0/DCIM/Camera/20200707_234610.mp4, -i, /data/user/0/com.example.example/app_flutter/watermark.png, -filter_complex, [0:v][1:v]overlay=main_w-overlay_w-5:5 ,drawtext=fontfile='/data/user/0/com.example.example/app_flutter/font.ttf':fontsize=90:x=20:y=20:text='Testing':enable='between(t\,1\,2),drawtext=fontfile='/data/user/0/com.example.example/app_flutter/font.ttf':fontsize=90:x=20:y=260:text='OTHER TEXT':enable='between(t\,3\,4)'', -crf, 27, -preset, veryfast, -c:v, libx264, -r, 30, /data/user/0/com.example.example/cache/2020-07-21T07:50:39.206386.mp4]

You're missing a single quote ('):
Change 'between(t\,1\,2),drawtext to 'between(t\,1\,2)',drawtext.
You also have an extra ' at the end of your filtergraph, but it was not the cause of the problem:
Change 'between(t\,3\,4)'', -crf to 'between(t\,3\,4)', -crf.
Fixed command:
-y, -i, /storage/emulated/0/DCIM/Camera/20200707_234610.mp4, -i, /data/user/0/com.example.example/app_flutter/watermark.png, -filter_complex, [0:v][1:v]overlay=main_w-overlay_w-5:5,drawtext=fontfile='/data/user/0/com.example.example/app_flutter/font.ttf':fontsize=90:x=20:y=20:text='Testing':enable='between(t\,1\,2)',drawtext=fontfile='/data/user/0/com.example.example/app_flutter/font.ttf':fontsize=90:x=20:y=260:text='OTHER TEXT':enable='between(t\,3\,4)', -crf, 27, -preset, veryfast, -c:v, libx264, -r, 30, /data/user/0/com.example.example/cache/2020-07-21T07:50:39.206386.mp4

As llogan said, you were missing a single quote (')... but it also showed up later.
Change both 'between(t\,1\,2),drawtext to 'between(t\,1\,2)',drawtext AND
'between(t\,3\,4)'' to 'between(t\,3\,4)'.

Related

FFMPEG - Strange issue with video copy

I'm new here.
I have a set of TIF frames that equal 1 minute and 25 seconds of a video.
I'm attempting to copy the frames without re-encoding using the "-c:v copy" function to avoid visible quality loss for a process I'm doing on my side. The command is as follows:
ffmpeg -r 23.977 -i %06d.tif -c:v copy out.mkv
However for some reason, the timing does not seem to be accurate and the video is slightly desynced from the original, ending at 1 minute and 22 seconds instead.
When I use the following command:
ffmpeg -r 23.977 -i %06d.tif out.mkv
It comes out with the proper timing at 1 minute and 25 seconds, however, I did not appreciate the quality loss that came with it.
Is there a workaround to this or is there something I'm missing?
I used both Command Line and Windows Terminal.
In general, it would make sense to transcode when you go from tiff to video format. (I'm surprised it actually works.) You can set encoding quality to your own liking. See [this FFmpeg Wiki article[(https://trac.ffmpeg.org/wiki/Encode/H.264).

Using FFMPEG I get an error when trying to insert a fade after about 35 mins in a long video - is this possible?

I have a source video that is an hour long from which I want to extract a couple of minutes towards the end and add a video fade in at the start of the cropped section.
Using FFMPEG, I'm specifying the following command:
ffmpeg -i MyLongVideo.mp4 -q:v 0 -y -ss 00:50:00.000 -to 00:52:00.000 -vf "fade=t=in:st=3000.0:d=1.0, scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2" ./testoutput.ts
This is intended to crop from the source video from 50:00.000 to 52:00.00 and fade in from the 50th minute for 0.5 seconds (so at 3000 seconds in - st=3000.0).
This command that we build programmatically, works on shorter videos or when you crop from before about 35 minutes. For this longer video though I get an error that says:
[fade # 0000025399981e80] Value 3000.000000 for parameter 'st' out of range [0 - 2147.48]
The 2147.48 is around the 35 minutes in seconds which explains why this command works for shorter videos or on crops earlier than 35 minutes.
I've seen a number of other issues with FFMPEG talking about this 'magic' 2147.48 number with parameter values. Is this some sort of hard limit?
Is there a way to do what I want to do? I could do this in two passes - extract the section of video and then add the fade, but I'd rather do it in one command if possible - and it works for shorter/earlier crops.
Get a ffmpeg build from after Nov 12 2018 or before Oct 7 2018. There was a regression in the builds in between.

How to use codec type properly in NPM

Trying to use '-acodec libopus' in my npm project as I use in the command line like in the following format;
ffmpeg -acodec libopus -i 1.webm 1.wav
This works perfectly! But I would like to make it possible in my NPM project.
How can I set the parameters?
This is what I have , but not working. The output file is broken in a way that some of the frames of the audio file are missing. It is like there is sound and then there is not. And vice versa.
var proc = new ffmpeg({
source: file,
nolog: false
});
format = "opus"; // or could be wav as well!
proc.addOptions([
'-f ' + format,
'-acodec libopus',
'-vn'
]);
The purpose is to take audio file from the video file seamlessly.
Without the codec libopus, I get the following errors in the command prompt, so I assume I should handle the same issue in my NPM project as well.
[opus # 00000000006d4520] LBRR frames is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[opus # 00000000006d4520] Error decoding a SILK frame.
[opus # 00000000006d4520] Error decoding an Opus frame.
My library is up to date, I just need to use the codec libopus properly.
Any suggestions?
\node-js>ffmpeg -version
ffmpeg version N-86175-g64ea4d1 Copyright (c) 2000-2017 the FFmpeg
developers
built with gcc 6.3.0 (GCC)
Output in command line;
xtranscribe transcodeWatson: file : ./data/that/2.webm
progress 62.625273103421605%
progress 100.01224534515762%
SAVED - transcodeWatson : .mp3
out of transcode!
fileSizeInBytes : 16284033
According to the README, you can add input options to the process:
proc.addInputOption('-acodec libopus');
It matters where you place an option in ffmpeg. If you put it before -i, it applies to that particular input. If you put it before an output file name, it applies to that output.

ffmpeg - automatically chopped?

I have an ISO file that I would like to encode it out to mp4 in parts so it's easier to upload to youtube. I am not sure how it handles with chapters etc in this iso file. I have tried
ffmpeg -i file.iso newfile.mp4
which works great however it's one large file.
I have google and read some where that says if you put a % within the output file, it should automatically give you parts of the video based on the -t you set, so I went ahead and did this
ffmpeg -i file.iso -t 30 newfile%.mp4
however, the above does not work as it only give me 30 seconds with the file name: newfile%.mp4
Thanks for your time and hoping I can get some help with this. Thank you in advance!
You can use -t and -ss in conjunction to do this with a script.
Here is one: http://grapsus.net/blog/post/A-script-for-splitting-videos-using-ffmpeg

ffmpeg: how to add pixellate effect?

I need to blur some uploaded videos and encoded them.
Infact by blur, it means pixellate them so "big squares" appear and blur it.
Any idea on how I can do that ? (ffmpeg would be great, by any command line windows tool should be ok)
Thanks.
FFmpeg can support the frei0r filters which includes pixeliz0r
Example:
ffmpeg -i input -vf "frei0r=filter_name=pixeliz0r:filter_params=0.02|0.02" output
The two pixeliz0r filter_params parameters are:
BlockSizeX: horizontal size of one "pixel"
BlockSizeY: vertical size of one "pixel"
Larger values will create larger blocks.
Where to get ffmpeg with frei0r support
Windows users can get the "full build" from gyan.dev.
Linux users can download or compile:
Download ffmpeg with frei0r support at johnvansickle.com.
Or compile ffmpeg by installing whatever package provides frei0r.h (such as frei0r-plugins-dev in Ubuntu or frei0r-devel in CentOS) and then add --enable-frei0r to your ffmpeg configure. See FFmpeg Wiki: Compile Guides.
macOS users can use Homebrew. You may need the --with-frei0r option.
More info
frei0r homepage
FFmpeg frei0r filter documentation
If you don't want to install the frei0r plugin for this, there's an alternative way.
dimensions=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of "csv=p=0:s=\:" input)
ffmpeg -i input -filter_complex \
"[0:v] scale='iw/15:-1', scale='$dimensions:flags=neighbor'" output
This scales down the input size (in this example, by 15) and then scales it back up to the original dimensions. The flags=neighbor tells ffmpeg to use the nearest neighbor rescaling algorithm which results in the pixelated effect. You can change the block size by changing the number 15.
The first line is needed to find out the input's original dimensions and scale back directly to it, otherwise the scaling down and scaling up might result in rounding errors that slightly alter the size of the output.

Resources