I am hoping to find a way to write generated video (non-real time) from Python and mix it with external audio file (MP3) simultaneously.
What's the current status of GStreamer Python bindings, are they up-to-date?
Would it be possible to write MPEG-4 output with GStreamer and feed raw image frames from Python
Is it possible to construct pipeline so that GStreamer would also read MP3 audio and mix it into the container, so that I do not need to reprocess the resulting video track with ffmpeg etc. external tools to have the audio track
Are there any up-to-date tutorials for using GStreamer with Python? (I couldn't find anything dated since 2006-2009)
(my old question: did not really give good pointers Writing video with OpenCV + Python + Mac )
Whether or not the binding are "up-to-date" really depends on what version of Python you're using. As for Python 2.7, I am using GStreamer without incident.
I have been fighting a major bug in developing with Python 2.7 and GStreamer on Windows 7 (WinBuilds installers), but I'm able to work with GStreamer just fine on Ubuntu.
GStreamer does have mp3 codecs, but there are some legal matters surrounding their legality in some countries. I'd do a Google search on that before using them.
As for tutorials, no luck. All the same, the existing tutorials do quite well for the modern version, especially this one and this one.
In regards to writing MPEG-4 output and feeding raw images, I do not know. That would be a good stand-alone question, in all honesty.
Related
I'm trying to capture my screen using Python because I'll use it on OpenCV, but I couldn't find a way to make it work on Gnome, since Gnome uses Wayland and all libraries that I've found only work with X11.
For now I'm not considering change my interface. I'm searching a solution to this problem.
Does someone know a solution?
To be more specific, I'll use the images to train an AI and so I need they continuously.
EDIT:
I've found this but how can I pass frames to OpenCV in Python instead of save a video file?
The proper way to do screencasting these days is by using the Screencast portal, which is part of XDG desktop portals and is already supported by GNOME, KDE, wlroots (and more). As an added advantage, this will also work in containerized formats like Flatpaks.
You can find an example on how to do screencasting in Pyhon using this snippet, created by one of the Mutter maintainers. If you look for parse_launch(), you will see a GStreamer pipeline which you can modify to include the GStreamer OpenCV elements that can do the processing for you.
Note: in your edit, you link to a predecessor of that portal, which is GNOME-specifc, internal API, so I wouldn't rely on it ;-)
I'm working on a project and I need to read and parse video metadata.(duration, date created,title,bit rate , ...)
as far as I know there isn't any good package for Python 3.X for this issue.
1 -- I found these :
enzyme
hachoir-metadata
but they are designed for python 2.X
2 --
I also know how to use ffmpeg and other libraries that process video files. but they are so slow, I want to simply read the metadata from the windows file.
3 -- I tried to use exifread package to read video metadata , but as far as I found out , it doesn't work on video files.
4 -- there was this question that asked for a way to retrieve only length of videos, but it is unanswered.
I'm looking for this:
file = open(path_to_video_file)
props = python_video_info_parser.get_info(file)
print(props)
platform:
python 3.4
windows 10
I hope you found what you are looking for. :)
But if you did not or others are wondering.. I am researching the same sunject and I may have found a solution.
What I have found so far is a command-line tool called exiftool.
If you download this software and use the command line feature you are able to run these commands with the subprocess module.
There is support for a lot of file formats, as shown in the documentation.
I will update this post as soon as I have found a working soltuion. :)
You can download the tool here.
I need to write a program on my Raspberry Pi to get a video and audio stream with Gstreamer from network and play them.(I have two stream. one for video and one for audio) and i need a custom GUI. I followed the below link :
http://www.jonobacon.org/2006/08/28/getting-started-with-gstreamer-with-python/
It used PyGtk and I want to switch to PyGObject. my question is : does PyObject support Gstreamer as well as PyGTK? or I should stuck to PyGTK? Or do you have a better solution to do that on Raspberry Pi
Considering the age of the article you linked, you might already know that there are newer versions of the libraries around. PyGtk and PyGst don't provide bindings for these.
Python GObject Introspection supports the Gkt-3.0 and Gst-1.0 versions. So you're safe using PyGObject for your program.
There's a quite good documentation on lazka.github.io/pgi-docs/ covering a lot more bindings as well.
Besides if you're going to build an audio/video player have a look at the playbin element. It's a complete pipeline supporting an audio-, a video- and a text-sink at once.
I'm looking for a Python library that can combine images into a video.
A library that just allows you to create an empty video and feed images into it as frames is ideal.
Preferably with support for MPEG compression of the video file as well.
If you run linux then you can use ffmpeg to do this from the command line there is a python wrapper called pyFFmpeg that you can use - there is also pymedia but it doesn't look to be maintained.
BTW there are a number of projects that provide builds of ffmpeg for windows.
gstreamer is the tool you are looking for. you'll probably need an appsrc or something like that.
Does anybody have experience with converting mp4 files to .wav or mp3 files? I am able to do this in Linux (bash), but I try to do everything in Python that I do in other languages, call me an enthusiast. I have been looking over the Pymedia library, but have not made progress as of yet.
You can use Python bindings for GStreamer, and create a pipeline to do the conversion:
More info here:
http://pygstdocs.berlios.de/pygst-tutorial/pipeline.html
Example of pipeline in another SO question:
converting wav to mp3 (and vice versa) using GStreamer
You might find the python audio tools of some use. They are designed to work from command line, but being python code you can simply import the modules and integrate it in another program. This is the API documentation. From the "About" page:
Python Audio Tools are a collection of audio handling programs which work from the command line. These include programs for CD extraction, track conversion from one audio format to another, track renaming and retagging, track identification, CD burning from tracks, and more. Supports internationalized track filenames and metadata using Unicode. Works with high-definition, multi-channel audio as well as CD-quality. Track conversion uses multiple CPUs or CPU cores if available to greatly speed the transcoding process. Track metadata can be retrieved from FreeDB, MusicBrainz or compatible servers.