<div dir="ltr">I wrote a script in python to generate a OGG video from a set of PNG files.<br><br>======================= >8 =======================<br><br>#!/usr/bin/env python3<br>import os<br>import argparse<br><br>import gi; gi.require_version('Gst', '1.0')<br>from gi.repository import GObject, Gst<br><br><br>def pipeline(png_path, ogg_path):<br> """<br> Builds the pipeline<br> png_path is a directory path to the images, like '/home/fulano/images/'<br> ogg_path is the file path for the video, including the name, like '/home/fulano/video.ogg'<br> """<br> pipeline = Gst.Pipeline.new("pipeline")<br><br> multifilesrc = Gst.ElementFactory.make('multifilesrc')<br> multifilesrc.set_properties(<br> location=os.path.join(png_path,'%03d.png'),<br> index=0,<br> caps=Gst.Caps.from_string("image/png,framerate=(fraction)12/1")<br> )<br> pipeline.add(multifilesrc)<br><br> pngdec = Gst.ElementFactory.make('pngdec')<br> pipeline.add(pngdec)<br> multifilesrc.link(pngdec)<br><br> videoconvert = Gst.ElementFactory.make('videoconvert', None)<br> pipeline.add(videoconvert)<br> pngdec.link(videoconvert)<br><br> videorate = Gst.ElementFactory.make('videorate', None)<br> pipeline.add(videorate)<br> videoconvert.link(videorate)<br><br> theoraenc = Gst.ElementFactory.make('theoraenc', None)<br> pipeline.add(theoraenc)<br> videorate.link(theoraenc)<br><br> oggmux = Gst.ElementFactory.make('oggmux', None)<br> pipeline.add(oggmux)<br> theoraenc.link(oggmux)<br><br> filesink = Gst.ElementFactory.make('filesink', None)<br> filesink.set_property('location', ogg_path)<br> pipeline.add(filesink)<br> oggmux.link(filesink)<br><br> return pipeline<br><br>if __name__=="__main__":<br> Gst.init(None)<br> pipe = pipeline('img', 'video.ogg')<br> pipe.set_state(Gst.State.PLAYING)<br> GObject.MainLoop()<br><br clear="all"><div>======================= >8 =======================</div><div><br></div><div>When running the script I get the following information:</div><div><br></div><div>$ GST_DEBUG=3 ./ogg_tool<br>0:00:00.037269747 11891 0x55adbcd1ec00 FIXME default gstutils.c:3902:gst_pad_create_stream_id_internal:<multifilesrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id<br>0:00:00.037337706 11891 0x55adbcd1ec00 FIXME videodecoder gstvideodecoder.c:928:gst_video_decoder_drain_out:<pngdec0> Sub-class should implement drain()<br>0:00:00.039960129 11891 0x55adbcd1ec00 WARN videodecoder gstvideodecoder.c:2438:gst_video_decoder_chain:<pngdec0> Received buffer without a new-segment. Assuming timestamps start from 0.<br>0:00:00.040000881 11891 0x55adbcd1ec00 FIXME videodecoder gstvideodecoder.c:928:gst_video_decoder_drain_out:<pngdec0> Sub-class should implement drain()<br>0:00:00.047336315 11891 0x55adbcd1ec00 WARN videopool gstvideopool.c:219:video_buffer_pool_set_config:<videobufferpool1> no caps in config<br><br></div><div>$ ll<br>total 12<br>drwxrwxr-x. 2 nnieto nnieto 4096 nov 30 15:00 img<br>-rwxrwxr-x. 1 nnieto nnieto 1959 nov 30 15:50 ogg_tool<br>-rw-rw-r--. 1 nnieto nnieto 0 nov 30 15:55 video.ogg<br></div><div><br></div><div>video.ogg is 0 bytes long</div><div><br></div><div>I tried with gst-launch and it works:</div><div><br></div><div>$ gst-launch-1.0 multifilesrc location="img/%03d.png" index=0 caps="image/png,framerate=\(fraction\)12/1" ! pngdec ! videoconvert ! videorate ! theoraenc ! oggmux ! filesink location="video_gstlaunch.ogg"<br>Setting pipeline to PAUSED ...<br>Pipeline is PREROLLING ...<br>Pipeline is PREROLLED ...<br>Setting pipeline to PLAYING ...<br>New clock: GstSystemClock<br>Got EOS from element "pipeline0".<br>Execution ended after 0:00:01.932992495<br>Setting pipeline to PAUSED ...<br>Setting pipeline to READY ...<br>Setting pipeline to NULL ...<br>Freeing pipeline ...<br></div><div><br></div><div>$ ll<br>total 444<br>drwxrwxr-x. 2 nnieto nnieto 4096 nov 30 15:00 img<br>-rwxrwxr-x. 1 nnieto nnieto 1959 nov 30 15:50 ogg_tool<br>-rw-rw-r--. 1 nnieto nnieto 438882 nov 30 15:57 video_gstlaunch.ogg<br>-rw-rw-r--. 1 nnieto nnieto 0 nov 30 15:55 video.ogg<br></div><div><br></div><div>Any idea what I'm doing wrong?<br></div><br><div><div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Noe Nieto<br></div><br></div></div></div></div>
</div></div></div>