[gst-devel] gnonlin and ffmpeg encoder problems

Lane Brooks lane at brooks.nu
Sat Jan 8 19:25:24 CET 2011


On 01/08/2011 02:54 AM, Edward Hervey wrote:
> On Fri, 2011-01-07 at 14:55 -0700, Lane Brooks wrote:
>> I have a gnonlin frontend that works fine when feeding an autovideosink
>> and the x264enc encoder. However, when I switch the encoder to a
>> ffenc_mpeg4, it quits encoding after the first source and starting
>> spewing out "Invalid timestamp" errors.
>>
>> I have a simple self-contained test that shows the problem that I posted
>> to http://pastebin.com/D8UgAHqt
>>
>> The script creates two gnlsources that encapsulate two videotestsrc with
>> different patterns that are arranged to play serially. The encapsulating
>> gnlcomposition feeds a ffenc_mpeg element. Only the first gnlsource gets
>> encoded in the resulting test.mp4 file. If you switch the script to use
>> the x264enc or the autovideosink, however, it works fine. The problem
>> also occurs with the mpeg2enc encoder and all the other ffmpeg encoders
>> that I have tried.
>>
>> The script is completely self contained and I would be curious if others
>> can download it and see the same behavior. Am I doing something wrong or
>> is there an incompatibility between gnonlin and ffmpeg encoders.
>
>    The problem is related to elements that don't properly take into
> account segments. GNonLin makes extensive usage of playback segments
> (see the documentation on new-segment event and the design docs for more
> info) to do time shifting. That way it doesn't need to do a costly
> re-timestamping of all buffers but instead just tweak the outgoing
> segments.
>    Very simplified, this means that if you have X sources, you will end
> up with gnlcomposition outputting at least X segments
>    NEWSEGMENT
>    buffers from first source
>    NEWSEGMENT
>    buffers from second source
>    ....
>
>    Elements operating on time should normally use/accumulate those
> newsegments (using GstSegment) to convert the buffer timestamps to
> running time timestamps (basesink does this for example, which is why
> you don't see any problem when using a videosink with gnonlin).
>
>    Since a lot of elements don't do that... you need to make sure they
> receive one continuous stream (with intermediary newsegment events
> swallowed and buffer timestamps modified).
>    Identity has got a property you can activate (single-segment) to do
> exactly that.
>
>    So basic rule of thumb : if you're using gnlcomposition, put a
> "single-segment identity=True" after it (or at least before your
> encoders).
>
>    EncodeBin supports that internally.
>
>      Edward

Thanks for the detailed feedback. The identity element does indeed solve 
the problem.

Lane




More information about the gstreamer-devel mailing list