Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. import subprocess as sp
  2. import numpy
  3.  
  4. print ("Hello World!");
  5. FFMPEG_BIN = "ffmpeg" # on Linux ans Mac OS
  6. #FFMPEG_BIN = "ffmpeg.exe" # on Windows
  7.  
  8. command = [ FFMPEG_BIN,
  9. '-i', '/Users/eananthaneshan/Movies/myvideo.mp4',
  10. '-f', 'image2pipe',
  11. '-pix_fmt', 'yuv444p',
  12. '-s', '420x360',
  13. '-r', '24',
  14. '-vcodec', 'h264', '-']
  15. pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=-1)
  16.  
  17. # read 420*360*3 bytes (= 1 frame)
  18. raw_image = pipe.stdout.read(420*360*3)
  19. # transform the byte read into a numpy array
  20. image = numpy.fromstring(raw_image, dtype='uint8')
  21. image = image.reshape((360,420,3) )
  22. # throw away the data in the pipe's buffer.
  23. pipe.stdout.flush()
  24.  
  25. ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
  26. built with Apple LLVM version 7.0.0 (clang-700.0.72)
  27. configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
  28. libavutil 54. 31.100 / 54. 31.100
  29. libavcodec 56. 60.100 / 56. 60.100
  30. libavformat 56. 40.101 / 56. 40.101
  31. libavdevice 56. 4.100 / 56. 4.100
  32. libavfilter 5. 40.101 / 5. 40.101
  33. libavresample 2. 1. 0 / 2. 1. 0
  34. libswscale 3. 1.101 / 3. 1.101
  35. libswresample 1. 2.101 / 1. 2.101
  36. libpostproc 53. 3.100 / 53. 3.100
  37. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/eananthaneshan/Movies/myvideo.mp4':
  38. Metadata:
  39. major_brand : isom
  40. minor_version : 1
  41. compatible_brands: isom
  42. creation_time : 2014-04-07 02:02:31
  43. Duration: 01:00:10.03, start: 0.000000, bitrate: 1024 kb/s
  44. Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 111 kb/s (default)
  45. Metadata:
  46. creation_time : 2014-04-07 02:02:31
  47. handler_name : GPAC ISO Audio Handler
  48. Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown), 720x404, 909 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
  49. Metadata:
  50. creation_time : 2014-04-07 01:14:58
  51. handler_name : L-SMASH Video Media Handler
  52. encoder : AVC Coding
  53. Output #0, image2pipe, to 'pipe:':
  54. Metadata:
  55. major_brand : isom
  56. minor_version : 1
  57. compatible_brands: isom
  58. encoder : Lavf56.40.101
  59. Stream #0:0(und): Video: rawvideo (444P / 0x50343434), yuv444p, 420x360, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
  60. Metadata:
  61. creation_time : 2014-04-07 01:14:58
  62. handler_name : L-SMASH Video Media Handler
  63. encoder : Lavc56.60.100 rawvideo
  64. Stream mapping:
  65. Stream #0:1 -> #0:0 (h264 (native) -> rawvideo (native))
  66. Press [q] to stop, [?] for help
  67. av_interleaved_write_frame(): Broken pipe
  68. frame= 2 fps=0.0 q=-0.0 Lsize= 886kB time=00:00:00.08 bitrate=87003.8kbits/s
  69. video:886kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
  70. Conversion failed!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement