But it wasn't working. Until I figured out from lots of reading about misconception 2. It turns out I needed to set keyint to double my desired GOP size. This means that min-keyint can be set to my desired GOP size without the internal code cutting it in half , which prevents scene-cut detection from using IDR I-frames inside the GOP size because the frame count since the last IDR I-Frame is always less than min-keyinit. So here's what works:. Twitch has a post about this. They explain that they decided to use their own program for several reasons; one of them was that ffmpeg doesn't let you run different x instances in different threads, but instead devotes all specified threads to one frame in one output before moving on to the next output.
If you aren't doing real-time streaming, you have more luxury. The 'correct' way is probably to encode at one resolution with just the GOP size specified with -g, and then encode the other resolutions forcing keyframes at the same places.
If you wanted to do that, you might use ffprobe to get the keyframe times and then use a shell script or an actual programming language to convert that into an ffmpeg command. But for most content, there's very little difference between having one keyframe every 5 seconds and two keyframes every 5 seconds one forced and one from scenecut.
This is about the average I-frame size vs the size of P-frames and B-frames. On other types of content, frame sizes will be different. To be fair, this is about temporal complexity and not spatial complexity, so it isn't just easy content vs hard content. But generally, streaming video sites have a bitrate limit, and content with relatively large I-frames is easy content that will be encoded at high quality no matter how many extra keyframes are added.
It's wasteful, but this waste will usually not be noticed. The most wasteful case is probably a video that's just a static image accompanying a song, where each keyframe is exactly the same. One thing I'm not sure of is how forced keyframes interact with the rate limiter set with -maxrate and -bufsize. I think even YouTube has had recent problems correctly configuring buffer settings to give consistent quality. Ffmpeg's -g option, or any other encoder option that you use, is mapped to the encoder-specific option.
One problem with using scene detection is if you prefer keyframes near specific numbers for whatever reason. If you specify keyframes every 5 seconds and use scene detection, and there's a scene change at 4. If the time keeps getting stepped up like this, you could end up with keyframes at Conversely, if there's a scene change at 5.
Ffmpeg doesn't let you specify "make a keyframe here if there's no scene change within the next 30 frames". Someone who understands C could add that option, though. For variable-frame-rate video, when you're not live-streaming like Twitch, you should be able to use scene changes without converting permanently to constant frame-rate.
This is probably different from, and not as useful as, the number used by x, but it could still be useful. The procedure, then, would probably be to do a test video that's only for keyframe changes, but maybe could be used for rate control data if using 2-pass.
Not sure if the generated data is at all useful for different resolutions and settings; the macroblock-tree data won't be. Convert it to constant-framerate video, but see this bug about stuttering output when halving framerate if you ever decide to use the fps filter for other purposes. Run it through x with your desired keyframe and GOP settings.
If you allow completely crazy user-generated content with a second gap between frames, then for the variable frame-rate encode, you could split the output, use fps filter, somehow use select filter maybe build a really long expression that has every keyframe time Then scale it to the correct size there's even a scale2ref filter for this and overlay the original video on it.
Then use the interleave filter to combine these destined-to-be forced keyframes with the original video. If this results in two frames that are 0. Dealing with frame buffer limits for the interleave filter could be the main problem here. These could all work: use some kind of filter to buffer the denser stream fifo filter? It seems that this syntax doesnt allways work.. Ive tested quite alot on our VOD content as well as live content file dumps and sometimes scenecut doesnt work and trigger a inbetween iframe:.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question. Asked 6 years, 6 months ago. Active 1 year, 9 months ago. Viewed k times. Method 3: insert a keyframe every N seconds Maybe?
Which is right? However, this requires that it conforms to GOP specifications in H. Improve this question. Giacomo Mark Gerolimatos Mark Gerolimatos 1, 2 2 gold badges 12 12 silver badges 20 20 bronze badges. Add a comment. Active Oldest Votes.
What is recommended for streaming? Does not work with pre-scenecut scenecut must be off to force off b-adapt. A good balance between speed and quality. It is considerably more efficient than DIA and hardly any slower, and therefore makes a good choice for general-use encoding.
It is mathematically equivalent to the bruteforce method of searching every single motion vector in that area, though faster. However, it is still considerably slower than UMH, with not too much benefit, so is not particularly useful for everyday encoding.
Should be avoided except on first pass encoding. Activates rate-distortion optimization for partition decision. This can considerably improve efficiency, though it has a notable speed cost.
Slower than subme 6, but again, more efficient. Linux Encoding. Search this site. Home Static Builds x options guide. Please Note: This guide will remain here for historic purposes but FFmpeg and libav now use libx's internal -preset, -profile and -tune options. This determines the maximum distance between I-frames. Very high GOP lengths will result in slightly more efficient compression, but will make seeking in the video somewhat more difficult.
Rarely needs to be adjusted. Recommended default: 40 --pre-scenecut x none FFmpeg Slightly faster but less precise scenecut detection.
Normal scenecut detection decides whether a frame is a scenecut after the frame is encoded, and if so then re-encodes the frame as an I-frame. This is not compatible with threading, however, and so --pre-scenecut is automatically activated when multiple encoding threads are used.
Most, however, do not; as a result, there is rarely any negative effect to setting this to the maximum 16 since x will, if B-adapt is used, automatically choose the best number of B-frames anyways. This parameter simply serves to limit the max number of B-frames. Note that Baseline Profile, such as that used by iPods, does not support B-frames. It is possible to disable this adaptivity; this is not recommended. Recommended default: 1 0: Very fast, but not recommended. Its speed gets considerably slower at high bframes values, so its recommended to keep bframes relatively low perhaps around 3 when using this option.
It also may slow down the first pass of x when in threaded mode. Not generally recommended. The name is technically misleading, as x does not actually use pyramid coding; it simply adds B-references to the normal reference list. B-references get a quantizer halfway between that of a B-frame and P-frame. This setting is generally beneficial, but it increases the DPB decoding picture buffer size required for playback, so when encoding for hardware, disabling it may help compatibility.
It is also required for the use of trellis quantization. Active Oldest Votes. Ronald S. Bultje Ronald S. Bultje 9, 23 23 silver badges 44 44 bronze badges. The official way to confirm that is parse the reference list from the headers and make sure the I is in the reflist for the B, but I doubt you want to go that far unless this is academic in nature. TvE TvE 1 1 gold badge 9 9 silver badges 17 17 bronze badges. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
0コメント