diego3g / video-to-reels

Automatically edit videos to post on Instagram Reels
678 stars 110 forks source link

Error when video has different resolutions #3

Open birobirobiro opened 2 years ago

birobirobiro commented 2 years ago

The video used in the example below has a resolution of 1080x1920.

Even changing the output resolution and inside the calculate-cuts.mjs file

https://user-images.githubusercontent.com/22185823/156855998-d481340c-2db4-4cb2-90ae-b354071bfb22.mp4


The error shown in video:

birobirobiro in video-to-reels on  feat/new-filters [!] took 6s 
❯ zx convert.mjs
Qual a pergunta? 
Biro bebe cafe?
$ ls ./assets/filters/
01.CUBE
02.CUBE
arabica.CUBE
ava.CUBE
azrael.CUBE
bourbon.CUBE
byers.CUBE
chemical.CUBE
clayton.CUBE
clouseau.CUBE
cobi.CUBE
contrail.CUBE
cubicle.CUBE
django.CUBE
domingo.CUBE
faded.CUBE
folger.CUBE
fusion.CUBE
hyla.CUBE
korben.CUBE
lenox.CUBE
lucky.CUBE
mckinnon.CUBE
milo.CUBE
neon.CUBE
paladin.CUBE
pasadena.CUBE
pitaya.CUBE
reeve.CUBE
remy.CUBE
sprocket.CUBE
teigen.CUBE
trent.CUBE
tweed.CUBE
vireo.CUBE
zed.CUBE
zeke.CUBE

Escolha um dos filtros acima e digite o nome abaixo (sem a extensão .CUBE): 
zeke

Digite o nome do arquivo a ser salvo: 
birobirobiro
$ 
>   convert     -font assets/roboto.ttf     -fill black     -pointsize 48     -gravity center     -annotate +10+95 @tmp/text.txt     assets/overlay.png     tmp/question.png
$ 
>   ffmpeg -y     -i origins/biro.mp4     -vf "transpose=1"     -frames:v 1     tmp/frame.png
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.0.0 (clang-1300.0.29.30)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'origins/biro.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:10.01, start: 0.000000, bitrate: 6342 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, 6208 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default)
    Metadata:
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> png (native))
Press [q] to stop, [?] for help
[swscaler @ 0x120828000] [swscaler @ 0x1101e8000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x130550000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x130560000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x130570000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x130580000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x130590000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x1305a0000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x128818000] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler @ 0x120828000] [swscaler @ 0x1305c0000] No accelerated colorspace conversion found from yuv420p to rgb24.
Output #0, image2, to 'tmp/frame.png':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.16.100
  Stream #0:0(und): Video: png, rgb24(pc, gbr/bt709/bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 59.94 fps, 59.94 tbn (default)
    Metadata:
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.18.100 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.01 bitrate=N/A speed=0.108x    
video:1886kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
$ node detect-face/face-detection.js
FaceAPI single-process test
Version: TensorFlow/JS 3.13.0 FaceAPI undefined Backend: tensorflow
Loading FaceAPI models
Detected faces: 0
file:///Users/birobirobiro/www/side-projects/video-to-reels/utils/calculate-cuts.mjs:9
  const originalHeight = faceResult._imageDims._height;
                                    ^

TypeError: Cannot read properties of undefined (reading '_imageDims')
    at calculateCuts (file:///Users/birobirobiro/www/side-projects/video-to-reels/utils/calculate-cuts.mjs:9:37)
    at file:///Users/birobirobiro/www/side-projects/video-to-reels/convert.mjs:64:13 
joaogelado commented 2 years ago

Apparently, TensorFlow couldn't detect any face, so it does not return values and the calculate-cuts function doesn't find them