[Libav-user] Simplified demux/decode/encode/mux
george at nsup.org
Sat Mar 1 19:15:46 CET 2014
Le primidi 11 ventôse, an CCXXII, Harald Schlangmann a écrit :
> #1: As I do not want to change the audio part, what is the preferred and
> fastest way to pass this stream through? Is it valid to simply read audio
> packets (not frames) and write them unchanged?
For most formats and codecs, this is valid. This is what the ffmpeg
command-line tool does when you use "-c copy".
> #2: I have learned about pts/dts and roughly understand what it is all
> about. Samples I have seen do quite sophisticated things to derive a PTS
> for real time display and so on… In my scenario (which is a simple batch
> process), is it a valid approach to ignore that stuff completely and
> simple copy over the original pts/dts fields on packet level (both audio
> and video) when writing them to the second file?
Not exactly, there are two issues you must take care of.
First, if you are transcoding, especially video, you must make sure to set
the frame's PTS (a frame does not have a DTS), and let the encoder set the
packet's PTS and DTS. The DTS exists to take into account the B-frames and
codec delay. You can not know that your encoder will make the same decisions
about that than the original encoded content.
Second, and that applies both for packets just encoded and packets copied
from the input as is: you need to rescale the packet's PTS and DTS to the
stream's time base.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: Digital signature
More information about the Libav-user