I'm new to FFMPEG and I'm having a really hard time understanding the documentation: https://ffmpeg.org/ffmpeg-all.html#aspectralstats
I want to get the centroid value for an audio file using command line.
ffmpeg -i file.wav -af aspectralstats=measure=centroid -f null -
I get the following errors
[Parsed_aspectralstats_0 # 000002a19b1b9380] Option 'measure' not found
[AVFilterGraph # 000002a19b1c99c0] Error initializing filter 'aspectralstats' with args 'measure=centroid'
Error reinitializing filters!
Failed to inject frame into filter network: Option not found
Error while processing the decoded data for stream #0:0
Conversion failed!
What am I doing wrong?
The measure option was added mere 4 weeks ago. So, yeah, you probably missed it by a couple days. Grab the latest snapshot if you want to only retrieve the centroids. The snapshot you have should get you the centroids along with other parameters if you just call aspectralstats (no options).
Also, the aspectralstats outputs only goes to the frame metadata and not printed on stdout by default. So you need to append ametadata=print:file=- to your -af.
ffmpeg -i file.wav -af aspectralstats=measure=centroid,ametadata=print:file=- -f null -
<Shameless plug> FYI, if you're calling it from Python, I have implemented an interface for this in ffmpegio if interested.</sp>
Related
I have a dozen of webm videos I need to resize with the following:
ffmpeg -i input.webm -vf “scale=w=360:h=270:force_original_aspect_ratio=2,fps=10,crop=360:270” output.webm
I tried the command and it worked fine for some webm videos, but most of the returned the following error:
[AVFilterGraph # 0x7fcb3db076c0] No such filter: '“scale'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
[libopus # 0x7fcb3c10a000] 1 frames left in the queue on closing
Conversion failed!
I checked that ffmpeg still worked fine with previously successful files.
How can I get ffmpeg to work with the remaining wemb videos?
The issue was that after the first few files I copy pasted the command on a message app (Slack was the app I was copy/pasting on) and it changed the double quotes into something that only looks like double quotes.
// this works
'command'
"command"
// this doesn't work
‘command’
“command”
And that seemed to be the issue.
Thanks to #Gyan for pointing me at the right direction!
I wanted to edit my .m4a voice recording from Samsung Voice Recorder using ffmpeg 2.2.2, however, I got the error Invalid data found when processing input. I tried to open it through Audacity, but it returned an error claiming that the ffmpeg library is missing, which is definitely not the case. Eventually I tried to use online .m4a to .mp3 converters, but they all returned error, so I assume there may be an issue with the encoding of the original file and ffmpeg should be configured accordingly. What settings shall I use? (The original file can be played on the phone without any problem.)
ffmpeg -ss 00:00:19 -i "C:\Your\Folder\original.m4a" edited.m4a
We have a request to append output/timecode into metadata starting from frame 0.
It is done in nuke with addtimecode node, starting at frame 0 and timecode as 00:00:00:00 with a prefix of "output"
I'm trying to do it with ffmpeg but nto able to get it :(
I have tried with -metadata output/timecode="00:00:00:00" It didn't work
Metadata fields are dependent on your output format.
I am trying to add chapters to a ogg file containing vorbis audio.
From this link I copied the following ffmpeg command.
ffmpeg -threads auto -y -i in.ogg -i metadata_OGG.txt -map_metadata 1 -codec copy out_METADATA.ogg
My metadata_OGG.txt file is as given below.
CHAPTER00=00:00:00.000
CHAPTER00NAME=Chapter 01
CHAPTER01=00:00:05.000
CHAPTER01NAME=Chapter 02
CHAPTER02=00:00:10.000
CHAPTER02NAME=Chapter 03
I am getting the following error.
[ogg # 00000000006d6900] Unsupported codec id in stream 0
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
But if i change -codec copy to -acodec copy there is no error in ffmpeg but the text file is converted to video. i.e. the output file will have a static video frame with the text of metadata_OGG.txt in it. Also, I observe the following log message during conversion.
Stream #1:0 -> #0:0 (ansi (native) -> theora (libtheora))
Stream #0:0 -> #0:1 (copy)
Anybody please tell me what is going wrong here?
Also, I would like to know what is the right way to add chapters to ogg. I searched for some tools also. I did not get any.
Here is what worked for me using ffmpeg 4.3.1.
I have a metadata file which almost respects ffmpeg's metadata file format:
;FFMETADATA1
title=Evolution theory
[CHAPTER]
TIMEBASE=1/1000
START=0
END=
title=Darwin's point of view
[CHAPTER]
TIMEBASE=1/1000
START=78880
END=
title=Genghis Khan's children
Notice the file format requires an END time, but leaving it empty didn't bother in my case.
Now I add chapter information to my opus/ogg file:
ffmpeg -i darwin.opus.ogg -i darwin_chapters.txt -map_metadata 1 -c copy darwin_withchapters.opus.ogg
Note: if you want to overwrite existing chapter information from the file, you may need to add a -map_chapters 1 parameter in the ffmpeg command line above.
That creates the file darwin_withchapters.opus.ogg. I check if chapter info has really been added to the file:
opusinfo darwin_withchapters.opus.ogg
You would use ogginfo for Ogg/Vorbis files.
And here is the result (I removed a few irrelevant lines):
ENCODER=opusenc from opus-tools 0.1.10
ENCODER_OPTIONS=--bitrate 112
title=Evolution theory
CHAPTER000=00:00:00.000
CHAPTER000NAME=Darwin's point of view
CHAPTER001=00:01:19.880
CHAPTER001NAME=Genghis Khan's children
[...]
Here you go. ffmpeg did the conversion between its metadata file format to the vorbis tag/comment chapter format.
You could also directly write metadata in the Vorbis Chapter Extension format, and use the classic vorbiscomment tool, or other tools which allow editing of opus/ogg in-file tags.
Opus has been mentioned here. I was trying to make opusenc from opus-tools add chapters when encoding and couldn’t find a command line example anywhere. Thanks to the hints in this thread I managed to figure it out, perhaps someone may find it helpful.
opusenc --comment "CHAPTER000=00:00:00.000" --comment "CHAPTER000NAME=Hello" --comment "CHAPTER001=01:23:45.678" --comment "CHAPTER001NAME=World" input.wav output.opus
The chapter key/value scheme is the aforementioned Ogg/Matroska one. Of course, more metadata options like --title, --artist etc. can be added.
Using ffmpeg to add the chapters resulted in two problems for me: The artwork image in the ogg/opus input file was missing in the output file, and ffmpeg rejected empty END chapter times.
I did this on Windows 10 using
opusenc opus-tools 0.2-3-gf5f571b (using libopus 1.3)
ffmpeg version 4.4.1-essentials_build-www.gyan.dev
opusinfo, MPC-HC (64-bit) v1.7.11 and VLC Media Player 3.0.14 Vetinari to confirm.
I found the issue.
For ffmpeg to work, the metadata file should have the following header.
;FFMETADATA1
I followed the steps given in ffmpeg documentation for metadata.
But the issue is not resolved completely.
With the above steps I am able to add metadata to mp4, mkv and other container files but not to ogg files. I am not sure whether ffmpeg supports adding chapters to ogg files.
I have an AJA Capture card. The drivers installed with the card include some DirectShow filter. If I pop the filter into GraphEdit I see this:
and if I run the ffmpeg command
ffmpeg -f dshow -list_options true -i video="AJA Capture Source"
I see
[dshow # 0034eec0] DirectShow video device options
[dshow # 0034eec0] Pin "Video"
[dshow # 0034eec0] pixel_format=yuyv422 min s=720x486 fps=27.2604 max s=1024x
486 fps=29.985
...
[dshow # 0034eec0] Pin "Audio 1-2"
[dshow # 0034eec0] Pin "Line21"
video=AJA Capture Source: Immediate exit requested
So I see the Video and Audio pins I need. But when I try to run an ffmpeg command to capture both, I can only figure out how to do the video part. How do I hook in to that audio pin? It seems all the examples and documentation point to using a separate audio device, and nothing about hooking into the pins. I'm running it out of a batch file for now like this and I use the ^ to break the line
ffmpeg.exe ^
-y ^
-rtbufsize 100M ^
-f dshow ^
-i video="AJA Capture Source" ^
-t 00:00:10 ^
-aspect 16:9 ^
-c:v libx264 ^
"C:\VCS_AUD_SAMPLE.mp4"
Again, the command above will get me some beautiful video, but I can't figure out the audio part. Is this even supported in ffmpeg or am I going to have to modify the ffmpeg dshow code?
I am the developer of this filter.
Actually the same device is used for both audio and video streams. Moreover, the data for both streams are the result of one function call. Dividing by separate audio and video filters in other cards (example - DeckLink) is artificial (they must be internally connected). Possible reason for division - an attempt to simplify the graph. However, this can lead to other problems (using streams from different devices).
Why ffmpeg can't work with pins of the same filter - not clear to me. This problem of ffmpeg developers.
About only one instance access - very old version of AJA Capture Source filter used. A more recent version of the filter allow you to create multiple instances simultaneously (but only one instance may be in "Play" state). Please, check AJA site for download latest versions of filters. If you like to check latest beta versions of AJA filters, please, write to me at support#avobjects.com
So after tracing through source code of FFmpeg it was deemed that it could not hook up to multiple pins on a dshow source, so instead of modifying the FFmpeg source, we piped the AJA source pins through two virtual capture sources to achieve the desired result.
OK support for this was (hopefully) added recently in FFmpeg dshow, you can specify ffmpeg -f dshow -i video="AJA Capture Source":audio="AJA Capture Source" now and it work.
There are even new parameters for selecting which pin you want to use, if you need them. https://www.ffmpeg.org/ffmpeg-devices.html#dshow
If it doesn't work for somebody/anybody please let me know rogerdpack#gmail.com or comment here.
From http://ffmpeg.org/trac/ffmpeg/wiki/DirectShow
Also this note that "The input string is in the format video=<video device name>:audio=<audio device name>.
So try
ffmpeg.exe -f dshow -i "video=AJA Capture Source:audio=audio source name"