teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

ffmpegのバージョン

2018/11/06 07:10

投稿

ruei
ruei

スコア284

title CHANGED
File without changes
body CHANGED
@@ -65,4 +65,24 @@
65
65
  >>> import matplotlib
66
66
  >>> matplotlib.__version__
67
67
  '2.2.2'
68
+ ```
69
+
70
+ ```
71
+ ffmpeg
72
+ ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
73
+ built with gcc 7.2.0 (crosstool-NG fa8859cb)
74
+ configuration: --prefix=/home/usr/anaconda3 --cc=/tmp/build/80754af9/ffmpeg_1526323631431/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-shared --enable-static --enable-zlib --enable-pic --enable-gpl --enable-version3 --disable-nonfree --enable-hardcoded-tables --enable-avresample --enable-libfreetype --disable-openssl --disable-gnutls --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --disable-libx264
75
+ libavutil 56. 14.100 / 56. 14.100
76
+ libavcodec 58. 18.100 / 58. 18.100
77
+ libavformat 58. 12.100 / 58. 12.100
78
+ libavdevice 58. 3.100 / 58. 3.100
79
+ libavfilter 7. 16.100 / 7. 16.100
80
+ libavresample 4. 0. 0 / 4. 0. 0
81
+ libswscale 5. 1.100 / 5. 1.100
82
+ libswresample 3. 1.100 / 3. 1.100
83
+ libpostproc 55. 1.100 / 55. 1.100
84
+ Hyper fast Audio and Video encoder
85
+ usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
86
+
87
+ Use -h to get full help or, even better, run 'man ffmpeg'
68
88
  ```

1

単体で動くコードに変更

2018/11/06 07:10

投稿

ruei
ruei

スコア284

title CHANGED
File without changes
body CHANGED
@@ -1,49 +1,57 @@
1
1
  次のようなプロットを動画として出力するコードを動かすと
2
2
  ```python
3
+ import matplotlib
4
+ matplotlib.use('Agg')
5
+ import random
6
+ import matplotlib.animation as animation
7
+ import matplotlib.pyplot as plt
8
+
9
+
3
- def plotEfield(self):
10
+ def run():
11
+
4
- def update(k, Ex, Ey):
12
+ def update(k, ax):
5
13
  ax.clear()
14
+ X=[1,2,3,4]
15
+ Y=[random.random() for i in range(len(X))]
6
- ax.plot(X[k], Y[k])
16
+ ax.plot(X,Y)
7
- fig, ax = plt.subplots(1, 1)
17
+ fig,ax=plt.subplots(1,1)
18
+ ani = animation.FuncAnimation(fig, update, fargs=[ax,], interval=50, frames=10)
19
+ ani.save("hogehoge.mp4", writer="ffmpeg")
8
20
 
21
+
9
- # アニメーション作成
22
+ run()
10
- # interval [ms]毎に画像が切り替わる。
23
+
11
- # framse回、画像を更新する。updateの第一引数は0,1,2,...,frames-1を動く。
12
- ani = animation.FuncAnimation(fig, update, fargs=[Ax, Ay], interval=50, frames=10)
13
- ani.save("hogehoge.mp4", writer="ffmpeg")
14
24
  ```
15
25
  下記のエラーが出ます。
16
26
  ```
17
27
  Traceback (most recent call last):
18
- File "input.py", line 39, in <module>
28
+ File "main.py", line 20, in <module>
19
- run()
29
+ run()
20
- File "input.py", line 32, in run
30
+ File "main.py", line 17, in run
21
- xyplane1.plotEfield()
22
- File "/home/usr/plot.py", line 266, in plotEfield
23
- ani.save("hogehoge.mp4", writer="ffmpeg")
31
+ ani.save("hogehoge.mp4", writer="ffmpeg")
24
- File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 1200, in save
32
+ File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 1200, in save
25
- writer.grab_frame(**savefig_kwargs)
33
+ writer.grab_frame(**savefig_kwargs)
26
- File "/home/usr/anaconda3/lib/python3.6/contextlib.py", line 99, in __exit__
34
+ File "/home/usr/anaconda3/lib/python3.6/contextlib.py", line 99, in __exit__
27
- self.gen.throw(type, value, traceback)
35
+ self.gen.throw(type, value, traceback)
28
- File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 241, in saving
36
+ File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 241, in saving
29
- self.finish()
37
+ self.finish()
30
- File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 367, in finish
38
+ File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 367, in finish
31
- self.cleanup()
39
+ self.cleanup()
32
- File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 405, in cleanup
40
+ File "/home/usr/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 405, in cleanup
33
- out, err = self._proc.communicate()
41
+ out, err = self._proc.communicate()
34
- File "/home/usr/anaconda3/lib/python3.6/subprocess.py", line 843, in communicate
42
+ File "/home/usr/anaconda3/lib/python3.6/subprocess.py", line 843, in communicate
35
- stdout, stderr = self._communicate(input, endtime, timeout)
43
+ stdout, stderr = self._communicate(input, endtime, timeout)
36
- File "/home/usr/anaconda3/lib/python3.6/subprocess.py", line 1505, in _communicate
44
+ File "/home/usr/anaconda3/lib/python3.6/subprocess.py", line 1505, in _communicate
37
- selector.register(self.stdout, selectors.EVENT_READ)
45
+ selector.register(self.stdout, selectors.EVENT_READ)
38
- File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 351, in register
46
+ File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 351, in register
39
- key = super().register(fileobj, events, data)
47
+ key = super().register(fileobj, events, data)
40
- File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 237, in register
48
+ File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 237, in register
41
- key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data)
49
+ key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data)
42
- File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 224, in _fileobj_lookup
50
+ File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 224, in _fileobj_lookup
43
- return _fileobj_to_fd(fileobj)
51
+ return _fileobj_to_fd(fileobj)
44
- File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd
52
+ File "/home/usr/anaconda3/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd
45
- "{!r}".format(fileobj)) from None
53
+ "{!r}".format(fileobj)) from None
46
- ValueError: Invalid file object: <_io.BufferedReader name=11>
54
+ ValueError: Invalid file object: <_io.BufferedReader name=6>
47
55
  ```
48
56
 
49
57
  環境は次の通りです。