text:
Where/when should I specify unsharpen when converting images to video?
Edit: its not liking it when I specify .exr as the output file....not sure if there's a fix to support exr in ffmpeg. Just pretends its .png then unless you can help with that as well
Hi so I transcoded a 30 min video into a 16 bit 1080p.exr image strip. I then plan on upscaling these images with ffmpeg to 4k. I then want to render it out again as an 8 bit h.264 .avi.
Somewhere here I want to apply sharpening to make the upscale a bit cleaner (this command looked nice when applied to the exr on their own):
-filter "unsharp=1x=13:ly=13"la=2.0"

Will unsharpening re-encode? Because my final video output is h.264 8/10bit I don't want to re-encode that.
My question is where in my commands should I be applying the unsharp? And should I only apply it once or as many times throughout that it makes things look nice?
I thought for simplicity I would divide my commands up, but maybe they should be done as a single command? Will a single command lessen the number of re-encodes any?
Step 1. Upscale:
ffmpeg -i %d.exr -vf scale=3840:-1 C:\Users\Me\Desktop\Test\output_3840.exr

Step 2: Turn images into .avi (not sure if this works for avi, i kno it works for mkv tho)
ffmpeg -framerate 500/21 -i %d.exr -c:v libx264 -crf 18 -pix_fmt yuv422p10le output.avi

Step 3: Unsharpen...but when/where?
-filter "unsharp=1x=13:ly=13"la=2.0"

I'm not even sure how to combine these, or like I said if doing so will limit the re-encodes. Is there a single command I can/should be using here based on the 3 above? I'll just do the audio as a separate command with -c copy so it doesn't re-encode, it makes it less confusing for me.

Of course it will re-encode. You can't change the content without re-encoding. Stop fretting about the infinitesimal losses re-encoding is going to make, when the end result is an 8-bit h.264 file. It. Won't. Make. Any. Difference.

my base footage is h.264 though. so unfortunately i need to worry about it. and limit the total render to 1, and transcode and render the number of extra times necessary inbetween.

No, the compression has already happened. Once ffmpeg has decoded the footage that's as good as it's going to get. Adding the 16-bit png stage will not increase the quality of the input, it will in fact decrease it very very slightly due to quantisation loss. But mostly it will just be a PITA for no benefit.

Artifacts are the problem I'm trying to avoid. Re-encoding the fooage as h.264 it creates artifacts. Re-encoding twice creates a stupid amount of them and its very noticable, thus I need to keep of and limit the re-encodes and rely on trancode to higher bit numbers if necessary. The problem is my base footage is 8 bit.

But you don't need to re-encode twice. Upscale and filter in the one operation. Did you look at my answer?

"Yes I looked at your answer. Did you look at my question?" Comments like this are extremely aggressive. And you have made many such on this and my other post. You ignored my criteria as unimportant and gave an answer based on what you thought was important. There are reasons I asked the question the way I did. If you wish further communication please keep it specific to answering the question as posed.

Just do it all as one step and forget about up-sampling to 16 bit. That just adds complexity, processing time, extra storage and for no gain in quality in the end result that anyone could possibly perceive.
fmpeg myinputVideo.avi -vf "scale=3840:2160,unsharp=1x=13:ly=13"la=2.0" myoutput.mp4

The internal process of ffmpeg works basically like this:
 _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------> | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
 ________             ______________       |
|        |           |              |      |
| output | <-------- | encoded data | <----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|

The "decoded frames" box basically is where the pixels in the image are stored in memory as uncompressed RGB or YUV (or whatever) samples. That's the point where your footage is as good as it is going to get. Any extra filtering or processing will notionally degrade the image due to quantisation loss, or compression etc.. That image is what is sent to the filter chain. What you're doing is:
demux → decode → [decoded frames] → resample → encode → mux → save →
demux → decode → [decoded, resampled frames] → upscale → sharpen → encode → mux → save

so you're applying your filters to frames that have had an extra resample and encode step added, not to mention taking up a whole bunch'a space on your HDD.
When you filter something the output of one filter goes to the input of the next filter in the chain, so if you put scale first the scaled image is then sent to the sharpen filter.
 _______        ________        _________        ________
|       |      |        |      |         |      |        |
| input | ---> | scale  | ---> | sharpen | ---> | output |
|_______|      |________|      |_________|      |________|

You can get more complex by using -filter_complex which allows you to have various inputs and outputs for filters.
https://ffmpeg.org/ffmpeg.html#Filtering for more ascii-art empowered knowledge

Is "scale=3840:2160,unsharp=1x=13:ly=13"la=2.0" a valid syntax? Should not theree be something else instead of double quote in the 13"la? Upd. judgung by the docs it should be : instead of " - "scale=3840:2160,unsharp=1x=13:ly=13:la=2.0"


text:
What are some GUI that allow me to cut sections from a video without re-encode?
To illustrate: Say I want to delete the 10-11 minute point of a 20 minute video and create the new video of 19 minutes without re-encode. Same as described in the link below; think: removing commercials from a tv show.
https://superuser.com/questions/681885/how-can-i-remove-multiple-segments-from-a-video-using-ffmpeg
I was trying to do the above with ffmpeg, but without re-encoding. I currently can do it by using each command separately i.e.:
    ffmpeg -ss 00:00:00 -i input -to 00:00:00 -c copy output
And then I'd concaticate the pieces I want together.
I looked up how to find the nearest i frame to try and get more accuracy when choosing times. But putting all this together and checking the video after getting each piece of information...turned into a very inefficient process.
So I wanted to know if there are any gui (video editors) that support this functionality of ffmpeg in a more manageable manner. I mean the simplest and ideal process I can think of is: I toss the videos in the editor, i click an option to disable re-encoding, i choose the sections I want. Then it just chooses the nearest i frame to my cut choices (if it displayed the i frame that would be good too) and does all the above stuff.
I don't have much experience with the modern capabilities of video editors. The ones I have used have very limited functionality when it comes to rewrapping/'no-encoding' compared to ffmpeg command prompt, or just always re-encode to begin with. So I'm just curious if there are editors that have the kind of re-wrapping functionality that ffmpeg command prompt has. Otherwise I'll need to pursue the solution from a scripting perspective, of which I know nothing about.

This verges on limitations with codec types, rather than being solely about limitations with software. A codec with i-frames (I presume h264 or similar is what you are using) has distinct limitations when copying the stream, as opposed to re-encoding, of which you seem aware. If you have the ability to record in a different format amenable to this trim/cut process you describe, then the best advice is to use that.

That said, if there's such a gui, I'm eager to know it.

Changing your workflow to not care about an extra re-encode here or there seems to be the standard all communities adhere by....I'm really confused as to why that is though given most of the data floating around has a low colour bit (8 bit) and suffers greatly from artifacts created during re-encode. I guess I'm hoping to stumble across a secret "rewrapping" society or something. The search continues...

Well, if you have full control, then hopefully you're capturing in a lossless or virtually lossless format. If so, then re-encodes will not affect quality, however, they take more time. My concern in my workflow is time spent, as I only work with my own data, which is captured lossless, but I generate over 1000 hours of data per year.

Without reencode no GUI: https://stackoverflow.com/questions/59460175/how-to-trim-a-video-file-at-a-precise-position-without-re-encoding-using-ffmpeg

LosslessCut is an open-source video cutting tool. Its interface is built using Electron, and its backend is ffmpeg. It's available on the three main operating systems (Linux/Mac/Windows), and also from the Mac, Microsoft and Snap stores.

Does the job, open source, easy to install. The interface could be cleaner but it's easy to learn to use.

Too bad it's inprecize same as using ffmpeg from cli. Had a hope it would be smart enough to re-encode the small fragments to fix -ss timing discrepancy, but sadly it isn't (yet).

Though it has these nice "previous keyframe"/"next keyframe" buttons - with them one can extract a separate tiny video of the whole keyframe in which you want to split, re-encode it and merge result back with parts before/after the keyframe.

DVDVideoSoft makes a tool called Free Video Editor. It is free, but certain features are only available to premium users who buy a license. Free Video Editor can cut out scenes without re-encoding when using compatible formats such as H.264. You can export as a single file, or individual pieces. This feature was free (up until at least version 1.4), but is now only available to premium users.
MP4Splitter (part of MP4Tools) can be used to break an MP4 into multiple parts, and MP4Joiner (part of MP4Tools) can be used to join the parts you wish to keep. It is free.

FFmpegYAG
FFmpeg GUI for Linux & Windows
https://sourceforge.net/projects/ffmpegyag/
~18mb
I was looking for something to trim specific clips from my dashcam videos.  A lot of the "free" programs I found were trial versions or came with extra baggage.  When I realized that FFmpeg was a reputable engine that was capable of doing all the work, I decided I wanted to find a solution that worked with it.
I have very limited experience with FmpegYAG, but I was able to get it working after a few minutes of testing.  I can visually cue the onscreen video to the beginning and ending of the clip I want encode.  If you preview the video it will show a red "X" over the video that you have selected to exclude from encoding.
I like that it can generate script files.  That allows me to see what commands it is sending to FFmpeg.  They script files have an extension of .cmd but are equivalent to .bat files.

Note that if you select copy as the Video Codec, the encoding is extremely fast.

Unfortunately, this does not work on recent OSes (requires an old version of wxwidgets).

AviDemux will do this - keyframe accurate without re-encoding ('copy' mode) as long as the vid file encoder settings are identical (I get driven nuts when the specs vary somewhat unexpectedly. I wish there was a clever workaround...)
Avidemux is a free video editor designed for simple cutting, filtering and encoding tasks. Tasks can be automated using projects, job queue and powerful scripting capabilities. It supports most video formats like DVD, VOB, AVI, WMV, MPG, MP4, AVI, MOV, MKV, DV, FLV and codecs like H.264/AVC, H.265/HEVC, MPEG4 ASP(DivX, XviD), MPEG2, MJPEG, HUffYUV, PNG, YV12.
It's available on the three main operating systems (Linux/Mac/Windows), and there's a 'portable' version.
I use it on a Mac.
GREAT APP!
https://www.videohelp.com/software/AviDemux
=========
I have also used LosslessCut recently and am very impressed by the possibilities of its 'smart cut' potential:
"...This experimental feature will re-encode the part of the video from the cutpoint until the next keyframe in order to attempt to make a 100% accurate cut while losslessly copying the rest of the segment.
Only works on some files:..."
https://github.com/mifi/lossless-cut/issues/126
https://github.com/mifi/lossless-cut/blob/master/README.md

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
I need to modify a movie's displayed subtitles and display as an image overlay
I'm kind of at a loss on how to do this. I have access to gimp/inkscape/ffmpeg/vlc, and I can download font styles as needed off the web.
So I have a movie. I play the movie in vlc player, I display the subtitles.
What I need is to take the displayed subtitles, change what they say and make them into an image overlay. So png RGBA I suppose, so I can overlay them onto a different scene. In other words I want to recreate the font and spacing and all the characteristics displayed in vlc.
Calling it up in ffmpeg:
The movie contains the sub file as a .ass file. As well as a single .ttf attachment stream. All I know is that those .ttf streams contain formatting information that make the text look the way it does, I'm unsure what to do with it though. I can separate the .ass stream out of the container with ffmpeg and open it in a text editor. I look at it and I think this is the information I want to use to create new text in the style:
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding

Style: Main,Open Sans Semibold,36,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,-1,0,0,0,100,100,0,0,1,1.7,0,2,0,0,28,1

I don't know what to do with this information though.
In inkscape I create text and go through my fonts and apply a stroke with differing thickness and nothing comes close to the desired font, which seems to be the default vlc player subtitle font shared across many movies i tryout.
I get the feeling there is a much better and easier way to go about doing this.
Can I create an overlay with this info as desired with ffmpeg? That would be great.
Edit: I tried this on the isolated subfile.ass, figuring I could just modify the .ass file with the new text I want if this worked. I got it to work, but the formatting is still a bit off. I need whatever is in the .ttf stream to do its thing here, not sure how to include it in the command.
ffmpeg -ss 00:01:87 -f lavfi -i "color=color=white@0.0:size=1920x1080,format=rgba,subtitles=subfile.ass:alpha=1" -frames:v 1 out.png

Edit: I read that the Stream # 0:3: Attachment: ttf
is just a font style and doesn't contain positioning or anything other than teh font incase u don't already have it. So the solution would be to grab that file and put it in my windows font folder? I tried to grab it out using:
ffmpeg -i input.mkv -map 0:3 -c:t copy output.ttf

But it says .ttf isn't the right extension to use. How do you export .ttf files out of a video?

ffmpeg -dump_attachment:t:3 out.ttf -i INPUT

Wonderful, everything works now. Is there a way to speed up the: "ffmpeg -ss 00:01:87 -f lavfi -i "color=color=white@0.0:size=1920x1080,format=rgba,subtitles=subfile.ass:alpha=1" -frames:v 1 out.png
" command? It's taking about 2 minutes per overlay. I'm just wondering if its doing unnecessary things, as that seems like a long time. If not, its fine its working that's what matters. thanks!

Ok great. So 3 steps really:
1. Make sure you have the .ttf on ur computer installed, if not extract it from the streams
ffmpeg -dump_attachment:t:0 OpenSans-Semibold.ttf -i input.mkv

In my case I had 4 streams and the .ttf was my only t stream so its 0. And the filename to be used is the one listed in the stream info which is OpenSans-Semibold.ttf in my case.

Take the sub file, .ass in this case out of the video container. and save it as a .ass file
Use this command here on the subfile. Open the subfile in a text editor and see the timestamps, and just change the text for a specific timestamp with the formatting you want. And write the time of that timestamps in the -ss. Then after you render out ur output. Just change the .ass in the text editor to have the new text you want. Save. And repeat the command changing the output to something new each time.
ffmpeg -ss 00:01:87 -f lavfi -i "color=color=white@0.0:size=1920x1080,format=rgba,subtitles=subfile.ass:alpha=1" -frames:v 1 out.png

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
"Opus cuts audio above 20kHz" - Is this normal for lossey audio codecs?
Summary:
1. Is it normal among lossey codecs?
2. what are the effects of this specifically when handling this 'cutoff' audio file?
3. Why is it still saving the file as 48khz if it doesn't contain that data anymore?
+++++++++++++++++++++++++++++++++++++++++++++++++++++
I was reading the wiki for Opus. And the bottom notes caught my eye, mainly:
https://en.wikipedia.org/wiki/Opus_(audio_format)

Opus cuts audio above 20 kHz, the generally accepted upper limit of
  the human hearing range.

It lists very specific sample rates that are supported as well for opus on that page: 8khz, 12khz, 16khz, 24khz, 48khz
So if I intend to use opus as my audio format does it mean I need only record at a sample rate of 24khz? Anything above 20khz is just extra data for transforming the waveform before export? So no intent to transform would mean you might as well just record at 24khz?
I'm not overly familiar with the specifics of audio codecs, but is this normal for codecs to cutoff such a large range of sounds? That just seemed concerning to me, given everyone records at ~44.1khz minimum and in general 48khz is well used. Is it better to use a different 'lossey' codec than opus if I intend on possibly editing/re-encoding the audio again at some point? Or would there be no real difference between the loss experienced when editing and re-encoding an opus vs the loss when editing an aac/etc?
I'm also confused why when I re-encode from a 48khz f32 .wav to opus it saves itself as a 48khz sample rate still. Isn't all data above 20khz gone...? That's confusing to me. edit: well I guess when you merge different sample rates they sound of different speeds so that's why it would keep the original format..?
And yes I'm aware that lossless is the ideal format if I intend to re-encode/edit at some point, but for the sake of argument let's pretend we have to choose between lossey formats (at least for the initial export, we can trans-code later to lossless)


text:
ffmpeg scaler options not working
https://ffmpeg.org/ffmpeg-scaler.html
ffmpeg -i in.png -vf scale=3840:2160 -sws_flags lanczos out.png

-vf scale=3840x2160:flags=lanczos

I went down the list upscaling a 720p image to 4k using the various ones on the documentation, lanczos is input above. I tried the variation below as well. I noticed 0 difference after tossing them in gimp and zooming in and comparing....exact same. I also noticed it doesn't matter what I type, i could call them something wrong or spell them wrong and the command works the same. They don't seem to be applying at all. Is there any indication in command prompt as to what scaling algorithm is being used so I can confirm ? I didn't see any difference.

Set -v 40 to see selected algo.

w: 3840 h: 2160 flags: 'bicubic' interl:0......it keeps saying bicubic regardless of what I put in the commands. Hash program also telling me they are indeed the exact same images.

Bug with -sws_flags but -vf scale=3840x2160:flags=lanczos works here.

Use the print_info flag to see what the scaler is doing, example from an actual conversion:
-filter:v "scale=w=1280:h=-2:flags=print_info+bicubic"

Part of the relevant output:
[Parsed_scale_0 @ 000001d8187fef00] w:1280 h:-2 flags:'print_info+bicubic' interl:0
[swscaler @ 000001d819bc7fc0] bicubic scaler, from yuv420p to yuv420p using MMXEXT
[swscaler @ 000001d819bc7fc0] 1920x804 -> 1280x536
Parsed_scale_0 @ 000001d8187fef00] w:1920 h:804 fmt:yuv420p sar:1/1 -> w:1280 h:536 fmt:yuv420p sar:1/1 flags:0x1004

Edit:  I also always use "-loglevel verbose", don't know if that changes the level of detail the scaler filter outputs.


text:
How to make PNG video render into 10bit h.264 matroska/avi file?
I'm not good with this stuff, so please dumb things down as much as humanly possible and assume that what I type is probably all i know about ffmpeg.
Okay so I rendered a 1080p video as thousands of 16 bit png images.
I want to take these images and create a 10 bit h.264 video file with either a matroska or avi container. I'll need to add in a .wav file as the sound without re-encoding as well. I'm guessing I can just use this command at any time to do so after its in mkv format in this example:
ffmpeg -i original.mkv -i audio.wav -c copy output.mkv
So this is what I have so far: Note I have no idea what the input for PNG images is so I just left it as "input" as you see below. When I do the command below on a normal video file it uses 8 bit. So I need to know the command to specify 10 bit.
ffmpeg -i input -c:v libx264 -preset veryslow -crf 0 output.mkv

(1) ffmpeg -i input.mkv -i audio.wav -c copy output.mkv
(2) ffmpeg -i input.mkv -i audio.wav -acodec copy output.mkv
(3) ffmpeg -i input.mkv -i audio.wav -c:a copy output.mkv
(4) ffmpeg -i input.mkv -i audio.wav -vcodec libx264 -acodec copy output.mkv

Which of these 4 is the best to use if I JUST want to combine video with audio without re-encoding? or is there an even better one to use?I was told -acodec copy is necessary to ensure it doesn't re-encode, but others have told me differently. should I use -acodec copy instead of -c:a copy?

You can use
ffmpeg -i %04d.png -i audio.wav -c:v libx264 -crf 0 -c:a copy output.mkv

where %04d.png represents the pattern for the image filenames. The % is a prefix indicating a numbering pattern is specified afterwards. 04 represents a 4 character pattern, padded with zeros as necessary. d indicates that the characters are numbers.
The particular filename pattern captured in %04d.png is
0001.png
0002.png
0003.png
...

If instead they are
1.png
2.png
3.png
...
999.png
...
9999.png

you would supply %d.png i.e. no padding.
If it's
myimages_00001.png
myimages_00002.png
myimages_00003.png
...

you would use myimages_%05d.png

3 questions 1. I need to specify the fps to 5/0.21 (23.80952.....lots more decimals) making sure the decimals are respected the same as they were in my video editor. What command should I tack on to it? 2.If my input is OPENEXR instead of PNG, what would change? 3. Why is it doing 10 bit automatically? I thought we'd have to specify a command to make it 10bit, is it going to 10 bit cause my source footage is 16 bit and can support 10 bit? If i use this on an 8 bit video, its gonna do 8 bit, is there a way to make to change this so if my input is an 8bit it converts to a 10bit h.264 mkv video?

Add -framerate NUM/DEN before -i. Both have to be integers. 2) Filenames :)  3) Some encoders, like x264, can auto-negotiate pixel formats. It selects the format best able to preserve input fidelity. Add -pix_fmt yuv422p10le after -crf 0 to always set 10-bits.

So I should I make it 500/21 then? Would this lose me 2 decimal places though? IN my vse (blender vse, it uses python and ffmpeg, I added a picture above!), it has an fps value and an fps base. What is the best way to go about this? It states 23.81 in the bar there, it does infact render it with the extra decimals though. Is there a way to specify fps value of 5 then a base like its listed in the ui of blender there?

As long as you render all frames, it shouldn't matter. Simply specify the rate 500/21 when feeding to ffmpeg.

(1) ffmpeg -i input.mkv -i audio.wav -c copy output.mkv  /
(2) ffmpeg -i input.mkv -i audio.wav -acodec copy output.mkv /
(3) ffmpeg -i input.mkv -i audio.wav -c:a copy output.mkv  /
(4) ffmpeg -i input.mkv -i audio.wav -vcodec libx264 -acodec copy output.mkv  /
Which of these 4 is the best to use if I JUST want to combine video with audio without re-encoding? or is there an even better one to use?I was told -acodec copy is necessary to ensure it doesn't re-encode, but others have told me differently. should I use -acodec copy instead of -c:a copy?

Or did you suggest the code with -c:a copy because it was in the same line as the necessary re-encoding so its already re-encoding and it'll just do the operation during the re-encoding and it doesn't matter? It's not gonna re-encode twice or anything will it?

One more question (so close to having everything figured out!). With the x264vfw, After I downloaded it, it had the configuration ui thing (I added pictures above and included the code for the previous question formatted). Is this a way to preset options so you don't have to specify them in the ffmpeg command line? And if so, what settings should I use for highest quality encode? I set a test using "single pass - lossless" and didn't include -crf in my command line, and the result was a file smaller than the original, and very good looking! Using single pass quantizer 1 it was 10xfileesize.

quantizer was the same but 10x the file size. the render could be a little better still in both. are there any other options I should look at here? Like I'm messing around and I'm noticing the values I change in the configuration are directly affecting the ffmpeg output. im not sure if specifying  the quantizer to 50 in the config  is having an impact if I specify -crf 1 in ffmpeg command line.  I tested but all I can tell is that its respected the command line as an overwrite or its blending the config and command line settings together somehow.

Only cmd (1) will avoid video re-encoding. -acodec is older form of -c:a. Latter form is preferred.

If you use x264vfw, you should skip video encoding in ffmpeg step. But I don't see choice of pixel format selection in that UI. Also, it uses an older version of x264 which only supports 8-bit.

Hi are you saying "-c:v libx264" does not use x264vfw? I thought libx264 was the command to 'use' x264vfw. I'm confused cause when I change the configure tab for x264vfw it directly affects the output (quality/size) when using the libx264 command. "When compiled with 10-bit support, x264's quantizer scale is 0–63. You can see what you are using by referring to the ffmpeg console output during encoding (yuv420p or similar for 8-bit, and yuv420p10le or similar for 10-bit)." I was getting yuv420p in my command line, but u helped me and now its yuv420p10le (even without using -pix_fmt yuv422p10le)

ya I just confirmed my previous comment was in error. and I understand now that x264vfw has nothing to do with c:v libx264


text:
Highest quality convert of wav to aac to fit in mp4 container?
Edit: These should probably be merged as they both go back to the same issue now:
https://sound.stackexchange.com/questions/45177/exporting-wav-as-m4a-creating-sync-issue-in-audacity
So I need to convert a .wav f32 track into the highest quality format possible that fits in a mp4 container.
It says Mp4 will support: MP2, MP3, LC-AAC, HE-AAC, AC3
From what I read online, LC-AAC is the highest quality of the bunch.
Basic command seems to be:
ffmpeg -i input.wav output.m4a

But I get an out of sync issue where the m4a is playing about half a second later throughout than the original wav. And the bit rate of this output seems to be very low, 100's.
"When compatibility with hardware players does matter then use libmp3lame or ac3 in a MP4/MKV container when libfdk_aac isn't available."
Is this...what I'd want below? Or are there other things to improve quality I can specify? or maybe its just wrong syntax already.
ffmpeg -i input.wav -c:a "something" -q:a 330 output.m4a

LOG AND IMAGE TEST UPDATE:
First picture is a wav audio file at the top. Then the aac created in ffmpeg, sync issue is present.

Share full log.

Did smaller test and posted information in description.

The output is fine. Audacity uses an old version of ffmpeg, which does not skip the priming sample. Other players should skip it. AAC streams will be encoded with that sample, so it's all about the player's handling.


text:
Do video containers influence the video quality?
https://en.wikipedia.org/wiki/Comparison_of_video_container_formats
Understanding containers and codecs
I'm just confused because the information above seems to indicate containers are simply chosen based on what codecs you want in your video, and that they are independent of the actual output which is determined by the codecs.
But then why is it when i output a h.264 in an .mp4 container the quality is much worse and shading different than h.264 in an .avi or .mkv?
And  if there is a reason is there a table or compilation somewhere showing this kind of information for each container so I know short of trying them all?
Extra
I ask because I'm trying to find an acceptable container to hold a .wav32 (or mbe .wav 16bit signed) and 4k h.265 video that will be supported by youtube specifically in this case, .avi isn't working. .mkv isnt listed as beings supported but does upload. it seems to be the same as a working .avi, but I don't pretend to understand what's really going on....it re-encodes anyways so its irrelevant so long as it seems to be the same as a supported format..?
People say to convert .mkv to mp4 but I don't see any reason why....mkv supports going to mp4 without a re-encode but whyyy would you limit your audio options and do so....? Especially when mp4 seems to degrade quality as talked about above, although I don't know if going mkv to mp4 produces similar quality changes as straight out rendering into such a container. Other non supported containers like .ts produces favourable visual results as well.
So this is relating to the posed question of does ur video container just hold the codecs and not affect anything really whether it be "supported" by a streaming site or not? It's all irrelevant and its the codecs that determine everything?

The choice of container has no bearing on stream quality, which is determined solely by encoder parameters.
What may happen is that the stream could have non-standard or at least unexpected colorimetry properties and some containers can't store that metadata or may have stored them incorrectly. Also possible is that the metadata is correct but the player doesn't parse them correctly or at all depending on the container. This can lead to a difference in rendering, which you perceive as a change in quality.

Is there anything I should look for to become aware of when this may happen? Or is it just a trial and error approach where I try different containers with different players and see how it shows itself on playback? With the .mp4 format I notice the difference across multiple players and streaming sites for example. I'm just stuck cause I can't find information online to help me move forward, perhaps I'm using the wrong keywords. avi is well supported but has failed due to that 2gb limitation on many players. Mkv hasn't been working on streaming, i need a format that can fit a .wav and stream


text:
Can anyone recommend a good/safe free spectrum visualizer?
Something that can generate fairly nice displays for videos would be good. Can just be the generic type where it displays differing frequencies as bars, but something nicer than the harsh ffmpeg generated ones for example.
Wondering if there's something via a player like vlc I can use, i tried their built-in ones though alrdy and they were bad.
State if you do not have personal experience with the programs suggested.

This question might be suited for Software Recommendation SE but is unfortunately not on topic here for being a recommendation question and also not really production related.

So this forum is only for exporting your video then? I guess the lack of editing in the title would foreshadow that. When I hear video production I assumed every step in creating a video would be covered here. But this wasn't getting an answer anyways, so whatever.

If your question is about creating an audio spectrum animation for a video that is absolutely on topic here!
The way you worded your question it sounds like you are searching for a software that generates a live spectrum for you.
Which is debatable if its production related, most people asking for these kind of things are looking for a cool visualizer for their party.
If your purpose is to analyse your audio spectrum during recording that is f.e. absolutely on topic. In that case word your question as a "how to?" rather than "whats the best?" or "what is a good (...)?".

Well you seem to know that's exactly what I am seeking. its not worth debating tho. but for ex) if i ask 'how to'...it changes nothing. i can make one in ffmpeg eez and its bad quality but it answers the how to. im looking for subjective quality by default and that's the problem, if you want you can try to edit my question to fit ur standards...but that's subjective standards as well. theres no way to make my query fit the rules of the exchange without someone being able to take issue with it. But do what you want, i dont care...no answers anyways.

I get the frustration with that rule. I'm not their biggest fan either.

use elgato its pretty good
they make the stream deck

That actually worked okay.

Foobar2000
Is what I use for visualizations.


text:
ffmpeg operations yielding changing fps values
I have a video that was rendered as 26.51 fps h.264 into an mkv by my video editor. Calling the file up in ffmpeg it displayed this file as 1k fps, 26.51 tbr.
When I applied an operation to separate a 1 minute segment of this video into its own video I used
ffmpeg -ss 00:00:00 -i input.mkv -to 00:01:00 -c copy output.mkv

Calling the output up in ffmpeg showed this video as 27.4 fps, 26.51 tbr.
I then changed the container of this short 1 minute section in two independent operations:
ffmpeg -i input.mkv output.mkv

Displayed the fps as: 26.51fps, 26.51 tbr
ffmpeg -i input.mkv -c copy output.mkv

Displayed the fps as: 27.4fps, 27.4 tbr
I'm very confused, what exactly is going on here? I wanted all my videos fps to be 26.51fps. What do I go about doing to prevent this from happening in the future?
"tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate"
So my understanding from that definition is in the first video I "wanted to see" 26.51fps instead of 1k fps. Which is true. So something *first went wrong at this point that I need to fix?
Then from the second video I wanted to see 26.51fps instead of 27.4fps? Which is true.
Then from the third video my tbr and fps matched at 26.51. Wonderful!
The fourth video the fps and tbr matched at 27.4fps but I didn't want 27.4fps
And with the -c copy command above I'm guessing it forced the 27.4 fps value onto the video and that's why it became the new tbr and fps values. But this doesn't explain how in the top command where I yielded out my 1 minute partition of the original video, which also used -c copy, that it created a new fps value rather than use the 1k fps value of the original.
Edit: I see you can force the fps with -r 26.51; but this is requiring a re-encode, which I need to avoid. Is there something else I can do at one of the steps? I already rendered it with 26.51 as my fps to begin with afterall.

What the fps and tbr values indicate is the average and peak framerate detected within the file. When the container doesn't have valid metadata, either or both of these values can be wrong.
A tbr like 26.51 indicates a variable frame-rate file. After you extracted a segment with -c copy, ffmpeg will display the rates detected in the new clip. Since the source is VFR, the rate may not match but the individual frame timings won't have changed, and can't, since no frame operations can occur*.
When you transcoded instead, ffmpeg sets the output rate to the detected tbr and drops frames in regions with a greater framerate. (When saving to a constant rate muxer like MP4, it will clone frames if input rate is lower).
*true within this context

I don't understand how that explains the first case where it displays an average of 1k and a peak of 26.51. Or in another case I rendered with an fps of 500/21 fps from my vse. It's not supposed to render variable framerates only constant. Checking with ffmpeg showed 1k fps and 23.81 tbr. Checking average fps with ffprobe showed 500/21 tho. From the information I have I am inclined to believe the data is actually the right fps and playing fine but its thinking its not. Is there a way to try and force it to think the data is 500/21 fps so it doesn't change?

where it displays an average of 1k --> When the container doesn't have valid metadata, either or both of these values can be wrong.

Okay I see my mistake now. In terms of fixing the metadata, or re-assigning it to the values I had assigned them to be on render from my video editor, is there any fix to that? Of note: I've had many problems with matroska renders in the past in my vse always changing the fps render value to 1000fps, the vse uses ffmpeg to render although its more limited in its options and does not allow access to the commandline. When I updated the vse it started displaying the right fps and worked correct on playback, but...seems something is still bad. I'll file a bug report if there's nothing else to try


text:
Can anyone recommend any good guides to ffmpeg outside of the official manual?
I have a hard time reading and understanding the official ffmpeg manual due to the lack of full command line examples per sections. Sections are completely hit and miss for me based on whether they provide these examples. For example I can understand the wiki ffmpeg pages on certain things cause they generally go into alot of detail and give alot of examples I can do on my own and just tinker with the values.
Are there any third party guides people can recommend that are very example heavy? As I said I need to see all the commands in a full command line example, or at least an explicit example and then just the separate callup parts in full....like -vf "filter1withfulldetails_onsetting_up_eachsetting". Many I find seem to be outdated or limited...both video and text, cause the commands just don't work right even when I copypaste....or the settings seem to have been changed cause on the ffmpeg guide they are different setting names entirely in some cases. I need to see the modern commands that work alongside the explanations to understand things better.

I found this site by coincidence yesterday! It explains things in a bit more human readable format, perhaps.
https://amiaopensource.github.io/ffmprovisr/

This is really good. Do you know how up to date it is or if it's regularly updated? I'm reading it and some stuff like the codec defaults seems a bit off from what I'm getting, just curious how careful I need to be when viewing it.

Do you know how up to date it is  --> I don't think it is actively maintained. e.g. in this, the value max was changed to fill over a year ago.

It's actively added to: there was an addition within the last 24 hrs. The contributors are from the archival community with a wide breadth of experience: some beginners, some more knowledgeable. They are appreciative of any pull requests.

Official FFmpeg Help Resources

FFmpeg Documentation
FFmpeg Wiki
ffmpeg-user mailing list
#ffmpeg IRC channel on Freenode

Unofficial Help Resources

Stack Exchange sites: [video.se], [su], [so] - Might be easiest for you to just search/ask here.
Zeranoe Forum
r/ffmpeg
ffmpeg.tv - FFmpeg Basics Book. I haven't looked at it. A few users told me they liked it, but it is not free ($9.50 USD) and I'm not sure if it is kept up to date.

Already had a look through those unfortunately.

The ffmpeg manual doesn't do much holistic explanation. Rather the aim is to be comprehensive, although it falls short of that goal and which I aim to rectify over the next year. Part of the problem is that the docs are a broth formed by too many cooks. Consistency of form and style hasn't been set.

I do have plans for a holistic overview but I expect that to take at least a couple of months.

Even if there can just be specific examples added for the remaining filters or things that don't have them, that helps make things many times more readable for me anyways.


text:
ffmpeg: adding blankspace to end of video
I'm trying to add blankspace to the end of a video (1 audio stream, 1 video stream) using ffmpeg. I'm curious what the best way of doing this is. I'm not very keen on using filter_complex so if there's another simple/viable method, that would be good. I've been trying to use the color filter using the command below, it's making a video with bad timestamps though. On playback it freezes in various parts of the blankspaced segment, my command is missing something.
ffmpeg -i input.mkv -filter_complex "color=black:s=1280x720:d=15[b0];[0:v][b0]concat=n=2:v=1:a=0" output.mkv

I receive the green/yellow message below at the point where it starts to render the black frames.
[Parsed_color_0 @ 0000000922e0fd900] EOF timestamp not reliable

This method is effectively making another video and concatenating it to the first one. I'm wondering if in general: Can you create frames in an existing video...? Or is that outside of how ffmpeg works?

@llogan That would be great, pic posted. I also looked up tpad and tried: ffmpeg -i testvid.mkv -vf tpad=start=360:color=0xF0F8FF out.mkv But it said "No such filter: 'tpad'". Guessing I'm doing that one wrong too.

It's always better to copy and paste the log, since it's text anyway, instead of making a screenshot. It makes answering easier.

Method 1: concat demuxer

Pros: Avoids re-encoding the main video and therefore preserves quality since it is stream copied. Fast.
Cons: Requires several steps. Harder to get right, because the blank video needs to have the same attributes as the main video.

Make the black video using same attributes and same number and type of streams as the main input. This example makes a 15 second black video, frame rate of 24, size is 1280x720:
 ffmpeg -f lavfi -i color=c=black:s=1280x720:r=24:d=15 black.mkv

Make input.txt. The order in this text file determines the order that they will appear when concatenating.
file 'main.mkv'
file 'black.mkv'

Concatenate:
ffmpeg -f concat -i input.txt -c copy output.mkv

Method 2: concat filter

Pro: Can all be done in one command.
Con: Filtering requires encoding, so no stream copying of the main video as in the concat demuxer. Some attributes must still be matched.

Use the color source filter to make the 15 second, 24 fps, 1280x720 black video and append it to the end of the main video with the concat filter:
ffmpeg -i main.mkv -filter_complex "color=c=black:s=1280x720:r=24:d=15[black];[0:v][black]concat=n=2:v=1:a=0[v]" -map "[v]" output.mkv

If you prefer the black to be at the beginning instead then switch the order for the concat filter inputs, such as [black][0:v]concat….

Method 3: tpad and apad filters

Pro: Easy. No need to match any attributes.
Cons: Filtering requires encoding, so no stream copying of the main video as in the concat demuxer. Relatively new filters: use FFmpeg 4.2 or newer, or even better use a build from the current git master branch.

Append 15 seconds of black video to the end of the main video:
ffmpeg -i main.mkv -filter_complex "tpad=stop_duration=15" output.mkv

If you want it at the beginning instead use start_duration instead of stop_duration. If you want to clone the frames instead, or want a different color than black then refer to the tpad filter documentation.

This helps significantly, just 3 issues: (1) Why is there the 'c' in "color=c=black"? Is there a difference vs using "color=black" (seemed the same when tried)? In 14.8 of the docs it lists titles of sections as "color,c" and "duration,d". Doesn't this mean d and duration are interchangeable cmds? Then why does "c=black" give an error? (2) What does 'pad' in "pad video frames" mean? (3) Does ffmpeg not have a way to add frames to an existing video in a 'single' simplified cmd? I was hoping to re-encode like 'method 2', but to create 'new frames', I can't afford to overwrite existing frames.

@kite 1) It is recommended to include the option name with the value instead of just the value; especially when many other options are being declared. It makes things less ambiguous and you know what you're going to get. c is a shortened alias for the color option in the color filter. Same with d and duration as you mentioned. c=black gives an error (probably No such filter: 'c') because you are telling it that c is the filter name, but there is no filter named c. Order is like this: filterA=option1=value1:option2=value2,filterB=optionB1=valueB1:optionB2=valueB2.

@kite 2) "pad" just means to extend, fill, or add. For example, take a 5 second input and extend/fill/add/pad it with black frames at the beginning and/or end to make it 8 seconds. In a way it's similar to padding in CSS if you're familiar with that element.
3) Both methods #2 and #3 are single commands, and method #3 is fairly simple. Neither method is overwriting any frames. They are just creating new frames and adding to them the end (and/or beginning if you prefer) of the main input.

Apologies for my confusion, I misread the video durations and made the wrong assumptions. One final Q: For a movie with [0:0]video+[0:1]audio stream, for method 3 using tpad: adding an "apad=pad_dur=10" worked fine. Of interest though: The docs said you could use -shortest to extend audio streams to the same length as the video stream. Upon trying -filter_complex "tpad=stop_duration=15;apad" -shortest it seems to render an infinitely long video out. I tried writing it like [0:1]apad but no difference either. My intent was to use -shortest to avoid writing out the pad_dur=10 part.

@kite IIRC, that's a known bug.

@llogan thank you, your post was the most information I could find about this everywhere! Unfortunately being a complete newb I need some help. 2 Questions;
A) I tried method 1, and the end result was just the non black video, I think I matched the properties, is there a command I can run to check if I did?

B) I also tried method 3 with success! But I wanted to do a variation but failed. I tried cutting from a file and adding the pad. ffmpeg -ss 100 -i "input.mp4" -to 32 -vf "tpad=start_duration=10" "output.mp4"this works, sort of.. It adds 10 seconds at the beginning but doesn't pad it just overwrites the first 10 seconds, and doing it with stop_duration doesn't do nothing, the result is only the cut video. What can I do to achieve the result I want?


text:
ffmpeg: crop then scale does not work
I want to crop black border, then scale to video to 1280x720, however, the following command does not work，crop works well, but scale has no effect:
ffmpeg -i input.mp4 -filter_complex '[0:v]crop=1424:720:0:40[c0];[c0]scale=1280:720[bg]' -map '[bg]' -map 0:a -pix_fmt yuv420p output.mp4

The scale filter adjusts the aspect ratio, so that the display ratio remains the same. Assuming you don't want that.
Use
ffmpeg -i input.mp4 -vf crop=1424:720:0:40,scale=1280:720,setsar=1 -c:a copy output.mp4

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Premiere: Make clips from extracts of same clip
I am dealing with long clips inside which I have several different moments I want to use.
So when logging, I create multiple sequences I use as folders, and I put extracts (i/o) of these clips in the timelines. Then, before starting to edit, I have a master sequence and several others with all my i/o extracts I copy/paste in the master (instead of dragging clips to the timeline).
Is there any way I could have all these extracts (of all clips) displayed as clip icon view, like registering multiple extracts of same clips as one clip, so I could use the Icon View?
Hope I'm clear!
Thanks!

You can create subclips of the sequences in the source material that you want to use seperately. This will create a second instance of the source material in the Project Panel that is limited to a specific part of the source. A subclip is sort of a virtual copy of the original clip (the source material on the disk is not copied).
To create a subclip, you first have to set In- and Out-Points. The subclip will use those as boundaries, so only the part between them will be available in the subclip.
You can set In- and Out-Points at the current playhead position using the I- and O-keys. After you have set those points for the active clip in the Source Panel, right-click on the clip in the Project Panel and select Make Subclip. You can then set a name for the subclip, after that it's available in the Project Panel.
You can also edit your subclips after you created them, which is useful if you realize you need a longer part of the sequence after you created the subclip. The Edit Subclip option is available from the context menu as well, you can shift the start/end timecodes of the supclip this way. There's also an option to restrict the sequence to the subclip's boundaries, which is active by default, you might want to turn it off depending on your workflow.

Brilliant! I searched for sub-clips, but for any reason what I found then did not fit that much what I needed. Thank you very much for all the details!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How did ILM create the hyperspace tunnel effect?
In Star Wars: A New Hope, right before the Millennium Falcon exits hyperspace, we see a "tunnel" through which the ship is traveling:

How did ILM create this effect in 1976?

NOTE: I am not referring to the "stretching star lines" effect shown when a ship enters or exits hyperspace as detailed by John Dykstra in a 1978 interview with the Fantasy Film Journal. I am specifically referring to the blue tunnel effect seen while the ship is still in hyperspace.

Nice question. However, the quality of the gif is hell. Can you provide one frame in good quality at least?

I'm not entirely sure if this method was used in this particular shot, but you might wanna have a look at the slit-scan method https://en.m.wikipedia.org/wiki/Slit-scan_photography

Although it looks like a slit-scan effect similar to the Tom Baker era Dr. Who titles, in this case, the effect was very simply made with mylar - a reflective plastic.  Due to time and budget constraints, there wasn't much they could do, so they made a tunnel out of mylar and flew the camera through it.  They apparently had a lot of mylar left from making the reflective background behind the starfield.

Welcome! Paraphrasing: surplus is the parent of special effects.

Thanks for the answer!! If you update it with a source, I'll mark it as the accepted answer.


text:
How to send stream to server without any compression?
How to send stream to server without any compression (output should be exactly the same as the video stream being sent)?
ffmpeg doesn't seem to be able to do that. It always lose something (based on filesize and ffprobe output). Is there any alternative?
This question is asking for alternative to ffmpeg that may do the job more easily than ffmpeg.

what ffmpeg options are you using? Please post the commmand line and results

@stib https://video.stackexchange.com/questions/23778/how-to-use-ffmpeg-to-send-video-stream-to-another-server-that-gives-exactly-same

It would be better to edit that post to clarify what you want than posting essentially the same question again.

@stib the question is different. edited

Any video you plan to stream from a host machine to another endpoint, or multiple endpoints, will have to be encoded. The question is what is your source? Are you streaming a live video feed? If so, in order to stream uncompressed you’d first have to have your capture setup to injest the video as an uncompressed format, 4:4:4. Even with just 1080, you are talking huge amounts of data.
For uncompressed, to stream over the internet, youre going to need a serious rock solid network uplink... 1000mbps up or greater depending on the frame size.

why does that matter? I understand that it is going to be a huge data, but I just want to know how I can do this. And if I cannot support it, I will compress it.


text:
How to use ffmpeg to send video stream to another server that gives exactly same quality as manually copying the file to that server?
I tried doing this
ffmpeg -i tcp://192.168.1.41:5000?listen -c copy out.avi

and have another client publish to this server using
ffmpeg -i 1.avi -map 0 -c copy -f mjpeg tcp://192.168.1.41:5000

However, the ffprobe results I get for these two files are
Invalid return value 0 for stream protocol
    Last message repeated 1 times
Input #0, avi, from 'out2.avi':
  Metadata:
    encoder         : Lavf57.83.100
  Duration: 00:00:08.04, start: 0.000000, bitrate: 31181 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 2048x1536, 31321 kb/s, 50 fps, 50 tbr, 50 tbn, 50 tbc

and
[mjpeg @ 0x177aea0] Changeing bps to 8
Input #0, avi, from '1.avi':
  Metadata:
    encoder         : Lavf54.20.4
  Duration: 00:00:40.20, start: 0.000000, bitrate: 6235 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 2048x1536, 6264 kb/s, 5 fps, 5 tbr, 5 tbn, 5 tbc

Although the file size is the same, I am not sure if they are still the same. Based on the output, it seems not. Can I know why?
What should be the command to send exact same stream to a remote server?
Update with the suggestion from @Mulvya
The output of using -f nut is as follows, which I don't quite understand why:
Invalid return value 0 for stream protocol
    Last message repeated 1 times
[nut @ 0x55cdee5959c0] No main startcode found.
tcp://192.168.1.41:5000?listen: Invalid data found when processing input

Are these interlaced images?

I am not sure what interlaced images mean. The original video is produced using opencv by adding new frame one by one.

mjpeg is a raw stream, so ffmpeg has to assign a framerate if one isn't manually supplied. Default fps is 25 but yours shows as 50. Which may happen if at the receiving end, ffmpeg thinks there are two frames in a packet. Usually, those would be pair of interlaced pictures.

@Mulvya is there a way to make the fps the same? e.g. a command that cos everything to be copied exactly.

Don't stream a raw stream i.e. use -f nut tcp://192.168.1.41:5000 in 2nd command.

only -c copy will at least give same size of files but different ffprobe output @Mulvya

Why do you want to obtain exactly the original file by streaming?

@aleb Actually I just need exactly same quality. However, I am not sure how I should gauge the same quality other than file size? Previously, I thought -crf 0 means best quality but how it is bigger than the original file by many factors which doesnt make sense. Why is it much bigger and yet the quality is not better? (Not better because you can't have a converted file that is higher quality than the original file)

@aleb Are you implying streaming has to lose some quality?

Just to make sure it's not the container, try with -f avi

Check whether it's the same quality by doing something like ffmpeg -i IN -c:v copy OUT.mkv for both the source and the copy, and compare that.


text:
Why video call has no latency, but no matter what options of ffmpeg I tried to transmit video, the lowest I can get is ~0.2s latency?
Why video call has no (even if there is, it is lower than human perception can discern) latency,  but no matter what options of ffmpeg I tried to transmit video to a remote server, the lowest I can get is ~0.2s latency (estimated, not sure how to profile)?
What is the technology behind video call that allows it to be much faster than ffmpeg?
I tried sending to the server and make the server send back the stream using the following commands:
CLIENT:
termimal 1-
ffmpeg -pixel_format mjpeg -s hd720 -r 30 -i /dev/video1 -c libx264 -preset ultrafast -tune zerolatency -crf 18 -b 5M -f matroska -vf hflip tcp://X:5000

termimal 2-
mplayer -benchmark ffmpeg://tcp://Y:5000?listen

SERVER:
ffmpeg -i tcp://X:5000 -c copy -f matroska tcp://Y:5000

However, the video I got back has a slight delay of about 0.5s (estimated, not sure how to profile). Is sending to and fro different that causes it to have longer delay?

Try skipping format probe in server cmd: ffmpeg -f matroska -i tcp://X:5000 -c copy -f matroska tcp://Y:5000

What software is your video call made with, and who are you calling? Recipient on server X, I assume?

@Gyan same latency

@TonySepia facetime between mac

Have you looked at using RTP with ffmpeg? FaceTIme appears to use it. Check here: https://en.wikipedia.org/wiki/FaceTime

@TonySepia is tcp slower than rtp? isn't rtp also using tcp behind the scene?

@user136266 I would Google first, seriously! https://stackoverflow.com/questions/361943/why-does-rtp-use-udp-instead-of-tcp

It should be noted that UDP is not actually a requirement for low-latency streams. For example, the NDI protocol from Newtek is based on TCP and it is able to transmit 1080p60 video over a local network with less than a frame of latency

Try using UDP. It should be faster than TCP but with possibility of losing paackets.

Sources of any delays:

TCP protocol. Long handshake, possible error with time loss in future
Long encoder initialization (video call already prepared it)
Long decoder initialization (video call already prepared it), buffering for analyze data
Unoptimized protocol / format for low-time communication, like MKV
Prebuffering in encoder for B-frames and other optimizations

Video conferencing software also have many tricks to detect delays and resync streams. It why in video conferencing has frame drops and it not suitable for transmitting high quality video.


text:
Use markers in After Effects as triggers for a particular animation
I have a one precomp animations (from stocks). And I am searching for a script /expression that will automate a certain animation for my project.
I have a long videos with premade subtitles srt file and I want to use subtitles timestamps  (not a subtitle text content!) convert them to markers an link that one animation precomp to each and every starting marker on a specific AE layer. Finally I wanto to trigger an animation precomp by starting markers of on a layer.
Suppose I have 3 hour video with 30 captions in a one .srt file.
I import a video then I import .srt file via pt_importsubtitles (it will convert stamps to markers) and I will have a video already in sync with 30 imported markers on a АЕ layer from a one .srt file.
Importantly, I do not interested of any imported text captions (although it will be good if text will be imported to marker's comment field) but only thing I am interested is (markers) timstamps of a srt file.
I want to buy a script that will link a precomp to bunch of (timestamps) markers.
Only thing i found is this video

Any help for a complete dummy in AE?

What was wrong with what the video described?

A tool is found Duik > animation blender (suggested by  Аркадий Чумаков) but I I can not get it work with animated icons from videohive.

Markers are a special time of key, basically you can think of them as keys on a property of the layer called "marker", just like you can use keys on say, the position property. To access a marker on a layer you use
var myMarker = marker.key(n)

where n is the number of the key you want (counting from 1, not zero. WTF Adobe?) or alternatively:
var myMarker = marker.nearestKey(time)

Which will give you the nearest key, which can be ahead of or behind the current time.
Once you have the markerKey object you can get its time, duration, index (useful if you used the nearestKey method), and all of the metadata that can be stored in markers (quite a lot). Details about all the marker properties here. For example, if your marker has a comment, you can get the text of the comment thus
var myMarker = marker.key(n);
var theComment = myMarker.comment;

You can access comp markers too, just use
var myMarker = thisComp.marker.key(n); //or
var myOtherMarker = thisCom.marker.nearestKey(time);

Hello
Expressions is little bit advanced for me. Sorry
Аркадий Чумаков suggested me "animation blender" in Duik 16
It works (trigger an animation by marker) but it works for now inside one comp and shape layer within it.
When I pick an animation from VideoHive (icon) nothing happens.

Check out Marker Remap at www.aescripts.com/marker-remap . It takes the principles from the video you reference above and adds a powerful After Effects panel to control marker additions and timing.

It can be used for my purposes ? Trigger an imported animation (precomp) from stocks (titles or icons animations) by starting markers (foremerly (starting) time stamps in Subtitle Edit) on a layer ?

In a small touch of self-advertising, I'd like to refer to the free script MarkerTriggery for AE. It brings a neat UI you can control your markers from, and you don't need to know anything about expressions to use it.

What about importing timestamps from subtitle .srt file and convert starting stamps to MarkerTrigger ?
I have one icon animation precomp and I have to link it to multiple markers on a timeline layer.
It is possible to do it without manual work and minimum expressions writing ?

Hey Cloddo, that’s a great idea that I totally never thought about. I’ll look into that. It’s definitely not supported in the script, but I might look into it in the future and get back to you here.

I hope my Stackexchange question will be finally solved after a year. I used to use pt_importsubtitles for converting srt timstams to markers and intrestingly text content of subtitles will go into marker comment field (Hope you will have that feature). But then I was unaible to link a one precomp animation to all (starting) markers on a layer. I hope your plugin will handle that soon even if MarkerTrigger will be payed. Ready to support it. Thank you very much.

Hey Simon Heimbuchner, any news ?


text:
How can I downsample video to rgb24 with dithering in ffmpeg?
Setting -pix_fmt to a yuv colorspace will use Bayer dithering by default. I don't know how to change that behaviour.
When downsampling with -pix_fmt to an RGB colorspace like rgb24, no dithering is applied, resulting in ugly banding.
Edit:
I figured out how to control dithering to YUV colorspace. My issue was just that I misunderstood the ffmpeg filter syntax regarding format. It's not handled as a filter, but just tells the preceding filter what format to output:
-vf zscale:r=tv:d=error_diffusion,format=yuv420p

The issue is, zscale seems to be unable to dither at all when downsampling to RGB colorspace. 4 bpc RGB seems to be the exception, where ordered dithering is enforced. And I am unable to control dithering with the scale/swscale filter at all, using a global flag -sws_dither ed does not work.
colorspace filter can not output to RGB format.

Share full command and log.

@Gyan full command: ffmpeg -i <infile> -pix_fmt bgr0 -vcodec ffv1 -level 3 -threads 16 -coder 1 -context 1 -slices 24 -slicecrc 1 <outfile>
Whether the input file is 10-bit YUV or 10-bit RGB does not matter, dithering is never applied when downsampling to an RGB colorspace.


text:
How to Create Compatible AVC Video for Muxing Without Re-encode
I want to encode a video that will be compatible with videos created by my phone. That way I can mux the new video with the original without re-encoding the original video. I use FFmpeg with the libx264 encoder. The following are the MediaInfo specs of the original video created by my phone:
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Baseline@L3.1
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, Reference frames        : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 52 s 369 ms
Bit rate                                 : 10.0 Mb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 30.000 FPS
Minimum frame rate                       : 29.625 FPS
Maximum frame rate                       : 30.405 FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.362
Stream size                              : 62.4 MiB (98%)
Title                                    : VideoHandle
Language                                 : English
Encoded date                             : UTC 2020-10-27 19:43:55
Tagged date                              : UTC 2020-10-27 19:43:55
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
transfer_characteristics_Original        : BT.601
Matrix coefficients                      : BT.709
mdhd_Duration                            : 52369
Codec configuration box                  : avcC

So far, I have figured out the following, which I think has gotten me close:
ffmpeg -i in.mp4 -c:v libx264 -profile:v baseline -level:v 3.1 -refs 1 \
  -vsync 2 -filter:v scale="-1:720",pad="1280:720:720/2+ow/2",format="yuv420p" \
  -x264-params keyint="30":scenecut="0" -c:a copy out.mp4

I'm having trouble setting frame rate. It should be variable @ 30 fps. I found this question in regards to variable frame rate. But it has no answer. Setting -minrate & -maxrate does not help. The output is constant frame rate @ 30 FPS. Parameter examples follow.

Outputs constant rate @ 30 fps:
-vsync 2 -r 30 -minrate 29.625 -maxrate 30.405

Outputs variable rate @ 29.970:
-vsync 2 -r 30.405

I also believe that I should be using -crf or -qp, but am not sure of the correct value(s).
Edit:
The command shown above results in the following specs:
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Baseline@L3.1
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, Reference frames        : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 8 s 700 ms
Duration_FirstFrame                      : 33 ms
Bit rate                                 : 2 606 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.094
Stream size                              : 2.69 MiB (95%)
Title                                    : VideoHandle
Writing library                          : x264 core 160
Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=30 / keyint_min=3 / scenecut=0 / intra_refresh=0 / rc_lookahead=30 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language                                 : English
Codec configuration box                  : avcC

Is there anything else shown here that isn't compatible with the original video?

Sources that helped me:

setting GOP size
x264 FFmpeg Options Guide

Edit (2020-11-6 23:40 UTC):
After reading Gyan's answer, I used the -video_track_timescale parameter to set a tbn value to match the original video. But the concatenated video still does not display correctly. Did I miss something that should be matching? I'm looking over the ffprobe output now.
Original video:
$ ffprobe -hide_banner -i VID_20201027_124301.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20201027_124301.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2020-10-27T19:43:55.000000Z
    location        : +42.5418-122.5700/
    location-eng    : +42.5418-122.5700/
    com.android.version: 7.1.2
  Duration: 00:00:52.40, start: 0.000000, bitrate: 10187 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/smpte170m), 1280x720, 10002 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2020-10-27T19:43:55.000000Z
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2020-10-27T19:43:55.000000Z
      handler_name    : SoundHandle

FFmpeg encoded video:
$ ffprobe -hide_banner -i VID_20201027_124914-encoded.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20201027_124914-encoded.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:08.70, start: 0.000000, bitrate: 2732 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2596 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandle

Edit (2020-11-7 00:05 UTC):
Did some more testing & found that when I concatenate the video using FFmpeg, it works. But if I concatenate using a different muxer, like Avidemux or MKVToolNix, it does not. I think this question has been answered by Gyan, but I'm going to keep it open just a little longer to see if there is any input on why the video does not work with the other muxers as I prefer to use those.
Ultimate ffmpeg parameters used:
ffmpeg -i in.mp4 -c:v libx264 -profile:v baseline -level:v 3.1 \
  -refs 1 -r 30 -video_track_timescale 90k \
  -filter:v scale="-1:720",pad="1280:720:720/2+ow/2",format="yuv420p" \
  -x264-params keyint="30":scenecut="0" -c:a copy out.mp4

the keyint & scenecut params of -x264-params & framerate aren't required
Edit:
Created question about concatenation not working with Avidemux & MKVToolNix here.

To concatenate multiple files for expected playback in common players, following properties need to match for
video: codec, codec profile, codec level, resolution, reference count, pixel format, timebase/timescale.
audio: codec, codec profile, channel count & layout, sample format and sampling rate.
Advanced players can tolerate mid-stream changes in some of the above parameters.
Mediainfo won't show you timescale, it's the tbn value as shown by ffmpeg for the stream. Framerates need not match nor be constant for any given constituent stream. GOP size or keyframe cadence need not match. Neither need bitrate value or mode (CRF, VBR..etc) match. minrate and maxrate clamp bitrate, not framerate.

Okay, ffmpeg shows 30 fps, 30 tbr, 90k tbn, 180k tbc for the video produced by my phone. I used -video_track_timescale 90k option & the output video shows 29.89 fps, 30 tbr, 90k tbn, 60 tbc. But concatenated video still not displaying correctly in VLC nor MPlayer. Everything else you outlined matches. Does tbc need to match as well?

I updated my question to show the ffprobe output of the two videos.

New info: After following your answer, concatenating with FFmpeg works. Thank you. However, if I use a different utility to mux, such as Avidemux or MKVToolNix, the concatenated video does not display correctly. Any idea of why this might be?

Created new question for this.

Is codec level still true? I was able to use the concat demuxer to concat two videos that everything matched for except the codec level (and SAR/DAR).

Strictly speaking, to avoid failing with hardware-constrained decoders, the level and profile of further files should not exceed those of the first file.


text:
FFmpeg: Align Video & Audio of Desktop Capture
I am using FFmpeg's built-in gdigrab & dshow to record the display & audio of my system. I am encoding to uncompressed H.264/AVC video & uncompressed PCM/WAV audio.
I had been having two problems with audio/video synchronization:

Video & audio not aligned (video & audio do not start at same time).
Audio drift (audio progressively becomes out of sync with video).

Originally I was using a single command for capture/encode. Something like the following:
ffmpeg -hide_banner -rtbufsize 1000M -f gdigrab -framerate 60 -draw_mouse 0 \
  -i "title=<window_name>" -f dshow -i audio="<sys_audio/mic>" -c:v libx264 \
  -preset ultrafast -qp 0 -x264opts keyint=1 -c:a pcm_s16le -ac 1 "<out_file>.mkv"

But I was able to solve my second problem (drifting) by capturing video & audio in separate FFmpeg processes. Note that I am using a UNIX-like shell (MSYS2 with BASH). The following is an example of a shell script I am running:
# capture audio & get PID
ffmpeg -hide_banner -rtbufsize 500M -f dshow -i audio="<sys_audio/mic>" \
  -c:a pcm_s16le -ac 1 "<out_file>-audio.wav" & APID=$!

# capture video
ffmpeg -hide_banner -rtbufsize 1000M -f gdigrab -framerate 60 -draw_mouse 0 \
  -i "<window_name>" -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint=1 \
  "<out_file>-video.mkv"

# get exit code of video process
VIDRET=$?

# send interrupt signal to audio process after video process exits
kill -s SIGINT ${APID}

# mux video & audio if video process exited okay
if [ "${VIDRET}" -eq "0" ]; then
    ffmpeg -hide_banner -i "${OUTVID}" -i "${OUTAUD}" -map 0:0 -map 1:0 \
      -c copy "<out_file>.mkv"

    # delete temp video & audio streams if muxing succeeded
    if [ "$?" -eq "0" ]; then
        rm "${OUTVID}" "${OUTAUD}"
    fi
fi

So the problem left is that video & audio data do not start aligned correctly. The audio is generally somewhere between 0ms-300ms ahead of the video.
It can be easily solved by running the output file through FFmpeg again, or a separate program such as Avidemux, to adjust the audio delay. This can be done without re-encoding in Avidemux (not sure about FFmpeg).
However, I would prefer to solve this issue within the capture process/script so I can avoid the extra step of aligning the data manually.
Recently I have done a system cleanup by removing junk files, making sure fragmentation on my drive is low, & turning off unnecessary background processes. But audio/video alignment is still often off.
So finally, to the plain-&-simple question: Is there a way to get the two FFmpeg processes to begin capture at the same time to get video & audio as close to being synchronized as possible? Can I use the system clock as a seed?
Or, is there a better method than I am using right now? E.g., a single FFmpeg process that will capture both while keeping data aligned & avoiding audio drift.
It appears to me that the problem is simply that the audio process is starting before the video process. I've heard about piping FFmpeg commands, but am not sure of the correct way to do it. I have found some information on piping that I am trying to figure out:

https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Pipedprocesses
https://superuser.com/questions/1057388/pipe-ffmpeg-output-to-other-process

FFmpeg information: Official static 64-bit build from Zeranoe.
ffmpeg version N-92511-g0279cb4f69 Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 8.2.1 (GCC) 20181017
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig
        --enable-gnutls --enable-iconv --enable-libass --enable-libbluray
        --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb
        --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine
        --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame
        --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264
        --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
        --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
        --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
        --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va
        --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth

These are my system specs:

Model: HP Pavilion 24-b217c
OS: Windows 10 64-bit
CPU: Intel Core i5-7400T @ 2.40GHz, 2401 MHz, 4 cores
RAM: 12GB
GPU(s):

nVidia GeForce 930MX

RAM: 2GB dedicated

Intel HD Graphics 630

-- Edit --
I did figure out a pipe command, but the result is the same. Audio is slightly ahead:
ffmpeg -hide_banner -rtbufsize 500M -f dshow -ac 1 -i audio="<sys_audio/mic>" \
  -c:a pcm_s16le -f s16le pipe: | ffmpeg -y -hide_banner -rtbufsize 1500M -f gdigrab \
  -thread_queue_size 128 -framerate 60 -draw_mouse 0 -i title="<window_name>" -f s16le \
  -thread_queue_size 128 -i pipe: -map 0:0 -map 1:0 -c:v libx264 -preset ultrafast -qp 0 \
  -x264opts keyint=1 -c:a copy "<out_file>.mkv"

If it is Windows then why not to use dshow instead of gdigrab?
Please look at the
https://github.com/rdp/screen-capture-recorder-to-video-windows-free
If both video and audio would be via dshow then you could use ffmpeg like this:
ffmpeg -f dshow -i video="VIDEO_DEVICE":audio="FIRST_AUDIO_DEVICE" -f dshow -i audio="ANOTHER_AUDIO_DEVICE" ...

After doing what you describe with separate files for a while, I recently started using embedded streams instead. It's late and I'm tired, but you should be able to see how it works, and I can elaborate later if you need me to.
using separate output files, just so you can see how I have that set up...for reference.
ffmpeg -hide_banner \
    -re \
    $videoDecodeMode \
    -f pulse \
        -i $audioOut \
    -f pulse \
        -i $audioMic \
    -f x11grab \
        -r $frameRate \
        -s $resolution \
        -i :0.0 \
        -g 60 \
    $videoEncodeMode \
    -map 2:0 \
        -metadata handler="video:1920x1080@60" \
        "${exportName}" \
    -map 0:0 \
        -metadata title="audio:out" \
        "${exportName%.*}_audioOut.wav" \
    -map 1:0 \
        -metadata title="audio:microphone" \
        "${exportName%.*}_audioMic.wav" </dev/null &

using embedded streams
ffmpeg -hide_banner \
    -re \
    $videoDecodeMode \
    -f pulse \
        -thread_queue_size 1024 \
        -i $audioOut \
    -f pulse \
        -thread_queue_size 1024 \
        -i $audioMic \
    -f x11grab \
        -r $frameRate \
        -s $resolution \
        -thread_queue_size 1024 \
        -i :0.0 \
    -g 60 \
    -map 2:v \
    -map 0:a \
    -map 1:a \
    -c:a aac -ac 2 -b:a 128k -r:a 48000 \
    -metadata:s:v:0 handler="video:1920x1080@60" \
    -metadata:s:a:2 handler="audio:out" \
    -metadata:s:a:3 handler="audio:microphone" \
    $videoEncodeMode \
    "${exportName}"  </dev/null &

embedded streams, companded mic to clean up my line-noise problem a bit, and some stream mixing to put output and mic together on their own stream
ffmpeg -hide_banner \
    -re \
    $videoDecodeMode \
    -f pulse \
        -thread_queue_size 1024 \
        -i $audioOut \
    -f pulse \
        -thread_queue_size 1024 \
        -i $audioMic \
    -f x11grab \
        -r $frameRate \
        -s $resolution \
        -thread_queue_size 1024 \
        -i :0.0 \
    -g 60 \
    -filter_complex \
        "[1:a]aformat=channel_layouts=stereo,asplit=2[micOrig][micNew]\
        ;[micNew]\
            compand=0:0.2:-26/-900|-16/-16|0/-10|10/-900:6:0:0:0\
        [micCleaned]\
        ;[0:a][micCleaned]amix=inputs=2:duration=first[allAudio]" \
    -map 2:v -map 0:a \
    -map [allAudio] -map [micOrig] \
    -c:a aac -ac 2 -b:a 128k -r:a 48000 \
    -metadata:s:v:0 handler="video:1920x1080@60" \
    -metadata:s:a:2 handler="audio:out" \
    -metadata:s:a:1 handler="audio:combined" \
    -metadata:s:a:3 handler="audio:microphone" \
    $videoEncodeMode \
    "${exportName}"  </dev/null &


text:
Desktop Capture Has Become Choppy/Jerky with FFmpeg
Recently, videos produced by capturing a window on my system using FFmpeg have become choppy/jerky, as if frames have been dropped or duplicated. FFmpeg will sometimes report that a number of frames were dropped when recording began, but not throughout the video. Videos I had recorded a few months ago did not suffer from this. Encoding speed reports to be between 1.0x & 0.996x.
I suspected that the problem might have to do with system performance related to the hard drive. So I cleaned up junk files on my system & defragmented the drive. But the resulting video output did not change.
Reading through this thread, one user recomends recording at 30 fps instead of 60. But I had no problem recording at 60 before.
The dimensions of the window I am recording are 512x448. I record the audio & video in separate FFmpeg processes (this prevents audio drift).
The following is an example portion of a script I use for recording:
ffmpeg -hide_banner -rtbufsize 500M -thread_queue_size 512 -f dshow -ac 1 -i audio="<audio_device>" -c:a pcm_s16le audio-tmp.wav & APID=$!

ffmpeg -hide_banner -rtbufsize 1500M -thread_queue_size 512 -f gdigrab -framerate 60 -i title="<window_name>" -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" video-tmp.mkv

The entire script can be found here.
System specs:

HP Pavilion 24-b217c
CPU: Intel Core i5-7400T

2.4GHz
4 cores

RAM: 12GB
GPU (hybrid):

NVIDIA GeForce 930MX
2GB dedicated RAM
Intel HD Graphics 630

Edit: Here is the video output from the terminal:
Input #0, gdigrab, from 'title=Mega Man Unlimited':
  Duration: N/A, start: 1550055137.876177, bitrate: 440427 kb/s
    Stream #0:0: Video: bmp, bgra, 512x448, 440427 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001d2881a15c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001d2881a15c0] profile High 4:4:4 Intra, level 3.1, 4:4:4, 8-bit
[libx264 @ 000001d2881a15c0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-video.mkv':
  Metadata:
    encoder         : Lavf58.26.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 512x448, q=-1--1, 60 fps, 1k tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.47.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=14587 fps= 60 q=-1.0 Lsize= 1625062kB time=00:04:03.13 bitrate=54753.8kbits/s speed=   1x
video:1624328kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.045149%
[libx264 @ 000001d2881a15c0] frame I:14587 Avg QP: 0.00  size:114027
[libx264 @ 000001d2881a15c0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 000001d2881a15c0] coded y,u,v intra: 46.0% 44.6% 44.6%
[libx264 @ 000001d2881a15c0] i16 v,h,dc,p: 77% 23%  0%  0%
[libx264 @ 000001d2881a15c0] kb/s:54725.45

And here is some of the audio output (output to file):
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, dshow, from 'audio=Stereo Mix (Realtek High Definition Audio)':
  Duration: N/A, start: 11732.800000, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-audio.wav':
  Metadata:
    ISFT            : Lavf58.26.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
    Metadata:
      encoder         : Lavc58.47.100 pcm_s16le
size=       0kB time=00:00:01.01 bitrate=   0.6kbits/s speed=   2x
size=       0kB time=00:00:01.51 bitrate=   0.4kbits/s speed= 1.5x
size=       0kB time=00:00:02.01 bitrate=   0.3kbits/s speed=1.33x
size=       0kB time=00:00:02.51 bitrate=   0.2kbits/s speed=1.25x
size=     256kB time=00:00:03.01 bitrate= 696.7kbits/s speed= 1.2x
size=     256kB time=00:00:03.51 bitrate= 597.7kbits/s speed=1.16x
size=     256kB time=00:00:04.01 bitrate= 523.0kbits/s speed=1.14x
size=     256kB time=00:00:04.51 bitrate= 465.1kbits/s speed=1.12x
size=     256kB time=00:00:05.01 bitrate= 418.6kbits/s speed= 1.1x
size=     256kB time=00:00:05.51 bitrate= 380.7kbits/s speed=1.09x
size=     512kB time=00:00:06.01 bitrate= 697.9kbits/s speed=1.09x
size=     512kB time=00:00:06.51 bitrate= 644.3kbits/s speed=1.08x
size=     512kB time=00:00:07.01 bitrate= 598.3kbits/s speed=1.07x
...
...
size=   20224kB time=00:03:55.01 bitrate= 705.0kbits/s speed=   1x
size=   20224kB time=00:03:55.51 bitrate= 703.5kbits/s speed=   1x
size=   20224kB time=00:03:56.01 bitrate= 702.0kbits/s speed=   1x
size=   20224kB time=00:03:56.51 bitrate= 700.5kbits/s speed=   1x
size=   20224kB time=00:03:57.01 bitrate= 699.0kbits/s speed=   1x
size=   20224kB time=00:03:57.51 bitrate= 697.5kbits/s speed=   1x
size=   20480kB time=00:03:58.01 bitrate= 704.9kbits/s speed=   1x
size=   20480kB time=00:03:58.51 bitrate= 703.4kbits/s speed=   1x
size=   20480kB time=00:03:59.01 bitrate= 701.9kbits/s speed=   1x
size=   20480kB time=00:04:00.01 bitrate= 699.0kbits/s speed=   1x
size=   20480kB time=00:04:00.51 bitrate= 697.6kbits/s speed=   1x
size=   20736kB time=00:04:01.01 bitrate= 704.8kbits/s speed=   1x
size=   20736kB time=00:04:01.51 bitrate= 703.4kbits/s speed=   1x
size=   20736kB time=00:04:02.01 bitrate= 701.9kbits/s speed=   1x
size=   20736kB time=00:04:02.51 bitrate= 700.5kbits/s speed=   1x

Are you using the same ffmpeg as months ago when it worked?

I have upgraded to a newer version to see if it would fix the problem.

If an old version worked and the new one is worse it could indicate a regression. If you are familiar with git bisect and compiling you could find the responsible commit, but it can be time consuming and tedious.


text:
FFmpeg Can't Capture Window Rendered with Secondary GPU
Edit: I am using the terms "primary" & "secondary" cards below loosely. I'm just assuming the Intel card is considered the first card.
I recently discovered how to use my secondary graphics card (nVidia GeForce 930MX) to render a game on my Windows 10 system. However, when I do so, FFmpeg no longer captures what is displayed in that window. It captures whatever is displayed from the primary card (Intel(R) HD Graphics 630) at the coordinates of said window. Is there an argument that can be passed to FFmpeg's gdigrab or dshow formats to specify on which card the window/app is being rendered?
Example of command with gdigrab:
ffmpeg -format gdigrab -i title="<window name>" -c:v libx264 -preset ultrafast -qp 0 \
  -x264opts keyint="1" "<outfile>"

Example of command with dshow (window info read from registry):
ffmpeg -format dshow -i video="video-capture-recorder" -c:v libx264 -preset ultrafast \
  -qp 0 -x264opts keyint="1" "<outfile>"

I have been searching around the internet for quite a while, but haven't found much information on it.
I did try using the hwaccel & hwaccel_device arguments, but still Intel card is captured. I'm thinking these are actually to allow FFmpeg to take advantage of the hardware resources for its own performance?
ffmpeg -hwaccel_device 0 -hwaccel nvdec -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"

ffmpeg -hwaccel_device 1 -hwaccel nvdec -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"

...

[AVHWDeviceContext @ 000001f78689ef40] cu->cuDeviceGet(&cu_device, device_idx) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
Device creation failed: -1313558101.
[bmp @ 000001f7883ada40] No device available for decoder: device type cuda needed for codec bmp.

ffmpeg -hwaccel_device 1 -hwaccel cuvid -f gdigrab -i title="<window name>" \
  -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" "<outfile>"

Edit: Perhaps because the command using -hwaccel_device 0 -hwaccel nvdec doesn't exit with an error, this means that the nVidia GPU is considered card 0 & Intel is card 1?
In case it helps, I am on an HP Pavilion 24-b217c.

Possibly related to https://trac.ffmpeg.org/ticket/7718 although in your case, it appears the final buffer is composited at a latter stage, so not accessible to gdigrab. nvdec/hwaccel is irrelevant here, as they are meant for decoding compressed input on the GPU. You are working with raw frames as input.

This command ffmpeg -f gdigrab -i desktop -c:v h264_nvenc -gpu list -f null - will list your GPUs for you and the index number. You may just need to switch around which GPU is being used for h/w encoding. Depending on how your devices get enumerated will dictate what GPU gets assigned to what index. Index of a GPU is usually pretty static, but not if you have a dockable GPU, e.g. Microsoft Surface Book 2, desktop with multiple cards, eGPU over Thunderbolt, etc. When you run that command you will get an error about the encoder, just ignore it.

You can of course change "desktop" to "" if there is a specific window you are trying to analyze.

There are known (well documented and understood) and known (poorly documented and poorly understood) issues with capturing hardware accelerated windows with any software solution, not just ffmpeg. That said, your error message indicates the 930MX is not capable of supporting the h/w decode option your requested. And looking through the NVidia encode/decode support matrix (which isn't always accurate), it does appear that your 930MX is not up to the job. Your CPU most likely has Intel QuickSync on it.

When I say the NVidia encode/decode support matrix is inaccurate I mean that the information there is correct for those GPUs indicated to support the features, but often incomplete with missing GPU information or indicating that a GPU does not support that feature when in actuality it does because of the particular SKU of the GPU you happen to have.

For capturing (NVIDIA GPU rendered) chrome window, GPU compositing must be disabled via --disable-gpu-compositing. Maybe you can also disable it in your application.


text:
Configure CQP (CRF) for h264_nvenc
Encoding on CPU can be done via:
ffmpeg -i input.mp4 -vcodec h264 -crf 23 -acodec copy h264.mp4

GPU's alternative for the codec is h264_nvenc. How can I pass the same options to it?

I googled and came to following command:
ffmpeg -i input.mp4 -vcodec h264_nvenc -rc constqp -qp 23 -acodec copy h264_nvenc.mp4

But the file I get is much larger. And with other options quality is much worther.
PS: Same question in Russian.

CRF != CQP. The former may have variable QP but tries to maintain quality. CQP is a cruder form of rate-control.
For nvenc, use -rc vbr_hq -qmin 0 and add -cq X where X sets a quality level; range is 0-51. Smaller is better.

ffmpeg -i input.mp4 -vcodec h264_nvenc -vcodec h264_nvenc -cq 1 -acodec copy 25962-1.mp4 with values 0, 1 and 23 produce the same binary file having bad quality. With 51 file is 3 times smaller and quality is worther. So the parameter is not ignored.

Edited cmd. Values below 26 will produce about the same quality.

No, still bad quality.

nvenc will not match x264 quality at the same bitrate.

from reading:
ffmpeg -h encoder=h264_nvenc

and the nvidia nvenc examples at (https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/), I've arrived at:
ffmpeg -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i test_input.mp4 -c:a copy -c:v h264_nvenc -b:v 0 -cq 1 test3.mp4

where:
-b:v 0 over-rides the default 2mbps bitrate as noted by Gyan
-cq 1 means target quality level 1 (highest)
 range of 0-51.
 0 means automatic (in my case around 15mbps)
 1 gives about 15mbps, 26 results in around 5mbps, 51 results in 0.5mbps

If you don't specify bit rate yourself, FFmpeg will assume a default bit rate of 256 kbit\s, you have to unset it with -b:v 0.

The h264_nvenc encoder has a default bitrate of 2 mbps. But in any case, the cq mode does not look at bitrate.

Can you show the full command, please?


text:
Compare 2 videos automatically
I have 2 videos that are expected to be the same, but in some periods of time they may differ by additional elements shown above the video. Also video is reencoded, so some minor differences are possible. I want to run some program that will compare these videos and output me list of time slots where videos are different enough. What program should I use?
Note that I'm not interested in visual side-by-side comparison tool, I need the tool that will output time slots only without additional user interaction.


text:
ffmpeg. Converting through rawbitstream results to noise
I tried consequentially commands below. On output I'm getting video with a mess (even.mp4).
ffmpeg -i in.MOV -an -vcodec rawvideo -pix_fmt yuv420p rawbitstream.yuv

ffmpeg -r 2 -s 640x480 -i rawbitstream.yuv -vf select="not(mod(n-1\,2))" -c:v rawvideo -r 1 -format rawvideo -pix_fmt yuv420p -an even.yuv

ffmpeg -f rawvideo -vcodec rawvideo -s 640x480 -r 25 -pix_fmt yuv420p -i even.yuv -c:v libx264 -preset ultrafast -qp 0 even.mp4

Here is full log.
Video files are here.

Share full log of commands

@Gyan see above.

How are you playing the output? Can you share the input?

@Gyan See the link above. Before I tried to play it with VLC (mess), but it worked in Parole Media Player.

So, the issue is with the profile. Do you need lossless?

@Gyan I would like do not lose quality of original video.

Lossless is unnecessary and most players can't play it.

@Gyan got it, could you provide answer with edited command(s) ?

Use
ffmpeg -i in.MOV -an -vcodec rawvideo -pix_fmt yuv420p rawbitstream.yuv

ffmpeg -s 640x480 -i rawbitstream.yuv -vf select="not(mod(n+1\,2))" -c:v rawvideo -vsync 0 -an even.yuv

ffmpeg -f rawvideo -s 640x480 -pix_fmt yuv420p -i even.yuv -c:v libx264 -preset ultrafast -profile:v high -qp 1 even.mp4

Thanks a lot. I would like also to understand what is -qp and how it works. Hard to find info about it.

Quantization parameter. It controls how the raw coefficients - the error residuals - are transformed. You need to wade into DSP for the details - see https://en.wikipedia.org/wiki/Quantization_(image_processing)