ffmpeg -pattern_type glob not working in Google Colab - ffmpeg

I'm trying to combine images into video using ffmpeg in a Google Colab Notebook; I'm getting errors but don't see what I'm doing wrong.
!ffmpeg -pattern_type glob -i 2023021522* -c:v libx264 video2.mp4
returns: Option pattern_type not found.
!ffmpeg -pattern_type glob -i '2023021522*' -c:v libx264 video2.mp4 or
!ffmpeg -pattern_type glob -i "2023021522*" -c:v libx264 video2.mp4
return: 2023021522*: No such file or directory
I also tried adding from glob import glob and just import glob

-pattern_type glob is not required! Simply omit.

Related

Evaluate function within ffmpeg drawtext

I am looking to display a counter that is a multiple of the frame number on a video created with ffmpeg. Previous answers on SO taught me that a command of the form
ffmpeg -y -r 25 -pattern_type glob -i '*.jpg' -vf "text='%{n}': start_number=0: x=0: y=0: fontcolor=black: fontsize=30: box=1: boxcolor=white: boxborderw=5" -c:a copy movie.mp4
Will display the frame number, and this works nicely. But if I try to evaluate an expression within the %{}, e.g.
ffmpeg -y -r 25 -pattern_type glob -i '*.jpg' -vf "text='%{n*50}': start_number=0: x=0: y=0: fontcolor=black: fontsize=30: box=1: boxcolor=white: boxborderw=5" -c:a copy movie.mp4
Then I get the following error
[Parsed_drawtext_0 # 0x55683f9b00] %{n*50} is not known
on each frame. What is the proper syntax to evaluate n*50 and display in drawtext? TIA.
It's missing the e function specifier. Try
ffmpeg -y -r 25 -pattern_type glob -i '*.jpg' \
-vf "drawtext=text='%{e\:n*50}': start_number=0: x=0: y=0: fontcolor=black: fontsize=30: box=1: boxcolor=white: boxborderw=5" \
-c:a copy movie.mp4

Convert PNG sequence to MP4 from directory

On a mac I would normally convert a folder of pngs to mp4 using the following:
ffmpeg -framerate 25 -i -pattern_type glob -i "*" -c:v libx264 -pix_fmt yuv420p -b:v 10M output.mp4
Now I'm trying to accomplish the same using windows 10, but globbing is not supported.
Not knowing what the filenames might be, is there a decent way of getting a complete file list of the directory and implementing it with ffmpeg?
Have u tried the % operator ?
ffmpeg -r 30 -i %.png -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4

How do I join multiple glob inputs into a time lapse with ffmpeg?

I'm trying to combine image files from multiple directories into one combined time lapse using ffmpeg, but when running this code, only the first directory is used in the time lapse. How do I combine multiple glob inputs using ffmpeg?
ffmpeg -pattern_type glob -i "Time\ Lapse\ 11/*.JPG" \
-pattern_type glob -i "Burst\ Sequence\ 5/*.JPG" \
-pattern_type glob -i "Burst\ Sequence\ 6/*.JPG" \
-r 30 -c:v libx264 -crf 23 -preset fast -pix_fmt yuv420p tl11_combined.mp4
I've tried using glob sequence which didn't do anything, and I've tried various concat methods using a text file including directory names, but haven't found the correct format so far. Thanks!

FFMPEG multiple file pattern not working in single command

I want to add multiple file sequences in single ffmpeg command, below is my code, video is getting created but only first image sequence is getting used, second is getting ignored
ffmpeg -y -i input.mp4 -start_number 0000001 -i 1/%07d.png -i 2/%07d.png -filter_complex "[0][1]overlay=x=10:y=10:enable='between(t,0,3)'[v1];[v1][2]overlay=x=10:y=10:enable='between(t,3.8561422222222,6.9761777777778)'[v2]" -map "[v2]" -map 0:a out.mp4
Now the problem is FFMPEG wants continous images, which i don't have i have images starting from 0000001.png in each folder, how can i accomplish this without changing much in my images
Try the glob pattern to deal with inconsistent numbering and pad the PTS with setpts so the overlay doesn't get consumed before it is displayed:
ffmpeg -y -i input.mp4 -pattern_type glob -i "1/*.png" -pattern_type glob -i "2/*.png" -filter_complex "[0][1]overlay=x=10:y=10:enable='between(t,0,3)'[v1];[2]setpts=PTS+3.856/TB[fg];[v1][fg]overlay=x=10:y=10:enable='between(t,3.8561422222222,6.9761777777778)'[v2]" -map "[v2]" -map 0:a out.mp4
Can you pipe the images to -f image2pipe ?
cat $(find 1 2 -name '*.png' -print) | ffmpeg -y -i input.mp4 \
-f image2pipe -vcodec png -i - \
-filter_complex "[0][1]overlay=x=10:y=10:enable='between(t,0,3)'[v1];[v1][2]overlay=x=10:y=10:enable='between(t,3.8561422222222,6.9761777777778)'[v2]" \
-map "[v2]" -map 0:a out.mp4

ffmpeg with "-pattern_type glob" and variable in bash script

I'm trying to let ffmpeg make a video of all pictures in a directory using the -pattern_type glob switch and "/foo/bar/*.jpg". This works well, if I execute the command manually für just one directory. For example:
ffmpeg -framerate 35 -pattern_type glob -i '/root/webcam_test/2018-07-21/*.jpg' -vf scale=1280:-1 -c -c:v libx264 -pix_fmt yuv420p /root/clips/out01_cut.mp4
However, if I do it in a bash script and set the path via a variable, according to ffmpegs output, the variable gets substituted correctly, but ffmpeg states that
'/root/webcam_test/2018-07-21/*.jpg': No such file or directory
The part of the script looks like this:
for D in `find /root/webcam_test/ -type d`
do
[...]
cmd="ffmpeg -framerate 35 -pattern_type glob -i '$D/*.jpg' -vf scale=1280:-1 -c -c:v libx264 -pix_fm t yuv420p /root/clips/$d_cut.mp4"
echo $cmd
[...]
done
Does anyone know how to make ffmpeg do its wildcard interpretation even if the path is constructed by a script and not just try to plainly use the given path?
Best regards and thanks in advance
I had similar problem. My solution is to change directory before ffmpeg command and use pattern without directory. i.e.:
cd $D/;ffmpeg -framerate 35 -pattern_type glob -i "*.jpg" -vf scale=1280:-1 -c -c:v libx264 -pix_fmt yuv420p /root/clips/$D_cut.mp4
By putting the bash variable inside single quotes, it does not get expanded. Try with double quotes:
ffmpeg -framerate 35 -pattern_type glob -i "$D/*.jpg" -vf scale=1280:-1 -c -c:v libx264 -pix_fmt yuv420p /root/clips/$D_cut.mp4
Either of these, quoted or not, work in my timelapse cron script:
$ ls -1 *.jpg
20190620_011712sm.jpg
$ TODAY=$(date +"%Y%m%d")
$ ffmpeg -y -v 24 -f image2 -pattern_type glob -i ${TODAY}_\*sm.jpg -r 12 -vcodec libx264 ${TODAY}.mp4 2>&1|col -b
$ ffmpeg -y -v 24 -f image2 -pattern_type glob -i "${TODAY}_*sm.jpg" -r 12 -vcodec libx264 ${TODAY}.mp4 2>&1|col -b
I don't know why, but I fought hard to use single quotes around the * char before I came upon this. ...Lack of sleep maybe?

Resources