问题
I am using Python bindings for Gstreamer and am using the following pipeline to convert a wav file to mp3. I used one of the suggestions in this question , with some modifications (as I was getting some errors when original syntax was used)
gst.parse_launch("filesrc location=C:\\music.wav ! decodebin
! audioconvert ! lame ! filesink location=C:\\music.mp3")
When I run this code in Python, I get no errors. However, it doesn't generate music.mp3 file.
What else do I need to do so that it creates a new file music.mp3
回答1:
your pipeline is correct - or more specifically, your choice of elements and properties is correct.
the problem is most likely in another part of your code. have you set the pipeline to gst.STATE_PLAYING?
pipeline = gst.parse_launch("filesrc location=C:\\music.wav ! decodebin ! audioconvert ! lame ! filesink location=C:\\music.mp3")
pipeline.set_state(gst.STATE_PLAYING)
there are numerous other common mistakes that can be made- posting your entire source code would be a great help!
回答2:
If you didn't get this working I suggest using ffmpeg to convert your files, it's very efficient and opensource, you can find a compiled windows version with WinFF which you can manipulate through the command line.
来源:https://stackoverflow.com/questions/2172000/converting-wav-to-mp3-and-vice-versa-using-gstreamer