Given a wmv file that is streaming online. The file is around 10kb as it does not have any video. If i click on the file it opens windows media player which then connects to the net. Windows media player starts to cache the file and then play the video for me.
Instead I would like my python program to open the file. Grab the content from the net and then download it for me. How would can I do this?
I was facing the same issue and looked into the Python VLC bindings but because I was pressed for time and there was a lack of examples using the bindings, I went for another approach.
The vlc command line is extremely powerful. Using subprocess.call i did direct calls to the vlc command line.
This is the format I used and it worked beautifully.
subprocess.call([path_to_vlc,
mms_url,
'--sout',
'file/avi:'+target_file,
'vlc://quit'])
In the part of the list of parameters you send to call, here is a description of each:
path_to_vlc -- As the name suggests. You don't have to use " to encapsulate spaces as with os.system for Program Files, etc. subprocess.call does that for you.
mms_url -- is the url to the stream. Since in my case it was a mms stream the param name stuck. You can use any of the supported vlc stream prefixes.
'--sout' -- since call encapsulate spaces for you, you need to explicitly separate each param where a space is needed. The actual param here is --sout file/avi:.... but we have to split them into two.
'file/avi:'+target_file -- The uri (and muxer) pointing to the target file. I used no path to the file since I was standing in the target directory when calling the python script. The target file should
'vlc://quit' -- Last we tell vlc to quit after playback. This way you get rid of the zombie vlc windows that stick around after.
If you wish to see the full code i used to first find the it here.
You could use the VLC Python bindings to handle the actual downloading and saving.
You'll need to get vlc.py from their Git repo.
Look at Instance.media_new_location.
Related
I have a 1hr video I would like to chop up into segments. I have been through the 1hr video, and have ~40 segments I want to chop and output into audio only (mp3) files, each file with a name. I have the start time, end time, and title all saved in a csv.
I'm aware of the python bindings (https://wiki.videolan.org/Python_bindings) and the documentation (https://www.olivieraubert.net/vlc/python-ctypes/doc/), but it's quite large, and I can't find what I'm looking for (VLC Media Player > Convert/Save).
Essentially I want to use the VLC ython API to provide a list of times (from/to), along with titles for each, so the API with use VLC to output into single mp3 files in a folder.
Anyone have any ideas where I can start, and what functions I should start with?
In typing this out a thought has occurred to me that there may be a python package that can do this (and avoid the need to use VLC), if so I'd be happy to hear about it also. Thanks,
I am very new to python and it seems that every tutorial mentions the need for a path when opening and reading a pdf in python.
The pdf that I want to read can be located in different folders and have different names and I would like to avoid relying on user input. Instead I was hoping that I could open the pdf in Acrobat Reader on the computer and code python to read the pdf file that is currently open. Is this possible?
One solution is to make use of the console arguments that can be accessed via the 'sys' module, the first argument is the path to the python executable, and the rest are arguments passed by the user like this:
python someScript.py arga argb
Then you can access them like this via the argv array:
import sys
for arg in sys.argv:
print(arg)
In this example it would print:
path/to/someScript.py
arga
argb
You could make it so you take the 1st user argument as path like this:
python someScript.py some/path/to/some/file.txt
And then you can get that path using
import sys
path = sys.argv[1]
If you dislike the user having to type the path in the terminal when launching the python script, or prefer launching it by double clicking the py file, you can just drag and drop the file you want the path of onto the python file and then it will work just fine.
I do realise that its not exactly what you asked, but finding an open file in some process on the pc is way harder and more unrealistic, if its even possible.
Hence i am proposing this alternative solution
It's possible but paths are so much easier, lol. checkout pyautogui. After you configure the script which navigates to the window you're looking for you're going to need to take a screenshot and use optical content recognition, checkout pytesseract
I'm working on a side project where we want to process images in a hadoop mapreduce program (for eventual deployment to Amazon's elastic mapreduce). The input to the process will be a list of all the files, each with a little extra data attached (the lat/long position of the bottom left corner - these are aerial photos)
The actual processing needs to take place in Python code so we can leverage the Python Image Library. All the Python streaming examples I can find use stdin and process text input. Can I send image data to Python through stdin? If so, how?
I wrote a Mapper class in Java that takes the list of files and saves the names, the extra data, and the binary contents to a sequence file. I was thinking maybe I need to write a custom Java mapper that takes in the sequence file and pipes it to Python. Is that the right approach? If so, what should the Java to pipe the images out and the Python to read them in look like?
In case it's not obvious, I'm not terribly familiar with Java OR Python, so it's also possible I'm just biting off way more than I can chew with this as my introduction to both languages...
There are a few possible approaches that I can see:
Use both the extra data and the file contents as input to your python program. The tricky part here will be the encoding. I frankly have no idea how streaming works with raw binary content, and I'm assuming that basic answer is "not well." The main issue is that the stdin/stdout communication between processes is very text-based, relying on delimiting input with tabs and newlines, and things like that. You would need to worry about the encoding of the image data, and probably have some sort of pre-processing step, or a custom InputFormat so that you could represent the image as text.
Use only the extra data and the file location as input to your python program. Then the program can independently read the actual image data from the file. The hiccup here is making sure that the file is available to the python script. Remember this is a distributed environment, so the files would have to be in HDFS or somewhere similar, and I don't know if there are good libraries for reading files from HDFS in python.
Do the java-python interaction yourself. Write a java mapper that uses the Runtime class to start the python process itself. This way you get full control over exactly how the two worlds communicate, but obviously its more code and a bit more involved.
I want to automate the entire process of creating ngs,bit and mcs files in xilinx and have these files be automatically be associated with certain folders in the svn repository. What I need to know is that is there a log file that gets created in the back end of the Xilinx gui which records all the commands I run e.g open project,load file,synthesize etc.
Also the other part that I have not been able to find is a log file that records the entire process of synthesis, map,place and route and generate programming file. Specially record any errors that the tool encountered during these processes.
If any of you can point me to such files if they exist it would be great. I haven't gotten much out of my search but maybe I didn't look enough.
Thanks!
Well, it is definitely a nice project idea but a good amount of work. There's always a reason why an IDE was built – a simple search yields the "Command Line Tools User Guide" for various versions of Xilinx ISE, like for 14.3, 380 pages about
Overview and list of features
Input and output files
Command line syntax and options
Report and message information
ISE is a GUI for various command line executables, most of them are located in the subfolder 14.5/ISE_DS/ISE/bin/lin/ (in this case: Linux executables for version 14.5) of your ISE installation root. You can review your current parameters for each action by right clicking the item in the process tree and selecting "Process properties".
On the Python side, consider using the subprocess module:
The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
Is this the entry point you were looking for?
As phineas said, what you are trying to do is quite an undertaking.
I've been there done that, and there are countless challenges along the way. For example, if you want to move generated files to specific folders, how do you classify these files in order to figure out which files are which? I've created a project called X-MimeTypes that attempts to classify the files, but you then need a tool to parse the EDA mime type database and use that to determine which files are which.
However there is hope, so to answer the two main questions you've pointed out:
To be able to automatically move generated files to predetermined paths. From what you are saying it seems like you want to do this to make the versioning process easier? There is already a tool that does this for you based on "design structures" that you create and that can be shared within a team. The tool is called Scineric Workspace so check it out. It also have built in Git and SVN support which ignores things according to the design structure and in most cases it filters all generated things by vendor tools without you having to worry about it.
You are looking for a log file that shows all commands that were run. As phineas said, you can check out the Command Line Tools User guides for ISE, but be aware that the commands to run have changed again in Vivado. The log file of each process also usually states the exact command with its parameters that have been called. This should be close to the top of the report. If you look for one log file that contains everything, that does not exist. Again, Scineric Workspace supports evoking flows from major vendors (ISE, Vivado, Quartus) and it produces one log file for all processes together while still allowing each process to also create its own log file. Errors, warning etc. are also marked properly in this big report. Scineric has a tcl shell mode as well, so your python tool can run it in the background and parse the complete log file it creates.
If you have more questions on the above, I will be happy to help.
Hope this helps,
Jaco
I'm working on a web application that manages VRML files. I also want to let users see the uploaded files, without requiring a specific plug-in or player. X3DOM allows viewing X3D files without plug-ins on most browsers, so I'd like to use it.
Alas, it works on X3D files, and not VRML files. I need to convert VRML files to the X3D format.
The same people behind X3DOM released a package called InstantReality that has a utility that converts VRML to X3D. However, I'd much rather not use an external utility (I'm not even sure I'm allowed to use it on a commercial environment, I couldn't find its terms of use) but call a conversion routine from my application code.
MeshLab! There's an opensource project called MeshLab that does all sorts of processing on 3D meshes. It also has a command-line tool called MeshlabServer.
Running meshlabserver.exe -i <wrl file> -o <x3d file> performs the conversion (very quickly). Since it's open-source, I don't have any licensing issues.
are you talking about this online converter?
http://doc.instantreality.org/tools/x3d_encoding_converter/
you could probably build some scripting to convert the vrml to x3d/x3dom and then store and or display
as well blender aopt and others should be able to convert vrml to x3d on the command line. depending on your servers os this could be batched/scripted as well
im in a rush to get some other work done but hope this helps.
let me know if you need more info or examples and ill see what i can do
I also needed to convert VRML .wrl to .x3d; I tried meshlab (meshlabserver), but unfortunately, the version I have (.deb 2016.12~trusty2 on Ubuntu 14.04) compacts everything to a single mesh, and looses color in the process.
I found that view3dscene can do conversion from the command line, where the materials/colors are preserved in .x3d, as they were in .wrl:
view3dscene mymodel.wrl --write --write-encoding xml > mymodel.x3d
Since view3dscene functions as a viewer for both .wrl and .x3d files, it can also be used immediately, to check if the converted (or the original) file has colors or not.
ok so i think this is the full solution for you
1) user uploads a vrml file
2) that file gets saved to (file or db)
3) upon confirmation that the vrml file has been saved (and possibly validated as correct vrml syntax) it gets converted and saved to x3d (again as file or db) , with aopt this would be accomplished by aopt -i input.wrl -o output.x3d
FYI: aopt is avail for linux windows and mac
since you use python this maybe a way you could do it as well with blender although there are no full example of vrml to x3d this link should get you started
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Wavefront_OBJ#Command_Line_Converting
4) display the x3d via x3dom
Since the ClassicVRML X3D Encoding is a direct successor of the VRML97 standard, in most cases you can copy the file, rename the .wrl file extension to a .x3dv file extension, and change the scene header from
#VRML V2.0 utf8
to
#VRML V3.3 utf8
PROFILE Immersive
Many converters exist, both commercial and open source. Several are integrated with X3D-Edit. A full list is maintained at
X3D Resources: Conversions and Translation Tools
http://www.web3d.org/x3d/content/examples/X3dResources.html#Conversions
Personal favorite:
Castle Game Engine: Convert everything to X3D
https://castle-engine.io/convert.php
If you simply want to convert X3D XML encoded files to VRML Classic encoded files you can use Titania, http://titania.create3000.de/. Open your .x3d file and save it as .x3dv or .wrl.
Titania also comes with a command line utitity »x3dtidy« that can do the conversion too.
You can use this tool (a java jar that can be run from the command line) to convert VRML to X3D:
http://www.deem7.com/vrmlmerge/howto.php
java -jar VrmlMerge-[version].jar -convert inputfile.wrl [outputfile.x3d]
The license:
VrmlMerge is free for non-commercial use. If you somehow make money out of VrmlMerge then I'd like you to contact me to agree on some terms of use. VrmlMerge is provided "as is" and I don't take any responsibility for any damage it can make to you, your computer, files, data, wife, brain etc..