Pass option or argument in ffmpeg - ffmpeg

I'm doing some modification into af_silencedetect.c file, one of the ffmpeg many filters and I want to pass a unique option in when I run ffmpeg. I need ffmpeg to save silence that it found and put them in different log file with unique ID that I'm passing, because I'm running multiple ffmpegs at the same time. Here is what I try to do:
ffmpeg -i audio.mp3 -vn -af silencedetect=n=-50dB:d=1:id=01 -f mp3 out.mp3
How to do that? How to create new parameter and pass it in and grep it inside ffmpeg?

I have been working a bit on ffmpeg and I know that it is a bit painful to start development of new features. They are very few infos for developers and the answers on the ffmpeg mailing list are not always helpful.
Note: The following instructions suppose you are able to compile ffmpeg. Run the "ffmpeg_g" program with gdb, it is the debug version of ffmpeg.
So for adding options you have to look to this line.
For each option you want add a line in this array and set the parameters in this order :
{option name, description, offset in the context object, type, default value, min value, max value, flags}
Note: see other files for possible options types.
Then for each option add a member in the context structure.
And finally use your options with the context object that you obtain with this instruction.
That's all, I hope it will help you.

Related

In ffmpeg command-line, how to show all filter settings and their parameters before encoding?

Is there a way to force the ffmpeg command-line to display a comprehensive list of all filters and their parameters, even those that are applied automatically like -vf scale?
(EDIT: To clarify, I do not mean filter documentation, but rather displaying filters that are instantiated at runtime for a particular command-line, just before transcoding starts. The goal of this is mostly checking that ffmpeg is indeed doing the right thing and not inserting/changing filters when I do not intend it to.)
There are a few options available, but none are comprehensive enough. For example:
The lavfi module has a dumpgraph option (here) but only if you're using lavfi.
The -sws_flags print_info option (here) can be used to determine if -vf scale is applied automatically and shows a subset of its parameters, but not all of them.
Additionally, this question appears related the answer doesn't answer what I'm looking for.
Are there better ways to achieve that?
ffmpeg -filters is what you're looking for
it shows an entire list of the the available filters and how they can be used with the input/output
The only thing it is missing is the parameters. But you can find those on their online docs https://ffmpeg.org/ffmpeg-filters.html

Is it possible to use vidstabdetect and vidstabtransform together in ffmpeg's -filter_complex option?

I'm wondering if it is possible to use the vidstabdetect and vidstabtransform filters together in the -filter_complex option, in one ffmpeg ... command? If it is, a simple example would be great.
No, the vidstabtransform filter reads the entire analyzed data at time of initialization so the data has to be complete at that time.

MediaInfo CLI (Command Line Interface) Syntax Teaching Me Once & For All

Dear Friends at Stack Overflow,
There is a pattern of questioning here that I noticed in many categories, but for the sake of this topic I'll talk about MediaInfo CLI. The same type of questions keep re-occurring because the source problem is NOT solved, which is to teach people how to fish, rather than feeding them with fish.
Some people ask:
"I do not know how to get BitRate only from MediaInfo". They are respected, and the advanced users who answer them are also respected. Others ask the same question for FrameRate, Duration, & Resolution... I respect them, and also respect those who answer them.
However, I'm truly sorry for this process to be redundant. Unfortunately the MediaInfo website documentation does not clarify how to properly use MediaInfo.exe with the CLI version to extract specific information, and the --Info Parameters just lists a lot of parameters without instructing how to use them.
So in order to extract specific information for a video using MediaInfo.exe CLI, I'll just have to kindly ask here because I am unable to customize the parameters myself, since I don't get the syntax on the documentation. I would have taken the easy way to just ask you what kind of information I need to extract from the video, but then every one who doesn't know the syntax will come back asking for redundant questions.
Instead, I decided to waste a bit more of your time by writing all this, in hopes that you will help me and everyone else who will come searching for this specific question on How to Use the MediaInfo CLI --Info-Parameters Syntax so that the answers aren't repeated for every custom inquiry.
I honestly want to understand how to use it, and not just copy pasting the ready made one-line answers I will receive.
I'll start by mentioning what I know, that any new inquirer may learn from the very little I know, and then I'll kindly ask you to teach me how to write proper MediaInfo --Info-Parameters syntax to extract specific video information.
After you Download MediaInfo the CLI version for Windows, extract the zip file and put it on your Desktop.
RUN + CMD
Navigate to the MediaInfo Folder on the Desktop.
Put some Video files in the MediaInfo folder.
Run the following on the terminal:
MediaInfo.exe --help >Help.txt
MediaInfo.exe --Info-Parameters >Info_Parameters.txt
Now you have some help files to search for your required information. The rest of this simple documentation depends on the generosity of my fellow StackOverflow members.
To be more clear about my question, once and for all: How can I write proper syntax for the MediaInfo.exe CLI to extract specific information such as FrameRate, Duration, & Resolution? I need to understand the syntax more than the ready-made solution to be able to customize it later.
Thank you for your time!
When you run mediainfo --Info-Parameters, you will notice that there are seven sections: General, Video, Audio, Text, Other, Image, and Menu. Each of these sections contains many different parameters that contain various information about the file and get called with the format --Output=SectionName;%Parameter%. You can pick multiple parameters from the same section name, separating them with any text you like (including \n for newlines (but not \t for tabs, interestingly)), like --Output=SectionName;%Parameter1%\n%Parameter2%.
You can also add your own text, which gets displayed as however you wrote it, allowing you to label the output for easier reading later. For example, to get the file name, duration, and file size, you can use the command mediainfo --Output="General;File Name: %FileName%\r\nDuration: %Duration/String3%\r\nSize: %FileSize/String%" video.mkv
If you want to get data from multiple sections (like adding video dimensions to the above information), you will have to use a template, as there is no way to get data from multiple sections in the same --Output command and having multiple instances of --Output cancel each other out until you get left with the last one in the list. In the template, specify one section per line and add the parameters to their respective sections, like this:
General;File Name: %FileName%\r\nOverall Bit Rate: %OverallBitRate/String%\r\nDuration: %Duration/String3%\r\nFormat: .%FileExtension%\r\nSize: %FileSize/String%\r\n
Video;Dimensions: %Width%x%Height%\r\n
These parameters will be displayed in the order that they were written in the template, and you cannot go back and forth between sections (in this example, I couldn't add more General parameters after the Video section). To call a template, use the syntax mediainfo --Output=file://template.txt video.mkv or mediainfo --Output=file://C:\full\path\to\the\template.txt video.mkv.
This is also possible on the command line:
mediainfo --Output=$'General;File Name: %FileName%\\r\\nOverall Bit Rate: %OverallBitRate/String%\\r\\nDuration: %Duration/String3%\\r\\nFormat: .%FileExtension%\\r\\nSize: %FileSize/String%\nVideo;\\r\\nDimensions: %Width%x%Height%\\r\\n' input.file
Note the "\n" between the sections
Tested on Ubuntu 18.04 MediaInfo Command line,
MediaInfoLib - v17.12
These days I came across a command line tool called jq. This tool uses filters to manipulate json data like if you are querying a Database.
It seems to me that this tool could be a perfect companion for mediainfo capability of outputting JSON.
Certainly mediainfo parameters are difficult to use but most of us knows how to handle json. Time will be best spent learning jq's filter language than deciphering cryptic mediainfo parameter options ;)
Workflow is more or less like this.
Know what info you want to extract from media file.
Use jq and its filters to extract it.
Commands
See all info on media file in a pretty formatted json
#> mediainfo --output=JSON myVideo.mp4 | jq .
Customize jq filters to get the desired result.
#> mediainfo myVideo.mp4 --output=JSON | jq '.media.track[1] | {FrameRate: .FrameRate, Duration: .Duration, Width: .Width, Height: .Height}'
Extracted info...
{
"FrameRate": "30.000",
"Duration": "158.334",
"Width": "320",
"Height": "176"
}
Possiibilities are endless once you get familiar with jq's filters.

Extracting text subtitles using ffmpeg libraries

I'm writing a C program that uses the ffmpeg's libav* libs, and using Dranger's tutorial, I can decode both audio and video correctly. Currently, I'm trying to extract subtitles. I actually don't want to decode them on time and display them on the video, but actually extract the subtitle text out of the container.
For example, on the cli,
ffmpeg -i video.mkv -map 0:4 -scodec copy out.ass
would give me the ass file back. (For some reason, srts only return the text.)
I've tried messing with AVSubtitle, avcodec_decode_subtitle2, etc., but they're returning the subtitles line by line. I would like the timecodes in srts, header information in ass, etc. All I want is the entire subtitle text file that was muxed into the container.
In the case of .mkv files, you could use mkvextract. You may need to use mkvinfo first to identify which track you want to extract.
Since you want to do this from your own C program, you would probably want to use the Matroska libraries instead of the command line tools.

Merge two or more video files of any format using FFmpeg in iPhone

Is there any direct command in FFmpeg to merge videos in iPhone. I need to do this programmatically by setting the command line argument to the FFmpeg containing the input movie files to merge and the output file name.
I just wanted to merge two .mov movie files using FFmpeg. I was trying to do this in iPhone where I was creating a command line argument containing two video fies to merge as an input parameter and the destination video file as output parameter and then calling main method of FFmpeg. But for merging videos using FFmpeg first we need to convert it to mpg format and then pass the movie files in mpg format in the command line format. This is the only way found to merge the video using FFmpeg as far as I know. Is there anybody out there done this in a different way?
To paraphrase the FFmpeg FAQ entry "How can I join video files?"
Transcode to a format that supports direct concatenation (MPEG-1, MPEG-2 PS, DV) and then back to the desired format.
Use the concat protocol to get the same effect without the intermediate files.
Use named pipes to avoid the intermediate files.
Do any of the above with the lossless yuv4mpegpipe or raw formats.

Resources