![]() '-vcodec', 'mpeg4', outf) # output encoding '-f', 'rawvideo', '-i', '-', # tell ffmpeg to expect raw video from the pipe '-s', '%dx%d' % (canvas_width, canvas_height), # size of image string thanks to Kington for this trickį = plt.figure(frameon=False, figsize=(4, 5), dpi=100)Ĭanvas_width, canvas_height = f.canvas.get_width_height() # create a figure window that is the exact size of the image I've included that code here, but you can make standard graphs and pipe them to ffmpeg instead if you want. Basically I wanted to make a movie/animation using matplotlib code, but not have it "look like a graph". I found a solution using pure ffmpeg, which I personally find easier to use than matplotlib.animation or mencoder.Īlso, in my case, I wanted to just save the image in an axis, instead of saving all of the tick labels, figure title, figure background, etc. is correct that the bottleneck is typically the writing of the image, so if you are writing png files to your video compressor, it will be pretty slow (even if you are sending them through a pipe instead of writing to disk). build 5664)Ĭonfiguration: -prefix=/Users/paul/local_test -enable-gpl -enable-postproc -enable-swscale -enable-libxvid -enable-libx264 -enable-nonfree -mandir=/Users/paul/local_test/share/man -enable-shared -enable-pthreads -disable-indevs -cc=/usr/bin/gcc-4.2 -arch=x86_64 -extra-cflags=-I/opt/local/include -extra-ldflags=-L/opt/local/lib With compile options, FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developersīuilt on 20:42:02 with gcc 4.2.1 (Apple Inc. Lastly, I removed '-number' from Makefile to get the man pages to build. I had to manually apply the patch to libavcodec/Makefile. It would not work without the patch, which trivially modifies two files and adds libavcodec/png_parser.c. P = subprocess.Popen(cmdstring, stdin=subprocess.PIPE) After patching ffmpeg (see Joe Kington comments to my question), I was able to get piping png's to ffmpeg as follows: import subprocess
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |