I want to crop video file with FFMPEG. There option to preview video with crop-future results using FFPLAY. It works great and I can see what my crop values will give me as output. I want to set the new scale (display aspect ratio) too but can’t find the way to see that in preview. Tried everything, even couldn’t find in FFPLAY documentation a word about scaling (SAR, DAR) preview. Seems that it is hidden in some filtering options but… I am really stacked. Or it is impossible?
Next code used (windows 10, BAT (CMD)):
Thanks in advance.Code:Set cropHeight=64 ffplay -i "filename.ext" -vf "crop=in_w:in_h-%cropHeight%"
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 14 of 14
Thread
-
-
try this:
Code:set "h=1920" set "w=1080" set "cropHeight=64" ffplay -i "filename.ext" -x %w% -y %h% -vf "crop=in_w:in_h-%cropHeight%"
-
Thanks _Al_ but it's not that I meant. That's also crop. If I enter
Code:set "h=900" set "w=1060" set "cropHeight=64"
-
you can use scale, i just test it:
set "h=1920"
set "w=1080"
set "cropHeight=64"
Code:ffplay -i "filename.ext" -vf "crop=in_w:in_h-%cropHeight%,scale=%h%:%w%"
-
Thanks _Al_
Not ok again... tomorrow I'll post video file somewhere and try to solve crop (again!) first.
I didn;t read this page carefully:
https://www.bogotobogo.com/FFMpeg/ffmpeg_cropping_video_image.php -
If you are just looking for a general representation of how it looks you can do all in one shot with pipe ffmpeg to ffplay.
Code:ffmpeg -i "C:\Users\Bud\Desktop\CGOP.mp4" -t 52.753227 -vf crop=440:230:40:40 -f flv - | ffplay - -vf scale=640:-2
-
Bud, my code is more complex… sure that I am cropping video later but preview is the first step. If preview OK then Do Crop. Else: go back on entering crop values.
This will not work on our way (_Al_, me etc...). Only one dimension of scaling is processed (larger one seems to me) and the second is automatically set to keep source video scaling (source DAR). Maybe that is exactly they wanted to achieve...
I would like to set my own scaling (resizing!) for preview to get something as on the attached image “Sam Distortion.png”
Whatever you enter as scaling width or scaling height, DAR 16:9 will be displayed in FFPLAY. Crop is another story: crop simple working perfect (there are lot of play with negative values, distance from the left or the bottom… etc.)!!!
Video file is here (800 x 654 - if youtube did resize it...)
https://www.youtube.com/watch?v=mNTWkStnsGA
Batch code (just edit my paths):
Code:@echo off echo ! set dl=C:\Users\DL set ffmp=%dl%\pgs set wpath=%dl%\files set result=%dl%\result REM Bud sample REM %ffmp%\ffmpeg -i "C:\Users\DL\files\input.mp4" -t 52.753227 -vf crop=440:230:40:40 -f flv - | %ffmp%\ffplay - -vf scale=640:- REM pause REM exit :procStart FOR %%g IN (%wpath%\*) DO ( for /F "delims=" %%e in ('%ffmp%\ffprobe -v error -select_streams v:0 -show_entries stream^="width,height" -of csv^=s^=x:p^=0 "%%g" 2^>^&1') do set "inputWH=%%e" ) echo Input file scale (v-dimension, v-resolution, DAR?..) is %inputWH% set cw=800 set ch=450 set cx=0 set cy=102 set sw=480 set sh=270 set /p cw=Enter crop width value (default: %cw%): set /p cw=Enter crop height value (default: %ch%): set /p cw=Enter left shift value (default: %cx%): set /p cw=Enter bottom shift value (default: %cy%): set /p cw=Enter scale width value (default: %sw%): set /p cw=Enter scale height value (default: %sh%): echo cw is %cw% echo ch is %ch% echo cx is %cx% echo cy is %cy% echo sw is %sw% echo sh is %sh% pause FOR %%g IN (%wpath%\*) DO ( %ffmp%\ffplay -i "%%g" -vf "crop=%cw%:%ch%:%cx%:%cy%,scale=%sw%:%sh%" -loop 4 -window_title "%%~nxg | CW %cw% CH %ch% CX %cx% CY %cy%" -autoexit ) echo( echo If you are satisfied, choose OK. Chose Repeat to enter the new crop value. Or Exit to do nothing. CHOICE /C "123" /M "Choose your acction [(1)OK, (2)Repeat, (3)Exit]" echo( IF ErrorLevel 3 GoTo :Stop IF ErrorLevel 2 GoTo :procStart IF ErrorLevel 1 GoTo :doCrop echo( :Stop exit :doCrop echo Now crop and save your output file... but this is another story... exit timeout /t 32 exit
Huh... how to show attachments as link???
Bud, your code doesn’t work for me… dunno why… I don’t understand why you need FLV and –t? Screenshot attached.Last edited by Drag; 7th Oct 2018 at 12:43. Reason: Small tipo 2
-
You can affect ffplay preview by using -vf setsar or setdar
https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar -
I did not tried all of it, just core of the script for playback and it crops, no black bars
Code:@echo off :procStart set cw=800 set ch=450 set cx=0 set cy=102 set sw=480 set sh=270 set /p cw=Enter crop width value (default: %cw%): set /p cw=Enter crop height value (default: %ch%): set /p cw=Enter left shift value (default: %cx%): set /p cw=Enter bottom shift value (default: %cy%): set /p cw=Enter scale width value (default: %sw%): set /p cw=Enter scale height value (default: %sh%): echo cw is %cw% echo ch is %ch% echo cx is %cx% echo cy is %cy% echo sw is %sw% echo sh is %sh% pause ffplay.exe -i "test file.mp4" -vf "crop=%cw%:%ch%:%cx%:%cy%,scale=%sw%:%sh%" -window_title "test" -autoexit exit
Last edited by _Al_; 7th Oct 2018 at 11:32.
-
-
Well… that DAR & SAR are very complicated… the same problem guy had (exactly!) 5 years ago! Darn month October https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-October/018327.html
Today, we did better than they in 2013.
So, in this case, all of above working on the next way.:
video is 800 x 654 with top black bar of 102 and bottom black bar of 102. I want to cut it on 800 x 450 (654 – 2 x 102). So cropWidth=800, cropHeight=450, cropX=0, cropY (shift from the bottom side)=102. Preview I want to see scaled (in dimensions), let’s say 560x315 (16:9 ratio). All my values are well calculated so I want to set SAR on 1:1. DAR should not be used together with SAR (probably ever(?!)) because, in this case, 560x315 has roll of DAR. Preview is perfect. And preview window will "listen" my commands, especially scale! It will not be in aspect (as before) but elastic as I order. Result is perfect (attached screenshot [File 800x654.png])
Further, I resized video on 800 x 560 and new value for one side black bar is 86. So, I am cropping it cropping: 800 x 388 (560 – 2 x 86) and all values are:
Code:cropWidth=800 cropHeight=388 cropX=0 cropY (shift from the bottom side)=86 Scale w x h = 560x315 SAR (obligatory) 1:1
I just wanted to push ffplay to show preview screen with my values without any automation. Achieved. 2 more screenshots attached: [Scale 560x650.png], [Scale 560x120.png])
Final ffplay line is
Code:FOR %%g IN (%wpath%\*) DO ( %ffmp%\ffplay -i "%%g" -vf "crop=%cw%:%ch%:%cx%:%cy%,scale=%sw%:%sh%,setsar=1:1" -loop 4 -window_title "%%~nxg | CW %cw% CH %ch% CX %cx% CY %cy%" -autoexit )
Thanks _Al_, thanks Bud, thanks all. Still here for further (if any).Last edited by Drag; 7th Oct 2018 at 14:00. Reason: Small tipo
-
personally I use mpv player for all the magic for a while, abandoning ffplay a while ago, for example, its array of options and options might have the same pattern, like ffmpeg
Code:vf=crop=w:h:x:y
Or you might use this setup for cropping visuallyLast edited by _Al_; 7th Oct 2018 at 14:39.
-
I know... many good programs today... that MPV is really something very nice... and Wondershare, Premiere... but I created scripts for all life cases. Now I can put 100 files in my DIR and each one will be processed, user will be asked to enter values, will have preview and choisee crop, back, skip or exit ... etc ... and everything must be simple... I am not doing this for myself...
Similar Threads
-
ffplay preview window
By foldbck123 in forum Newbie / General discussionsReplies: 5Last Post: 7th Dec 2017, 04:22 -
where i can download FFPLAY.exe?
By marcorocchini in forum Newbie / General discussionsReplies: 2Last Post: 15th Aug 2017, 16:10 -
DAR: why scale down width rather than scale up height?
By chconnor in forum Video ConversionReplies: 15Last Post: 20th Feb 2017, 19:40 -
Help needed with ffmpeg/ffplay and select
By Selur in forum Video ConversionReplies: 2Last Post: 13th Aug 2014, 02:35 -
ffplay output-what is aq?
By Punchcard in forum AudioReplies: 2Last Post: 31st Jul 2014, 14:12