Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg_renderer failing in animate #483

Closed
rressler opened this issue Aug 3, 2023 · 2 comments
Closed

ffmpeg_renderer failing in animate #483

rressler opened this issue Aug 3, 2023 · 2 comments

Comments

@rressler
Copy link

rressler commented Aug 3, 2023

I am trying to use gganimate to render an mp4 with code that worked several months ago but now fails with error.

p2 is a ggplot2 plot where animate(p2, nframes = 120) works fine to produce a gif. However, running the following

animate( plot = p2, renderer = ffmpeg_renderer(format = "mp4"))

produces

Error: Rendering with ffmpeg failed.

Traceback shows
4. stop("Rendering with ffmpeg failed", call. = FALSE)
3. args$renderer(frames_vars$frame_source, args$fps)
2. animate.gganim(plot = p2, renderer = ffmpeg_renderer(format = "mp4"))

  1. animate(plot = p2, renderer = ffmpeg_renderer(format = "mp4"))

I am operating on a mac M2 with gganimate version 1.08.

ffmpeg appears to be installed properly as entering the following in a terminal window does work.

ffmpeg -i my_gapminder.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" my_gapminder.mp4

Appreciate any suggestions.

@thomasp85 thomasp85 added the bug label Aug 30, 2023
@thomasp85
Copy link
Owner

I cannot reproduce this. The ffmpeg renderer throws this error if the output file does not appear after rendering so maybe there is an issue with write permissions on your disk?

@rressler
Copy link
Author

Tom,
Thanks for the review. Without changing anything, it worked today with the output below. I am not sure what may have changed in the use of the temp folder that enabled it to work. One of those Mac mysteries I guess.
Thanks for the assist.
Richard

Show in New Window
Inserting image 120 at 11.90s (100%)...
Encoding to gif... done!
Show in New Window
Input #0, image2, from '/var/folders/_7/4_9z3s852cng3ktlr0pvn99h0000gn/T//RtmpfQuNM8/60704c9dd73a/gganim_plot%4d.png':
Duration: 00:00:04.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 480x480, 25 fps, 25 tbr, 25 tbn
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x120e1b600] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x120e1b600] profile High, level 2.2, 4:2:0, 8-bit
[libx264 @ 0x120e1b600] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - 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=-2 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=10 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 '/var/folders/_7/4_9z3s852cng3ktlr0pvn99h0000gn/T//RtmpfQuNM8/file6070e9d4822.mp4':
Metadata:
encoder : Lavf60.3.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 480x480, q=2-31, 10 fps, 10240 tbn
Metadata:
encoder : Lavc60.3.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 100 fps=0.0 q=-1.0 Lsize= 127kB time=00:00:09.70 bitrate= 107.2kbits/s speed=70.7x
video:125kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.589969%
[libx264 @ 0x120e1b600] frame I:1 Avg QP:15.91 size: 21930
[libx264 @ 0x120e1b600] frame P:27 Avg QP:19.51 size: 2805
[libx264 @ 0x120e1b600] frame B:72 Avg QP:28.69 size: 411
[libx264 @ 0x120e1b600] consecutive B-frames: 1.0% 6.0% 9.0% 84.0%
[libx264 @ 0x120e1b600] mb I I16..4: 36.4% 25.6% 38.0%
[libx264 @ 0x120e1b600] mb P I16..4: 0.2% 0.1% 1.6% P16..4: 2.8% 1.3% 2.2% 0.0% 0.0% skip:91.7%
[libx264 @ 0x120e1b600] mb B I16..4: 0.0% 0.3% 0.1% B16..8: 3.3% 0.4% 0.4% direct: 0.1% skip:95.3% L0:55.8% L1:38.0% BI: 6.2%
[libx264 @ 0x120e1b600] 8x8 transform intra:26.6% inter:13.4%
[libx264 @ 0x120e1b600] coded y,uvDC,uvAC intra: 47.2% 30.2% 28.3% inter: 1.0% 0.4% 0.4%
[libx264 @ 0x120e1b600] i16 v,h,dc,p: 94% 5% 1% 0%
[libx264 @ 0x120e1b600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 4% 53% 0% 0% 0% 0% 0% 0%
[libx264 @ 0x120e1b600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48% 14% 9% 4% 5% 5% 5% 4% 5%
[libx264 @ 0x120e1b600] i8c dc,h,v,p: 83% 5% 7% 4%
[libx264 @ 0x120e1b600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x120e1b600] ref P L0: 77.5% 10.0% 8.9% 3.7%
[libx264 @ 0x120e1b600] ref B L0: 78.0% 19.2% 2.9%
[libx264 @ 0x120e1b600] ref B L1: 93.6% 6.4%
[libx264 @ 0x120e1b600] kb/s:101.79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants