ropensci / av

Working with Video in R
https://docs.ropensci.org/av
Other
92 stars 10 forks source link

av_encode_video: height not divisible by 2 #31

Closed elgabbas closed 4 years ago

elgabbas commented 4 years ago

Hello,

I am trying to convert many JPEG files into a video using the av_encode_video function. I received the following error message:

deprecated pixel format used, make sure you did set range correctly
height not divisible by 2 (8550x2925)
Error: FFMPEG error in 'avcodec_open2': Generic error in an external library

I found some solutions (e.g. this and this) but no solution using R. Can this error message be solved using R?

The same simple code I used works fine for other image sets (with different image size).

Cheers, Ahmed

muschellij2 commented 4 years ago

Duplicate of https://github.com/ropensci/av/issues/2

muschellij2 commented 4 years ago

Have you tried:

av::av_encode_video(vfilter = "scale=trunc(iw/2)*2:trunc(ih/2)*2")
elgabbas commented 4 years ago

Thanks @muschellij2 for your response. Now, I do not receive the same error, but the produced video does not work. I tried it on two different PCs. Below you find the output.

deprecated pixel format used, make sure you did set range correctly
MB rate (97905000) > level limit (16711680)
using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
profile High, level 6.2, 4:2:0, 8-bit
264 - core 159 r2991M 1771b55 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=9 lookahead_threads=1 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=25 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 'Video1.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 8550x2924, q=-1--1, 90k tbn
Adding frame 366 at timestamp 182.50sec (99%) - video stream completed!
frame I:2     Avg QP: 9.10  size:966348
frame P:97    Avg QP:11.08  size:351413
frame B:267   Avg QP:16.01  size:193829
consecutive B-frames:  1.6%  2.7%  1.6% 94.0%
mb I  I16..4: 25.7% 61.1% 13.2%
mb P  I16..4:  2.8%  7.4%  2.1%  P16..4:  5.6%  3.2%  2.3%  0.0%  0.0%    skip:76.6%
mb B  I16..4:  0.2%  0.8%  0.5%  B16..8:  6.0%  3.0%  1.6%  direct: 2.9%  skip:85.1%  L0:44.4% L1:46.4% BI: 9.2%
8x8 transform intra:59.0% inter:58.2%
coded y,uvDC,uvAC intra: 49.7% 29.2% 28.1% inter: 6.1% 4.2% 3.0%
i16 v,h,dc,p: 80% 11%  5%  5%
i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 15% 28%  3%  4%  4%  4%  3%  5%
i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 25% 16%  5%  6%  4%  5%  3%  4%
i8c dc,h,v,p: 81%  9%  7%  3%
Weighted P-Frames: Y:0.0% UV:0.0%
ref P L0: 47.1%  8.2% 31.5% 13.2%
ref B L0: 77.1% 18.1%  4.7%
ref B L1: 92.7%  7.3%
kb/s:3837.03
elgabbas commented 4 years ago

This works for me vfilter = "scale='bitand(oh*dar, 65534)':'bitand(ih/2, 65534)', setsar=1". I am naive to FFmpeg and do not know the difference, but it works anyway! Thanks