Creating Batch Spectrograms Using FFMPEG? - audio

So I am wanting to create spectrograms using the FFMPEG for thousands of FLAC files in batch.
I am using the following for just one file.
ffmpeg -i audio-in.wav -lavfi showspectrumpic image-out.png
However, I would like to do this for all the files in a certain folder (\Desktop\FLACfiles) and don't want to keep changing the file name and the image output name.
I would like to somehow create a batch script in Windows 10 that automatically creates a spectrogram based on the filename.
I was trying to make it work but I don't have much experience via command line or programming in general. Not sure how to do achieve this.
Simply put, would like to use commands from a working directory containing FLAC files and create a spectrogram for each file matching the filename.

This worked for me using mp3 files but it wasn't fast. Someone may have a better solution. Try this as a bat file.
for %%a in ("*.mp3") do ffmpeg -i "%%a" -lavfi showspectrumpic "%%~na .png"

Related

Linux - delete some parts from video (mp4)

How can I remove several parts from video in command line? Or how can I select some intervals from video and create file from them?
I tried to convert video to mpg (mpg file was ok) and then use something like that:
mpgtx -j input.mpg [0:10-0:20] [0:42-0:52] [1:23-1:33] -o output.mpg
But result file was incorrect.
Thanks for answers!

How can I create a file in Linux in a way that when I open it, it is actually running a process

I have a set of .sph files which are actually audio .wav files plus some header.
I have a program called sph2pipe which converts these .sph files to normal audio .wav files.
I want to create some kind of symbolic link to these .sph files that when I read these links I would be actually reading the converted version of them.
Something like this:
ln -s "sph2pipe a.sph |" "a.wav"
ln -s "sph2pipe b.sph |" "b.wav"
So this way, I don't have to convert all audio files to .wav files and instead I just create links to .sph files and I want them to get converted on the fly.
I hope I made myself clear. I was thinking what I am looking for is a Named pipe (https://en.wikipedia.org/wiki/Named_pipe) but this would not be useful in my case since I need to read the .wav files several times.
EDIT-1: I don't have to use named pipes. I just thought this could be the solution.
Actually, in my case, these .wav files are needed to be read several times.
EDIT-2: I was wondering how Samba (or gvfs-smb) works. So the files are in the network but there is also a path available for them in my system like: /run/user/1000/gvfs/smb-share:server=10.100.98.54,share=db/4a0a010a.sph. Can I do something like this? (I read .sph files from a specific path and .wav files come out :) )
EDIT-3: I came up with this so far:
keep_running.py:
#!/usr/bin/python3
import subprocess
cmd = 'mkfifo 4a0a010a.wav'
subprocess.call(cmd, shell=True)
cmd = 'sph2pipe -f wav 4a0a010a.wv1 > 4a0a010a.wav'
while True:
subprocess.call(cmd, shell=True)
And in shell:
./keep_running.py &
play 4a0a010a.wav
play 4a0a010a.wav
play 4a0a010a.wav
I can use the audio file as many times as I want.
What do you think would be the limitations of this implementation?
Would I be limited by the number of the processes that I can spawn? Because it looks like I need to spawn a process for each file.
Don't do it, it's a bad idea.
If you insist anyway, perhaps just out of curiosity, here's a proof of concept.
mkfifo a.wav
sph2pipe a.sph >a.wav &
Now, the results are available once in a.wav but once you have consumed them, they are gone, and a new instance of the background process has to be started if you need to do it again.
Sounds to me like a simple Makefile would serve your use case better (create missing files, recreate files which need to be updated, potentially remove temporary targets when the main target has successfully been made).
No, a named pipe, or fifo(7), wants some existing process to write it (and another to read it). There is no magic that will start the writing process when some other process opens that fifo for reading.
You could provide your FUSE filesystem (whose actions would produce the sound data). I am not sure that it worth the effort in your case.
Remember that several processes can read or write the same file at once.
EDITED ANSWER
Or, if you don't have more than a couple of 1000 files, you can spawn a process for each fifo that keeps sending the file to it repeatedly like this:
for f in *.sph; do
mkfifo "${f}.wav"
(while :; do sph2pipe "$f" > "${f}.wav"; done) &
done
ORIGINAL ANSWER
I am not at my computer but can you generate the WAV files automatically, use them, then delete them...
for f in *.sph; do
sph2pipe "$f" > "${f}.wav"
done
Then use them,,,
Then delete
rm *.wav

QT-FastStart Windows how to run it?

So I have a lot of mp4 files on my computer and I read that QT-FastStart is for moving the metadata from the end of the files to the beginning but how do I use or run it ?
Every time I drag and drop a file into qt-faststart, nothing seems to happen?
I downloaded the 64bit version from here:
https://web.archive.org/web/20140206214912/http://ffmpeg.zeranoe.com/blog/?p=59
Do I need a batch file or something or a specific command line parameter to make it run?
Note, QT-FastStart is described here https://manpages.debian.org/stretch/ffmpeg/qt-faststart.1.en.html
qt-faststart is a utility that rearranges a Quicktime file such that
the moov atom is in front of the data, thus facilitating network
streaming.
It can be used (perhaps among other purposes), for making a sample file when demonstrating an issue. One can take a large file, fix it with QT-FastStart, then use dd to cut a sample. And the sample should play. Whereas if you did dd without doing that then it wouldn't or may not play.
See Neil's answer qt-faststart infile.mp4 outfile.mp4
However, QT-FastStart has now been integrated into ffmpeg.
ffmpeg -i original.3gp -codec copy -movflags +faststart fixed.3gp
List item
simple. in CMD prompt run qt-faststart infile.mp4 outfile.mp4

"batch" files in bash

I want to make a "batch" file so to say for some bash commands (convert.sh). I think it would be best to describe the situation. i have a $#!^ ton of mp4 videos that i want converted into mp3's. it would take me an unreasonable amount of time to convert them using ffmpeg -i /root/name\ of\ video.mp4 /name\ of\ video.mp3 for every single video. not to mention the fact that all the file names are long and complicated so typos are a possibility. so i want to know how to make a shell script (for bash) that will take every file with the extension .mp4 and convert it to a .mp3 with the same name one by one. as in it converts one then when it done it moves on to the next one. im using a lightweight version of linux so any 3rd part soft probably wont work so i need to use ffmpeg...
many thanks in advance for any assistance you can provide
PS: i cant seem to get the formatting sytax on the website to work right so if somone can format this for me and maybe post a link to a manual on how it works that would be much appreciated =)
PPS: i understand that questions about using the ffmpeg command should be asked on superuser however since i dont so much have any questions about the specific command and this relates more to scripting a bash file i figure this is the right place
A bash for loop should do it for you in no time:
SRC_DIR=/root
DST_DIR=/somewhereelse
for FILE in ${SRC_DIR}/*.mp4
do
ffmpeg -i "${FILE}" "${DST_DIR}/$(basename \"${FILE}\" .mp4).mp3"
done
Sorry - I don't know the ffmpeg command line options, so I just copied exactly what's in your post.
1) use find:
find . -name \*.mp4 | xargs ./my_recode_script.sh
2) my_recode_script.sh - see this question
so you can easily change the extension for output file name
the rest is trivial scripting job:
ffmpeg -i $name $new_name # in my_recode_script.sh after changing extension
this is enough for one-time script, if you want something reusable, wrap it with yet another script which receive path to dir, extensions from which to which to recode and call other parts :)

Stripping Audio From Vob Files through command prompt

What we need to do is either, extract the audio from a group or singular Vob video file and convert it to a .Wav format. Now the process of actually extracting the audio and converting it can be done from a third party application however this application has to be activated from a batch or c# script. The media we are retrieving the vob files from always comes from the CD drive and will always be placed in the same folder location once the conversion is complete.
In shot I need a program or script that can be activated remotely to extract and convert vob files to .WAV.
Any help will be greatly appreciated.
I only install ffmpeg on Windows and put in cmd this command:
ffmpeg -i [VOB_file_route].VOB [WAV_file_output_route].wav
And that's all, just works.
To do somthing like this you will need to use VLC and cmd they work togeather well and will allow you to strip video and audio from a file easily

Resources