Edit Quicktime file header - audio tracks assignment flags, Timecode track - python

I use Python quite a bit and am looking for a way to edit a Quicktime file flags via Python / command line. I need to edit the audio tracks assignment flags, Left, Right, Left Surround, etc, also edit Timecode track, Pixel Aspect ratio, etc, quicktime atoms. I have been looking for some time of how this can be done programatically via python but can't find anyway, I don't wan't to re-encode the file, just change the flags. can PyQt do this?

I've never tried pyglet, but it might look like what you need.
pyglet: a cross-platform windowing and multimedia library for Python.
Load images, sound, music and video in almost any format. pyglet can optionally use AVbin to play back audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as DivX, MPEG-2, H.264, WMV and Xvid.
Take a look at the pyglet documentation for more information.

Related

How to make screenshots from TS video stream?

I would like to make screenshots each 1 minutes from the video stream. The video stream is provided as m3u8 file:
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:112076
#EXT-X-PROGRAM-DATE-TIME:2019-03-19T16:16:53Z
#EXTINF:6.000, 2019/03/19/16/16/53-06000.ts
#EXTINF:6.000, 2019/03/19/16/16/59-06000.ts
#EXTINF:6.000, 2019/03/19/16/17/05-06000.ts
#EXTINF:6.000, 2019/03/19/16/17/11-06000.ts
I found a library to parse it - https://github.com/globocom/m3u8. But I don't understand how I can convert this TS video stream to single jpeg file.
Am I supposed to
download TS file
find needed frame
extract it
delete ts file?
Should I use OpenCV or is there any easier solution?
use OpenV
This is a job for ffmpeg.
To capture a frame from a playlist every minute, you can use:
ffmpeg -i "http://cam.l-invest.ru/nagatinskaya4/tracks-v1/index.m3u8" -vf fps=1/60 invest.ru_%04d.jpg -hide_banner
The above will produce:
invest.ru_0001.jpg
invest.ru_0002.jpg
and so on... once every 60″
Notes:
invest.ru_0002.jpg was taken exactly 60″ after invest.ru_0001.jpg, as you can see in the upper-right timestamp.
-vf indicates ffmpeg to use a video filter fps=1/60, so it will extract one frame every 60″ (src).
The output format and filename structure can be changed if needed (ex: %Y-%m-%d_%H-%M-%S.jpg). Please check the ffmpeg image2 docs for available options.
I think you can use VLC to do that.
EDIT: looks very similar to https://superuser.com/questions/1379361/vlc-and-m3u8-file.
The following answer might not work for your file format (unless higher versions of VLC work correctly ...). May be have a look to this question which might give you some more insight
To my knowledge, VLC works fines with TS files/streams
Once you have a TS file, you should be able to use vlc to perform your screenshots.
According to this link and to this SO question and answers, one can launch VLC and make it perform screen captures.
And according to VLC documentation, it seems possible.
Should work on win/linux/mac.
I do have tested it yet, I need to reach my personal computer to do that.
Quoting:
With new VLC versions (VLC 1.1.0 and above), the thumbnails are generated with scene video filter
vlc C:\video\to\process.mp4 --rate=1 --video-filter=scene --vout=dummy --start-time=10 --stop-time=11 --scene-format=png --scene-ratio=24 --scene-prefix=snap --scene-path=C:\path\for\snapshots\ vlc://quit
If you want to get rid of the sound you can add "--aout=dummy" next to "--vout=dummy".
For older VLC versions (1.0.0 and below) the same can be done with image output module
vlc C:\video\to\process.mp4 -V image --start-time 0 --stop-time 1 --image-out-format jpg --image-out-ratio 24 --image-out-prefix snap vlc://quit
What it does:
When VLC media player runs it 'plays' the video for one second without actually showing the video on screen, and then quits, leaving us with a file named 'snap000000.jpg', containing an image of the first frame of the video.

Display PiCamera video to an embedded video player in a python program

Is there any way of embedding a video player into the GUI of a python program and then displaying video from a piCamera to it in real time?
Currently, when I preview it fills the whole screen and makes any GUI unusable.
I would like to overlay information over the video capture.
I'm not too hot on Python but on Visual Studio for example you could use the VLC plug-in and use it as a display component.
There's lots of tutorials about how to host video and stream it to a server but nothing covers local display.
Cheers.
I'm not sure if this is exactly what you are looking for, but I use RPi-Cam-Web-Interface. If you are not aware of it you may want to take a look: http://elinux.org/RPi-Cam-Web-Interface

Python/pygame - turning images into video

I am using the Pygame module in python to take pictures with my webcam. The problem is that I would like to export a video file (don't care what type) to use elsewhere. Since pygame cannot export video directly, I guess that there is two ways to do it:
Somehow stitch the photos Pygame creates into a video. (my preferred method)
Use an external library.
I only need 4 frames per second, and I don't care about the picture quality.
How can I make a video with python / pygame?
I have the same problem and am searching the solution.
I found this
This seems work well though I didn't try yet.
Hope this helps.

Breaking a video into frames with python

I am trying to write a program that deletes frames of a video that don't have a particular symbol in them. My general plan:
Split the audio from the video
Split the video into frames
Run the frames through a subroutine that looks for the symbol, by checking the pixels where it should be for being the correct color, and logging the ones that don't.
Delete those frames and corresponding audio seconds
Splices it all back together.
I need some help finding libraries that can do this. I was wondering if wxpython could do the detection of pixel color. I have no idea what library could split audio and video and which could edit audio. I know ffmpeg could split the video into frames but after two days of work I still have not been able to install it for python 2.7, so I either need a way to install it or a different library to do it. Any ideas?
wxPython is mainly for desktop GUI development. I would look at pyAudio for the audio bit or possibly one of the following:
http://xoomer.virgilio.it/sam_psy/psych/sound_proc/sound_proc_python.html
https://github.com/Rudd-O/python-audioprocessing/
http://code.google.com/p/pyo/
You might be able to use one of the Mplayer wrappers for the video:
http://pypi.python.org/pypi/MplayerCtrl/
http://code.google.com/p/python-mplayer/
Or check out that OpenCV project that Sergey mentioned:
http://opencv.willowgarage.com/documentation/python/index.html

Python Video Framework

I'm looking for a Python framework that will enable me to play video as well as draw on that video (for labeling purposes).
I've tried Pyglet, but this doesn't seem to work particularly well - when drawing on an existing video, there is flicker (even with double buffering and all of that good stuff), and there doesn't seem to be a way to get the frame index in the video during the per-frame callback (only elapsed time since the last frame).
Try a Python wrapper for OpenCV such as ctypes-opencv. The C API reference is here, and the wrapper is very close (see docstrings for any changes).
I have used it to draw on video without any flicker, so you should have no problems with that.
A rough outline of calls you need:
Load video with cvCreateFileCapture, load font with cvFont.
Grab frame with cvQueryFrame, increment your frame counter.
Draw on the frame with cvPutText, cvEllipse, etc etc.
Display to user with cvShowImage.
Qt (PyQt) has Phonon, which might help out. PyQt is available as GPL or payware. (Qt has LGPL too, but the PyQt wrappers don't)
Try the Python bindings for GStreamer.

Categories