ffmpeg extract video frames from url to a local variable in Node - node.js

I'm using the Nodejs spawn() functionality to execute a shell command that goes like this:
ffmpeg -i https://someUrl.com/someVideo.mp4 -vf fps=30 frame-%d.bmp
Which works for me as to saving 30 frames per second into numbered files, but I'd like to save every frame into a local variable so I could parse it in whatever way I need to (specifically to a JSON).
What would be the best way to do so?
Thanks in advance.

Related

Save StreamTitle tag in recording

Some streams have StreamTitle tag set and it changes from time to time. Is that information send only when it changes in the stream? For example in this stream StreamTitle is used to tell the artist and the name of current song:
ffprobe -v error -show_entries format_tags http://st.downtime.fi/sun.mp3
Is the StreamTitle tag exclusive to MP3 streams? Can one have it in Opus streams as well?
Can such information be added to the output file created when recording the stream by ffmpeg for example, to be able to see which song is playing when playing the recording later? Could another tag be used to tell program name which may also alter in time?

ffpmeg - how to detect if video crop is completed?

Thanks in advance.
I'm trying to crop a .mp4 video using an ffmpeg binary (within the context of an electron-react-app).
(The binary is run in a child process using execFile() and outputs to a temp folder which is later deleted)
ffmpeg varies considerably in the time it takes to complete the creation of a cropped video file (1sec to 18sec) depending on the computer (mac vs Windows).
I need to read the cropped video file.
I've set up an event listener in the Main process of electron
if (!monitorCroppedFile) {
console.log(`${croppedFilePath} doesn't exist`);
} else {
console.log(`${croppedFilePath} exists !`)
...readFile...;
Once monitorCroppedFile = true I read it using fs.readfile().
The problem is that ffmpeg initally creates the cropped file path but it sometimes takes ages to complete the process of cropping.
This results in the read file often being blank (as the read is triggered on detecting the file path of the cropped file).
I've tried using -preset ultrafast in the ffmpeg arguments but this only improves things on Windows marginally.
The problem doesn't occur on Macs.
Can anybody suggest a possible solution ? Is there a way to detect when the crop is fully completed ?
Many thanks.
Add -progress FILE to your command where FILE should be a filename. ffmpeg will log processing status to that file. Search for the line progress=end in it. Once you find it, you can read the file.

batch FFMPEG-Normalize AND convert via Python?

I am currently working on a script to help me batch convert and
normalize audio files (wma to mp3)
In the search of useful tools I was lucky to stumble on FFMPEG-Normalize!
My script is running from Python and I am calling FFMPEG via subprocess.
I could not get the FFMPEG-Normalize to output Mp3 files - thus I am
doing another FFMPEG call to convert the resulted wav files.
Do you know how to make FFMPEG normalize also convert to mp3 ?
The second issue is that only part of the files in my folder are being
processed, I cant understand why. Out of 8 files I have in the path,
sometimes all of them are processed and sometimes only 3, or 5... very
weird!
Here is my code :
for file in sorted(os.listdir(pathdes)):
os.chdir(pathdes)
subprocess.call(['ffmpeg-normalize','-m','-l','-0.1',file])
file = 'normalized-' + file
file = file[:-3] + "wav"
file2 = file[:-3] + "mp3"
os.chdir(pathdes)
subprocess.call(['ffmpeg', '-i', file,'-b:a','320k', file2])
I understand FFMPEG normalize was written in Python, maybe there is
another way to call it other than subprocess ?
Am I missing something ? (i know i am !)
Thank you so much !
The ffmpeg-normalize tool allows you to set an audio encoder as well, using the -a, --acodec <acodec> option.
For example, to EBU R128-normalize a bunch of WAV files and encode them to MP3 with libmp3lame:
ffmpeg-normalize --ebu --acodec libmp3lame --extra-options "-b:a 192k" *.wav
Note that for MP3 specifically, you could use MP3Gain to change the volume without having to re-encode the files.

HandbrakeCLI command lines

I'm trying to convert DVD iso files to mp4 using HandbrakeCLI. I use the following line in a batch file:
D:\HandBrakeCLI.exe -i "D:\input.iso" -o "D:\output.mp4" --no-markers --width "720" --height "480" --preset "HQ 480p30 Surround" --encoder "mpeg2" --audio-lang-list "eng"
When I do this, I must then extract the audio from the file, using the following line:
D:\eac3to\eac3to.exe "D:\output.mp4" "D:\output.wavs" -down16
However, when I attempt to extract the audio, I get the error message
The format of the source file could not be detected.
Is there anything wrong with my former line of code that's causing the mp4 to get screwed up?
Minor side question: I'm also trying to get handbrake to remove subtitles and also only keep English audio, do you know what code could be used for that? I started a bit there with the --audio-lang-list "eng" but I'm now sure what to do from there.
Thanks a lot in advance!
You need to use a valid audio format. .wavs is not valid. You have to use an available audio codec to output to the below for --aencoder. The default output audio for MP4 is .aac
av_aac
copy:aac
ac3
copy:ac3
eac3
copy:eac3
copy:truehd
copy:dts
copy:dtshd
mp3
copy:mp3
vorbis
flac16
flac24
copy:flac
opus
copy
Defaults for audio
av_mp4 = av_aac
av_mkv = mp3
You need to pass none for no subtitles
-s none
And define only eng track like you were doing
--audio-lang-list eng
Check out the Handbrake CLI Documentation for the command line code:
https://handbrake.fr/docs/en/latest/cli/cli-guide.html
You can also try using a different program once you extract the audio. A program like XMediaRecode. It can also remux audio and video and convert other audio formats to wav
https://www.videohelp.com/software/XMedia-Recode

Is it possible to stream during a conversion? - FFMPEG

I'm wondering if it is possible to stream video while the video is being generated through conversion.
Any ideas?
Assuming that your copy of FFmpeg includes something like rtmp amongst the protocols listed with ffmpeg -protocols you should be able to do this using the split video filter. The whole command will look something like:
ffmpeg -i input.mp4 <video options> -filter split rtmp://server[:port][/app] out.mp4
well use the url you want to stream to (be it udp or rtmp) as output instead to output to a file.
To do both , you ll need to use pipe

Resources