But I'd like to first ask how you get the cursor position when you're
viewing an MP4 on Windows (so that I can put them into the ffmpeg command)?
On 16.11.2024 18:22, Oliver wrote:
But I'd like to first ask how you get the cursor position when you're
viewing an MP4 on Windows (so that I can put them into the ffmpeg command)?
I don't know which video player you use. I use Potplayer and there you
just press <CTRL>-C to copy the current frame into the clip board
(in VLC player you can use the pull down menu to save the picture).
Then in IrfanView do a <CTRL>-V and select the region you want, the coordinates are displayed in the title bar.
On Sat, 16 Nov 2024 23:14:54 +0100, Herbert Kleebauer <klee@unibwm.de>
wrote
On 16.11.2024 18:22, Oliver wrote:
But I'd like to first ask how you get the cursor position when you're
viewing an MP4 on Windows (so that I can put them into the ffmpeg
command)?
I don't know which video player you use. I use Potplayer and there you
just press <CTRL>-C to copy the current frame into the clip board
(in VLC player you can use the pull down menu to save the picture).
Then in IrfanView do a <CTRL>-V and select the region you want, the
coordinates are displayed in the title bar.
Thanks for trying to help because what I want to do is both simple & complicated at the same time. It's something almost nobody does and
something everyone who uploads videos has to do at the same time.
These videos are for Amazon reviews where Amazon gives me free stuff to review but I have to do the reviews and I'm trying to do a good job.
So I generally upload one video with every review (you can't upload more
than one video although you can upload plenty of photos in each review).
To answer your kind questions... My image viewer is the same one almost everyone uses, which is Irfanview.
My media player is the same one almost everyone uses, which is MPC-BE. Although I sometimes use VLC when I watch movies (usually with subtitles). Just like everyone else does - so I'm not unusual in any way shape or form.
I solved the problem that I had asked in this thread before I saw your helpful answer to copy a frame and then grab the coordinates in Irfanview & then use ffmpeg to crop to those coordinates. That should work I'm sure.
In reality I was hoping for a purely graphical "draw a box" solution.
But I found a solution which is kind of sort of but not exactly that.
As stated in the opening post, this is how to crop in ffmpeg but you need
to already know what the draw-the-box pixels are going to be ahead of time. https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video- with-ffmpeg
ffplay -i in.mp4 -vf "crop=80:60:200:100"
ffmpeg -i in.mp4 -vf "crop=80:60:200:100" -c:a copy out.mp4
In googling for a graphical way to "draw the box", I found this site. https://superuser.com/questions/510985/how-can-i-crop-a-video-to-a-part- of-the-view
We can use Handbrake to draw the box kind of sort of but not exactly.
I had to install Handbrake 1.8.2 which also required Net 8.0 on Windows. https://handbrake.fr/docs/en/latest/get-handbrake/download-and-install.html https://handbrake.fr/rotation.php?file=HandBrake-1.8.2-x86_64-Win_GUI.exe
Handbrake 1.8.2 required Windows dotNet 8.0 but it got it for me. https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime- desktop-8.0.11-windows-x64-installer?cid=getdotnetcore
Then I followed the instructions for drawing the crop box from here. https://www.tweaking4all.com/video/handbrake-trim-crop-rotate-video/
That is, with Handbrake 1.8.2 on Windows 10, I did the following.
a. I opened the 1920x1080 in.mp4 phone video with Handbrake 1.8.2
b. I clicked the Handbrake 1.8.2 "Dimensions" tab
c. I changed the Dimensions tab "Cropping" from "Automatic" to "Custom"
d. I pressed the Handbrake "Preview" button on the top bar e. It failed
with a popup asking me to check "Use External Player App"
f. I checked "Use External Player App" & pressed the popup "Close" button
g. For my video, I set the four crop dimensions manually to:
Top = 0
Bottom = 350
Left = 600
Right = 500
This part was sort of graphical but really more like trial & error.
h. Once I had the dimensions set, I checked it out with the preview slider
i. Then I got ready to save by clicking the "Summary" tab
Set Format = MP4
[x]Web Optimized
[x]Align A/V Start
i. I changed the "Save As" line to the desired path & name (out.mp4)
j. Finally I hit the "File > Start Encode" menu item & waited for results
k. When I watched the results I was happy with them.
l. But I needed to concatenate a second video which needed to be cropped.
m. Without closing Handbrake 1.8.2 I opened that second (shorter) video
n. Darn. The Dimensions reverted to the default so I changed them back.
o. I followed the saving procedure to save the second cropped mp4 file
p. Then I merged the two files. It wasn't seamless. But it was close.
echo file out.mp4 > mylist.txt echo file out2.mp4 >> mylist.txt
ffmpeg -f concat -i mylist.txt -c copy output.mp4
q. Now I have to remove the metadata (if any)
ffmpeg -i output.mp4 -map 0 -map_metadata -1 -c copy output1.mp4
r. I deshaked the video (deshook?) although it wasn't too shaky
ffmpeg -i output1.mp4 -vf deshake output2.mp4
s. While that was running I manually created dummy captions
gVim output2.srt
1
00:00:10,000 --> 00:00:15,000
This is the first caption
2
00:00:25,000 --> 00:00:50,000
This is the second caption
3
00:01:00,000 --> 00:01:15,000
This is the third caption
4
00:01:20,000 --> 00:01:30,000
This is the fourth caption
t. I tested the dummy captions by playing output2.mp4 in MPC-BE
and then I adjusted the captions to the actual desired captions.
u. I then burned those captions into the video for a single upload.
ffmpeg -i output2.mp4 -vf subtitles=output2.srt output3.mp4
The result is a single video that has the offending person cropped out!
Thanks for your kind help which I very much appreciate since these kinds of video edits are both common and unusual at the same time.
Basically, anyone uploading videos to the Amazon reviews who still wants to maintain a bit of privacy (so there is no voice in the video) needs this.
The good news is I hope someone finds a much better way to crop the video because what I wanted was just to draw a box and then say "crop to it!".
But I'd like to first ask how you get the cursor position when you'reI don't know which video player you use. I use Potplayer and there you
viewing an MP4 on Windows (so that I can put them into the ffmpeg command)? >>
just press <CTRL>-C to copy the current frame into the clip board
As stated in the opening post, this is how to crop in ffmpeg but you need
to already know what the draw-the-box pixels are going to be ahead of time. https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg
ffplay -i in.mp4 -vf "crop=80:60:200:100"
ffmpeg -i in.mp4 -vf "crop=80:60:200:100" -c:a copy out.mp4
In googling for a graphical way to "draw the box", I found this site. https://superuser.com/questions/510985/how-can-i-crop-a-video-to-a-part-of-the-view
We can use Handbrake to draw the box kind of sort of but not exactly.
I had to install Handbrake 1.8.2 which also required Net 8.0 on Windows.
I had to install Handbrake 1.8.2 which also required Net 8.0 on Windows.
I don't understand why it is easier to install new software instead
of using the already installed IrfanView.
1. Open the video in your player and copy one video frame
to the clipboard (for the Potplayer this is just a <CTRL>-C).
You can close the player then. You can also start the player
in the batch if you want.
2. Execute this batch:
(I use the ini file in IrfanView, if you use the registry you have
to modify the batch. You also have to use the correct path to Irfanview).
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
start /w "" D:\Programme\IrfanView\i_view32.exe /clippaste
for %%k in (CustSelX CustSelY CustSelW CustSelH) do (
for /f "delims=." %%i in ('find "%%k=" ^<D:\Programme\IrfanView\i_view32.ini') do set %%i
)
echo ffmpeg -i in.mp4 -vf "crop=%CustSelX%:%CustSelY%:%CustSelW%:%CustSelH%" -c:a copy out.mp4
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
After IrfanView is started and the video frame is displayed,
use the left mouse button to select the the crop region. You can
change the size with the left mouse button or move the region with
the right mouse button. Then press <SHIFT>-C and then "Save values and exit". Then close IrfanView. The batch then executes the ffmpeg command.
On Mon, 18 Nov 2024 01:07:17 +0100, Herbert Kleebauer <klee@unibwm.de> wrote
In MPC-BE (which most people use)
there doesn't seem to be a way to save
the frame to a file. A Windows print-screen would be all wrong.
Luckily in VLC (which most people also use) there is an option
VLC:Video > Take snapshot" which puts a single-frame grab into C:\Users\you\Pictures\vlcsnap-2024-11-17-18h08m36s459.png
I'm not sure how to get that video frame into the clipboard though.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
start /w "" D:\Programme\IrfanView\i_view32.exe /clippaste
for %%k in (CustSelX CustSelY CustSelW CustSelH) do (
for /f "delims=." %%i in ('find "%%k=" ^<D:\Programme\IrfanView\i_view32.ini') do set %%i
)
echo ffmpeg -i in.mp4 -vf "crop=%CustSelX%:%CustSelY%:%CustSelW%:%CustSelH%" -c:a copy out.mp4
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
When I open the VLC frame grab in Irfanview, I can leftmouse crop the
area I want to crop the entire video to as you suggest I do.
When I'm done drawing the crop rectangle of the VLC frame grab in
Irfanview, on top of Irfanview is displayed the coordinates of that crop.
XY:(953,1080) (850x1080 Pixels, 0.787)
All I need now is the X:Y coordinate of the starting point of that line. Unfortunately, Irfanview doesn't give me the starting X:Y coordinates.
This is clipcrop.bat as it had to be modified to fit my system setup.
for /f "delims=." %%i in ('find "%%k=" ^C:\app\editor\pic\iview\i_view64.ini') do set %%i
Environment variable ---------- C:\PATH\IVIEW\I_VIEW64 not defined
I'll write up a simpler description after I post this so that we don't lose the issues that came up when running the process using VLC instead of Potplayer as the main problem I had was getting the frame into the
clipboard. If there is an easier way to do that, I'm all ears.
You are perfect in doing easy things in a complicated way.
In MPC-BE (which most people use)
I never heard of MPC-BE. I use the portable version of PotPlayer
(formerly KMplayer) since many decades and most probably will
never use anything else (it is made to make complicated things
easy and not to make easy things complicated).
I also have a portable version of VLC, because this is the
only player I know, which can read the video from stdin.
This allows to store private videos encrypted on the disk
and play them without first generating a decrypted version
on the disk. https://onlib.de/pub/pfv/
there doesn't seem to be a way to save
the frame to a file. A Windows print-screen would be all wrong.
If your screen is large enough to display the video in original
size and you don't care about a few pixels off, you can take
a screenshot with the snipping tool (<WIN>-<SHIFT>-S) to store
the picture in the clip board.
Luckily in VLC (which most people also use) there is an option
VLC:Video > Take snapshot" which puts a single-frame grab into
C:\Users\you\Pictures\vlcsnap-2024-11-17-18h08m36s459.png
I'm not sure how to get that video frame into the clipboard though.
No need to get the picture into the clipboard, just replace
the line:
start /w "" D:\Programme\IrfanView\i_view32.exe /clippaste
by:
start /w "" D:\Programme\IrfanView\i_view32.exe d:/your-path/name.jpg
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
start /w "" D:\Programme\IrfanView\i_view32.exe /clippaste
for %%k in (CustSelX CustSelY CustSelW CustSelH) do (
for /f "delims=." %%i in ('find "%%k=" ^<D:\Programme\IrfanView\i_view32.ini') do set %%i
)
echo ffmpeg -i in.mp4 -vf "crop=%CustSelX%:%CustSelY%:%CustSelW%:%CustSelH%" -c:a copy out.mp4
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
When I open the VLC frame grab in Irfanview, I can leftmouse crop the
area I want to crop the entire video to as you suggest I do.
When I'm done drawing the crop rectangle of the VLC frame grab in
Irfanview, on top of Irfanview is displayed the coordinates of that crop.
XY:(953,1080) (850x1080 Pixels, 0.787)
All I need now is the X:Y coordinate of the starting point of that line.
Unfortunately, Irfanview doesn't give me the starting X:Y coordinates.
Just above you wrote, IrfanView displays the starting coordinates XY:(953,1080). But you don't need to transfer them manually to
the ffmpeg command, the batch extracts that in formation from
the ini file.
This is clipcrop.bat as it had to be modified to fit my system setup.
for /f "delims=." %%i in ('find "%%k=" ^C:\app\editor\pic\iview\i_view64.ini') do set %%i
for /f "delims=." %%i in ('find "%%k=" ^<C:\app\editor\pic\iview\i_view64.ini') do set %%i
You removed the "<" and therefore you get the error message:
Environment variable ---------- C:\PATH\IVIEW\I_VIEW64 not defined
I'll write up a simpler description after I post this so that we don't lose >> the issues that came up when running the process using VLC instead of
Potplayer as the main problem I had was getting the frame into the
clipboard. If there is an easier way to do that, I'm all ears.
Don't make easy things complicated.
1. Play the video and extract a single frame. In PotPlayer
just press <CTRL>-C to store it in the clipboard, in VLC save
it to a file. Then the player isn't needed any more.
2. Start the batch, but be sure you have the correct line
in the batch:
start /w "" C:\path\iview\i_view64.exe /clippaste
if the picture is in the clipboard
start /w "" C:\path\iview\i_view64.exe C:\path\name.jpg
if you saved the video frame to a picture file
start /w "" C:\path\iview\i_view64.exe
if you want to load the picture file manually in IrfanView
3. After IrfanView is started and the video frame is displayed,
use the left mouse button to select the the crop region.
Then press <SHIFT>-C and then "Save values and exit".
Then close IrfanView. The batch then extracts the data
from the ini file and executes the ffmpeg command.
Only these 3 steps are required, nothing more.
How do you find the dimensions to crop a phone MP4 to a box within the original frame?
That is, how can I play an MP4 & get the cursor coordinates of two points?
I'm successfully uploading phone MP4 videos to Amazon reviews but this
latest 1,920px width by 1,080px height video needs to have a portion
cropped out because a reflection of the video taker shows in the video.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 507 |
Nodes: | 16 (2 / 14) |
Uptime: | 186:24:45 |
Calls: | 9,958 |
Files: | 13,825 |
Messages: | 6,355,849 |