Statnet-Summer-Project / ndtv-shiny

R-Shiny interface for ndtv package
GNU General Public License v3.0
1 stars 5 forks source link

saveVedio displays black movie #2

Closed kecoli closed 10 years ago

kecoli commented 10 years ago

TBA

skyebend commented 10 years ago

can you provide some more information? What was the command that was being run? :-)

skyebend commented 10 years ago

whoops, didn't mean to close it when I commented.

kecoli commented 10 years ago

Hi, Skye,

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] ndtv_0.5.1           sna_2.3-2           
[3] animation_2.2        networkDynamic_0.6.3
[5] network_1.9.0       

loaded via a namespace (and not attached):
[1] statnet.common_3.2-12564.1-2014.02.03-23.53.39
[2] tools_3.1.0  

I used with latest FFmpeg Latest Zeranoe FFmpeg Build Version: git-7e8fdf0 (2014-06-26)

ani.options(outdir=getwd())

saveVideo({
  par(mar = c(3, 3, 1, 0.5), mgp = c(2, 0.5, 0), tcl = -0.3, cex.axis = 0.8, cex.lab = 0.8, 
      cex.main = 1)
  ani.options(interval = 0.05, nmax = 300)
  brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow")
}, video.name = "BM.mp4", other.opts = "-b 300k")  # higher bitrate, better quality
kecoli commented 10 years ago

Yixi and Tongfang also encountered the same problem.

skyebend commented 10 years ago

Ok, this is the example off the saveVideo help page, right? It works for me. Do you see output from ffmepg on the R console? I wonder if it is some issue with the path to ffmpeg? Usually on windows I have to edit the system Path to put ffmpeg on it. Or it seems you can set the path via ani.oopts as in the example. What do you get with

Sys.which('ffmpeg')

kecoli commented 10 years ago

Hi Skye, this is the example off the saveVideo help page, right? Yes

> Sys.which('ffmpeg')
                               ffmpeg 
"C:\\Rtools\\ffmpeg\\bin\\ffmpeg.exe" 

I can see the animation from R console, and I do find the batch of png files at

C:\Users\kecoli\AppData\Local\Temp\RtmpsXOO9X/Rplot%d.png

The output of the code:

animation option 'nmax' changed: 50 --> 300
Executing: "ffmpeg" -y -r 20 -i C:\Users\kecoli\AppData\Local\Temp\RtmpsXOO9X/Rplot%d.png  BM.mp4
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov 20 2013 21:13:48 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, image2, from 'C:\Users\kecoli\AppData\Local\Temp\RtmpsXOO9X/Rplot%d.png':
  Duration: 00:00:12.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, pal8, 480x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 000000000415ab60] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 000000000415ab60] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 000000000415ab60] 264 - core 140 r2377 1ca7bb9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=20 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'BM.mp4':
  Metadata:
    encoder         : Lavf55.19.104
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 480x480, q=-1--1, 10240 tbn, 20 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> libx264)
Press [q] to stop, [?] for help
frame=  300 fps=0.0 q=-1.0 Lsize=     282kB time=00:00:14.90 bitrate= 155.2kbits/s    
video:278kB audio:0kB subtitle:0 global headers:0kB muxing overhead 1.477713%
[libx264 @ 000000000415ab60] frame I:2     Avg QP:19.40  size:  6009
[libx264 @ 000000000415ab60] frame P:124   Avg QP:16.84  size:  1464
[libx264 @ 000000000415ab60] frame B:174   Avg QP:25.49  size:   520
[libx264 @ 000000000415ab60] consecutive B-frames: 16.7% 16.7%  4.0% 62.7%
[libx264 @ 000000000415ab60] mb I  I16..4: 16.7% 75.1%  8.2%
[libx264 @ 000000000415ab60] mb P  I16..4:  1.2%  2.1%  1.6%  P16..4:  2.6%  0.8%  0.2%  0.0%  0.0%    skip:91.6%
[libx264 @ 000000000415ab60] mb B  I16..4:  0.0%  0.2%  0.3%  B16..8:  6.7%  1.1%  0.1%  direct: 0.1%  skip:91.5%  L0:50.7% L1:46.8% BI: 2.5%
[libx264 @ 000000000415ab60] 8x8 transform intra:49.4% inter:10.1%
[libx264 @ 000000000415ab60] coded y,u,v intra: 17.1% 16.7% 16.5% inter: 0.2% 0.2% 0.2%
[libx264 @ 000000000415ab60] i16 v,h,dc,p: 73% 25%  2%  0%
[libx264 @ 000000000415ab60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34%  4% 62%  0%  0%  0%  0%  0%  0%
[libx264 @ 000000000415ab60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 14% 49%  3%  3%  4%  4%  4%  3%
[libx264 @ 000000000415ab60] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000000000415ab60] ref P L0: 69.9%  3.4% 16.1% 10.6%
[libx264 @ 000000000415ab60] ref B L0: 82.4% 13.7%  4.0%
[libx264 @ 000000000415ab60] ref B L1: 94.9%  5.1%
[libx264 @ 000000000415ab60] kb/s:151.52

Video has been created at: C:\Users\kecoli\Documents\ndtv-shiny\BM.mp4
animation option 'nmax' changed: 300 --> 50

I can find the BM.mp4 at local path, and I committed it in ndtv-shiny respository as well. https://github.com/Statnet-Summer-Project/ndtv-shiny/blob/master/BM.mp4

skyebend commented 10 years ago

OK, so it it generating the movie, but there are problems with the video format.

noticed this in the ffmpeg output:

No pixel format specified, yuv444p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players.

which makes me think it might be a variant of the ffmpeg pixel format bug https://statnet.csde.washington.edu/trac/ticket/711

Maybe adding

other.opts='-pix_fmt yuv420p"

to saveVideo() will work around the problem?

I opened a ticket for this with the animation library author: https://github.com/yihui/animation/issues/49

kecoli commented 10 years ago

Yep,

Adding

other.opts='-pix_fmt yuv420p"

works !

I should have noticed this from the output

Thanks Skye.

Best

skyebend commented 10 years ago

maybe if you add a 'me too' comment on https://github.com/yihui/animation/issues/49 saying that the example for saveVideo() gives black output they may be able to come up with a solution.

TongfangInCafe commented 10 years ago

Thank you very much, Kirk and Skye!

Skye Bender-deMoll notifications@github.com于2014年6月26日星期四写道:

Closed #2 https://github.com/Statnet-Summer-Project/ndtv-shiny/issues/2.

— Reply to this email directly or view it on GitHub https://github.com/Statnet-Summer-Project/ndtv-shiny/issues/2#event-135636915 .