Output luma and chroma data in txt format - ffmpeg

Good day!
I would like to know if there's a way to get Y/luma values in txt format
here it is the command line
-https://ffmpeg.org/ffmpeg-filters.html#Examples-105
https://ffmpeg.org/ffmpeg-filters.html#signalstats-1
and one more thing I would like to know the way to get all YUV min/max values at once
thanx
regards.

Use a less verbose log level and append the command with > output.txt:
ffprobe -loglevel error -f lavfi movie=input.mp4,signalstats -show_entries frame_tags=lavfi.signalstats.YMIN,lavfi.signalstats.YLOW,lavfi.signalstats.YAVG,lavfi.signalstats.YHIGH,lavfi.signalstats.YMAX,lavfi.signalstats.UMIN,lavfi.signalstats.ULOW,lavfi.signalstats.UAVG,lavfi.signalstats.UHIGH,lavfi.signalstats.UMAX,lavfi.signalstats.VMIN,lavfi.signalstats.VLOW,lavfi.signalstats.VAVG,lavfi.signalstats.VHIGH,lavfi.signalstats.VMAX > output.txt
You can change the output format with the -of option.

Related

ffmpeg: How to save SSIM and PSNR to a file?

I'm a ffmpeg newbie.
I would like my script (on Windows) to output the average PSNR and average SSIM values to a file.
(but not the values for every frame)
I can output them to the standard output but not to a file.
I use this line:
ffmpeg -i ref.avi -i compressed.avi -lavfi "ssim;[0:v][1:v]psnr" -f null -
I understand I have to change something here: "-f null -" , but I cannot make it work.
Using ssim & psnr filters
On Linux and macOS you can use grep:
$ ffmpeg -i compressed.avi -i reference.avi -lavfi "[0][1]ssim;[0][1]psnr" -f null - |& grep Parsed_ > ff.log
Simple, but major downside is it won't show you the console output, so you may miss errors. To fix that add tee:
$ ffmpeg -i compressed.avi -i reference.avi -lavfi "[0][1]ssim;[0][1]psnr" -f null - |& tee >(grep Parsed_ > ff.log)
Example contents of ff.log from either command:
[Parsed_ssim_0 # 0x5579d7f17b40] SSIM Y:0.796135 (6.906565) U:0.843488 (8.054531) V:0.822424 (7.506157) All:0.820682 (7.463768)
[Parsed_psnr_1 # 0x5579d7f12b00] PSNR y:24.940925 u:23.938192 v:23.641771 average:24.138969 min:23.298059 max:26.880485
If you want to append to ff.log instead of overwrite use grep Parsed_ >> ff.log instead.
If |& does not work for you use 2>&1 instead.
Or use libvmaf
libvmaf filter is slower but will output a log file containing the VMAF, SSIM, and PSNR aggregate scores along with the per frame scores in XML or JSON. Your ffmpeg will need to be compiled with --enable-libvmaf to use this filter.
ffmpeg -i compressed.avi -i reference.avi -lavfi "[0][1]libvmaf=log_path=vmaf.xml:log_fmt=xml:ssim=1:psnr=1" -f null -

ffmpeg cut first and last second of every clip

I'd like to make a batch operation for all files in a folder.
For every file I need to remove the first and last second of the clip, and save it to a destination folder.
This is the command I used:
for %f in (“*.*”) do c:\ffmpeg\bin\ffmpeg -i "%f" -ss 00:00:01.000 -sseof 00:00:01.000 -c:v copy -c:a copy “u:\footage\%f”
That command does not work. It cuts the first second but leave the rest of the file as is.
Maybe there is something I need to change in the syntax regarding -sseof.
ss and sseof both tell ffmpeg where to start from, so your command has two start times specified and no end time. Your command is preferring ss (possibly since it is closest to the input) and ignoring sseof, then working to the end of the file.
You can use to (which takes a position in the file) or t (which takes a duration) to tell it where to end, but if your videos are not all of exactly the same length, you will need to calculate this value for each file. You can get the length of a video using ffprobe like this:
ffprobe -i <file> -show_entries format=duration -v quiet -of csv="p=0"
This will give you the length of the file in seconds. You will then need to subtract the desired amount (in your case, 1 second if you use to or 2 seconds if you use t) and feed the result into the appropriate flag in your ffmpeg command.

could use some help on ffprobe

I'm currently running the following command and it's giving me mostly what I need, but I would like to also have it include the file name.
for %%A IN (%VAR0%\*.wav) DO "C:\program files (x86)\ffmpeg\bin\ffprobe" -i "%%A" -show_entries format=duration -v quiet -of csv="p=0" >>output.txt
The above produces this:
110.994375
This is great, but what I would really want is something like this as I need to import this data into a db for further processing. I need to know which file the 110.9943765 came from.
recording1.wav, 110.994375
Thanks,
Steven
All you need is to add the filename key as well.
ffprobe -i "%%A" -show_entries format=filename,duration -v quiet -of csv="p=0" >>output.txt

ffprobe reports different format depending on file extension

I am using ffprobe on Windows to identify files. The command/parameters I use are:
ffprobe -show_entries format=format_name -v quiet filename
I noticed with certain image files ffprobe reports a different format if the file name has (or does not have) and extension. For example, for a BMP image file named XXX
ffprobe -show_entries format=format_name -v quiet XXX
reports
[FORMAT]
format_name=mp3
[/FORMAT]
But, if I rename the file to XXX.BMP and rerun the command
ffprobe -show_entries format=format_name -v quiet XXX.BMP
reports
[FORMAT]
format_name=image2
[/FORMAT]
Is this behavior expected? Has anyone else encountered this issue? I am using the most recent version of ffmpeg.

Load output of ffmpeg command in text file which detects silences

How can I load the output of below command into a text file?
ffmpeg -i units.wav -af silencedetect=noise=-20dB:d=0.2 -f null -
This command simply detects the silences from a video and I need to store this output in a text file.
I have also found this link but as I am newbie in ffmpeg I am not able to use it in my command.
Thanks..
Wanted to post this update for other people who've had this problem. I had the same problem with the > pipe command and found you can use 2> instead. Possible FFMpeg bug? Not sure.
ffmpeg -i units.wav -af silencedetect=noise=-20dB:d=0.2 -f null - 2> output.txt
You can pipe its output to a file like this:
ffmpeg -i units.wav -af silencedetect=noise=-20dB:d=0.2 -f null - > output.txt

Resources