2

How can I quickly determine positions in a video? For example, I have a video file and it looks like this.

enter image description here

I want to crop the video and get the part in the black box as a new video using ffmpeg. But first I need to get the upper left corner position of the black box and its width and height. How can I do this easily? Right now this is what I did. First I use ffprobe to get the actual video size:

I:\tutorial\Juggling - Step By Step [4 Vols]>ffprobe "Juggling - Step by Step (2 of 4) [VHS-Rip].avi"
ffprobe version N-103679-g7bbad32d5a-20210918 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10-win32 (GCC) 20210408
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20210918
  libavutil      57.  5.101 / 57.  5.101
  libavcodec     59.  7.103 / 59.  7.103
  libavformat    59.  5.100 / 59.  5.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  9.100 /  8.  9.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, avi, from 'Juggling - Step by Step (2 of 4) [VHS-Rip].avi':
  Metadata:
    software        : VirtualDubMod 1.5.4.1 (build 2178/release)
  Duration: 00:33:09.92, start: 0.000000, bitrate: 1266 kb/s
  Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 448x336 [SAR 1:1 DAR 4:3], 1116 kb/s, 25 fps, 25 tbr, 25 tbn
  Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 137 kb/s

I:\tutorial\Juggling - Step By Step [4 Vols]>

As you can see, this video is 448x336. Now I manually set my video player window size to 448x336.

enter image description here enter image description here

Then I use a tool called Golden Section, which is used to draw rectangles on the screen. I make it overlay over the video player like this: enter image description here

And I take a screenshot and paste into mspaint. enter image description here

Then I use Golden Section again to measure the black box position and size in mspaint.

enter image description here

Here as you can see, the upper left point of the black box is (130, 96). I can get the width & height of the black box using the same method.

As you can see, this process is way too complex! Is there an easier way? Thanks.

Just a learner
  • 481
  • 1
  • 6
  • 20

1 Answers1

1

Your method is indeed over-complicated.

I suggest to take a screenshot of the video window (without the border) and use an image editor for finding the coordinates (they are displayed in most image editors when your cursor is moving inside the image).

This should be much simpler.

harrymc
  • 455,459
  • 31
  • 526
  • 924