Take the 2-minute tour ×
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It's 100% free, no registration required.

My question is related to the technicality behind video overlaying. When a 3D object or an image is added to a video sequence as an overlay to render, does ffmpeg fully decode the original sequence to a raw file, then mix the object or image to the desired position and re-encode back to the desired format?. I'd like to know if this is the process followed by the industry to mix 3D objects, images or other material with generic video contents. Or is there another approach to perform this task. Your assistance is highly appreciated. Thanks.

share|improve this question

2 Answers 2

From FFmpeg Documentation – Detailed Description:

ffmpeg calls the libavformat library (containing demuxers) to read input files and get packets containing encoded data from them. When there are multiple input files, ffmpeg tries to keep them synchronized by tracking lowest timestamp on any active input stream.

Encoded packets are then passed to the decoder (unless stream copy is selected for the stream). The decoder produces uncompressed frames (raw video/PCM audio) which can be processed further by filtering. After filtering, the frames are passed to the encoder, which encodes them and outputs encoded packets. Finally those are passed to the muxer, which writes the encoded packets to the output file.

share|improve this answer

Yes, compositing, as it is known in the industry, involves decoding two or more assets in to video streams and them combining those streams in some way. The end result is then saved as a new file on render. There is some variation in when rendering is done though. Some software can put off rendering for a while to reduce the number of re-encodes required.

For example, if combining two layers of video in After Effects, you can embed the entire composition in to Premiere rather than re-encode the video to a lossy format. This prevents further generations of loss without having to store the lossless render while working on the video (which would be very large).

Alternately, lossless file formats such as TGA sequences can be used for storing the result of a render without an additional generation of loss (since the render is preserved perfectly.)

The final render still uses the same basic process of using some blending algorithm to combine the pixel data from two or more video streams in to a single stream though and that stream eventually has to be stored again.

share|improve this answer
    
Thanks. Are there any tools in the industry that can perform this real time for HD videos? –  userDtrm Aug 5 at 19:37
    
That's called a keyer, down stream keyer or mask keyer, depending on the situation. Often a video mixer will also have the functionality. –  AJ Henderson Aug 5 at 19:49
    
Is this the way it happens for re-broadcasting streams as well. For example, lets say that you need to add a logo to a stream you get which is already encoded. In that case do we need to fully decode the stream and add the overlay, and then re-encode before transmission?. Many thanks for your help. –  userDtrm Aug 6 at 11:20
    
In most cases, some stream players may support a logo layer that can be applied for viewing, but generally speaking, the stream is decoded, the alteration is made and it is re-encoded. You can't change the content of a stream without doing a new encoding, you can only alter the length (clip the video) without re-encoding and even that has some limitations. –  AJ Henderson Aug 6 at 13:16
    
Thanks a lot for the explanation. –  userDtrm Aug 7 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.