<div dir="ltr">Hi alls,<div>I try to port my old java-gstreamer application to pygi and make a little test with follow</div><div>This commande works </div><div>gst-launch-1.0 filesrc location=c:\\audiotest\\0000ad39.wav ! decodebin ! audioconvert ! audioresample ! lamemp3enc ! filesink location=c:\\audiotest\\0000ad39.mp3<br></div><div><br></div><div><br></div><div>I want to run something like this from python(pygi) </div><div><br></div><div><div>import logging</div><div>from logging.handlers import RotatingFileHandler</div><div><br></div><div>logging.basicConfig(level=logging.INFO)</div><div><br></div><div>logger = logging.getLogger('myapp')</div><div><br></div><div>import gi</div><div>gi.require_version('Gst', '1.0')</div><div>from gi.repository import GObject, Gst</div><div><br></div><div>GObject.threads_init()</div><div>Gst.init(None)</div><div><br></div><div>def transcode_process(pathin, pathout):</div><div><br></div><div><span class="" style="white-space:pre">    </span>log_message = "Transcoding %s to %s" % (pathin, pathout)</div><div><br></div><div><span class="" style="white-space:pre">        </span>cmd = 'filesrc location=c:\\\\audiotest\\0000ad39.wav name=source ! decodebin ! audioconvert ! audioresample ! lamemp3enc name=encoder ! filesink location=c:\\\\audiotest\\0000ad39.mp3 name=output'</div><div><br></div><div><span class="" style="white-space:pre">     </span>pipeline = Gst.parse_launch(cmd)</div><div><br></div><div><span class="" style="white-space:pre">  </span>if pipeline == None:</div><div><span class="" style="white-space:pre">               </span>logger.error("Failed get pipeline")</div><div><span class="" style="white-space:pre">              </span>return</div><div><br></div><div><span class="" style="white-space:pre">    </span>source = pipeline.get_by_name('source')</div><div><br></div><div><span class="" style="white-space:pre">   </span>if source == None:</div><div><span class="" style="white-space:pre">         </span>logger.error("Failed get source")</div><div><span class="" style="white-space:pre">                </span>return</div><div><br></div><div><span class="" style="white-space:pre">    </span>try:</div><div><br></div><div><span class="" style="white-space:pre">              </span>pipeline.set_state(Gst.State.PLAYING)</div><div><br></div><div><span class="" style="white-space:pre">             </span>bus = pipeline.get_bus()</div><div><br></div><div><span class="" style="white-space:pre">          </span>msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">           </span>pipeline.set_state(Gst.State.NULL)</div><div><br></div><div><span class="" style="white-space:pre">        </span>except Exception as e:</div><div><span class="" style="white-space:pre">             </span>logger.error(str(e))</div><div><span class="" style="white-space:pre">               </span>logger.error("Could not open the file for transcoding. This is probably happening because there are non-ASCII characters in the filename.")</div><div><span class="" style="white-space:pre">      </span>finally:</div><div><span class="" style="white-space:pre">           </span>try:</div><div><span class="" style="white-space:pre">                       </span># I think this is supposed to free the memory used by the pipeline</div><div><span class="" style="white-space:pre">                 </span>pipeline.set_state(Gst.State.NULL)</div><div><span class="" style="white-space:pre">         </span>except:</div><div><span class="" style="white-space:pre">                    </span>pass</div><div><br></div><div><br></div><div>def main():</div><div><span class="" style="white-space:pre">   </span>print sys.getdefaultencoding()</div><div><span class="" style="white-space:pre">     </span>transcode_process("c:\\\\audiotest\\0000ad39.wav", "c:\\\\audiotest\\0000ad39.mp3")</div><div><br></div><div><br></div><div>if __name__ == "__main__":</div><div><span class="" style="white-space:pre">       </span>main()</div></div><div><br></div><div><br></div><div>Something missing .. :-) </div><div><br></div><div>Thank for help </div><div><br></div><div><br></div><div><br></div><div>
</div></div>