FFmpeg making video from images placed in different folders - ffmpeg

I am making video from images in FFmpeg. I want to know if I can make video from images placed in different folders. Like first image is placed in folder1 and other in folder2 can I use both images in folder1 and folder2 to make a single video having both images in any order. Just want to know can I use images from two different folders to make a single video. if yes. Than how can i do that?

Yes it's possible, you can specify several input on the command (-i) but the more easy in your case as the order doesn't count, is to use the 'concat' ' filter
https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20(join,%20merge)%20media%20files
it will create a video with all images of folder1 and after all folder2, etc...
The concat filter come with 2 methods:
ffmpeg -i concat:file1|file2 etc ....
and
ffmpeg -f concat -i list etc...
for image sequence it look like only the 2nd method work.
so first create a file to describe your content (run touch file and edit it with nano file) and use the following syntax to specify where your file are and which is their naming syntax:
file './folder1/im%03d.jpg'
file './folder2/im%03d.jpg'
save the file (under nano it will be with CTRL+X)
and now run the following command:
ffmpeg -f concat -i list out.mp4
ffmpeg will use your file as input and push sequentially all your image in the encoding process

Related

Find all video files in directory with FLAC audio codec

Is it possible to search a directory and output a text file listing every video file that has FLAC audio?
My television doesn't support FLAC so when I run into one I have been converting them with a FFMPEG script but it would be nice to be able to find them all in advance instead of waiting until I hit the problem while trying to play the files. I'm hoping there is a way that doesn't involve just opening every file in Mediainfo and checking manually.
Maybe there is a way to just output all of the Mediainfo information for a directory and then I can just find all FLAC occurrences in a csv sheet?
You can open all files in MediaInfo then export to CSV then open the CSV in a spreadsheet processor, or for a smaller output you can customize the output with the command line version of MediaInfo (see the download section on the MediaInfo website and download the CLI version) and a template file template.txt containing:
General;%CompleteName%,
Audio;%Format%
Audio_Middle;,
File_End;\n
and this command line:
mediainfo --Output=file://template.txt --ParseSpeed=0 YourDir > List.txt
List.txt will contain a CSV file with complete file name in first column, then audio format per track (2nd column has 1st audio format, 3rd column has 2nd audio format...)
--Output=file://template.txt selects the template file.
--ParseSpeed=0 reduces the parsing speed (no need of the extra info from a longer parsing).
YourDir is to be replaced by the directory name you want to scan.
> List.txt sends the output to a file.

Script to bulk merge audio and a video+audio file

I have a folder with 52 video+audio files (m3u8 extn)
and 52 audio files (different language)(m4a extn)
The names of the files are same
abcde.m3u8(video)
abcde.m4a(that other language audio only file)
i want to merge them so i have a single file Video+auido1+audio2
and i don't to lose any quality in the merging process
What would be the bash/ffmpeg command to do so?
Thanks a lot
Something like :
for f in *.m3u8
do
basename="${f%.*}"
ffmpeg -i "${basename}.m3u8" -i "${basename}.m4a" -c copy "${basename}.mkv"
done
Are you sure the m3u8 files contain actual video frames?

How to get FFmpeg to make an exact copy of a video?

I was playing around with FFmpeg, trying to embed a tag into an mp4 file and remove it later and get back to the original file, when I noticed that the files seemed to be different. Trying to isolate the issue, I tried to do a simple passthrough copy like so:
ffmpeg -i file1.mp4 -codec copy file2.mp4
The md5 sums of both files are different. Am I missing any options/flags to make an exact replica of file1?

Batch copy metadata from one file to another (EXIFTOOL)

Im currently using tags such as exiftool -FileModifyDate(<)datetimeoriginal, etc. in terminal/cmd...
Im switching from icloud and the dates in the metadata are exif (meaning finder and windows explorer just see the date they were downloaded)..
It's working but for any sloMo videos that are M4V, they dont change.. I have the originals which do have the right dates and was wondering if there is a way to match file names (123.mp4 = 123.m4v) and copy the metadata over... But I also want to do it in batches. (since every month I will be offloading my iphone every month or so) Thanks!
It will depend upon your directory structure, but your command should be something like this:
exiftool -TagsFromFile %d%f.mp4 "-FileModifyDate<datetimeoriginal" -ext m4v DIR
This assumes the m4v files are in the same directory as the mp4 files. If not, change the %d to the directory path to the mp4 files.
Breakdown:
-TagsFromFile: Instructs exiftool that it will be copying tags from one file to another.
%d%f.mp4: This is the source file for the copy. %d is a exiftool variable for the directory of the current m4v file being processed. %f is the filename of the current m4v file being processed, not including the extension. The thing to remember is that you are processing m4v files that are in DIR and this arguments tells exiftool how to find the source mp4 file for the tag copy. A common mistake is to think that exiftool is finding the source files (mp4 in this case) to copy to the target files (m4v) when exiftool is doing the reverse.
"-FileModifyDate<datetimeoriginal": The tag copy operation you want to do. Copies the DateTimeOriginal tag in the file to the system FileModifyDate.
-ext m4v: Process only m4v files.
Replace DIR with the filenames/directory paths you want to process. Add -r to recurse into sub-directories. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.

Is there an ffmpeg flag to not ask for overwrite but add a number at the end?

I have a script that converts ~8000 files to mp3. I have some files that have a sielar name, where just the extension is diffrent, and they would create all the same .mp3 file with my script at the moment.
So I just want ffmpeg to add something like (x) at the end of the name befor the extension and not ask me every few files.
Thank you!
The flag for overwrite without asking y/n is ( -y ), just include -y in your command.
(-y overwrites files of same name without asking).
Look at ffmpeg docs: https://ffmpeg.org/ffmpeg.html.
To find this flag just search for "overwrite" key word in the docs.
Example to extract an image from video and save it without asking y/n.
ffmpeg -i <video_file_here> -y -ss 00:00:00 -vframes 1 image.jpg)
Now to save file name with a new number each time you can make a bat file with a loop counter variable and increase the number and issue the command with the new number each time.
for a reference on how to do this, you can check one of my questions here. incrementing a counter variable inside a FORLOOP
FFmpeg does not have the functionality you describe.
You need to implement it in your script instead.
Or (on the FFmpeg command line) explicitly specify such output file name that is guaranteed not to exist.
For example, if all your input files are in the same directory, then for an input file named fname.ext use output file named fname.ext.mp3 and place it in a new directory.

Resources