My head hurts!Could you FFMPEG gurus help me out here; I've spent the afternoon on this but am stuck.
On a set of DV files in a folder, I'm trying to crop off the top 2 pixels and the rightmost 4 pixels, then resize them to 1440x1080.
The script runs fine without the Crop command as shown, resizing to 1440x1080, but cropping doesn't occur.Code:for %%A in (*.avi) do C:\ffmpeg\bin\ffmpeg.exe ^ -i "%%A" ^ -vf "bwdif=mode=0,hqdn3d=1.5:1.5:3:3" ^ -vf "crop=716:574:0:2" ^ -vf "scale=1440:1080" ^ -c:v libx264 -crf 24 -preset medium ^ -pix_fmt yuv420p ^ -c:a aac ^ -b:a 192k ^ "%%~nA.mp4"
Extra question: how can I comment out a line (similar to # in AVISynth)? I've tried REM and #, to no avail.
I realise the colour format is wrong but will attend to that later.
Why, you ask? Although Handbrake does this, the folder setups and the Dimensions are just weird and illogical and I can't cope!I simply drop this BAT into a folder, double-click it and it's done. Just have to sort out the cropping.
I've attached a short DV file.
I would really appreciate any help you can provide.
+ Reply to Thread
Results 1 to 19 of 19
-
Last edited by Alwyn; 4th Nov 2026 at 18:41. Reason: Crop value amended.
-
Ah, that’s the classic multiple -vf gotcha: ffmpeg is only using the last one, so combine them into a single comma-separated filter chain like -vf bwdif=mode=0,hqdn3d=1.5:1.5:3:3,crop=716:574:0:2,s cale=1440:1080. Also double-check the crop width: 720 minus 4 is 716, so 718 would only trim 2 from the right.
-
Boom! Thank you Sidonia, that works a treat. Well spotted on the pixel count, I'll change my calculator batteries.
-
Thanks Sharc, tried REM and double colon but no joy, the command window closes immediately.
-
Yes, looks like one cannot use it within a commandline to skip certain parts ....
Btw., you can still break down your commandline into several lines, something like
I usually put pause at the end so the window stays open to read the log/error messages.Code:ffmpeg.exe -i "ffmpeg crop\20050813_180811 T11 snip.avi" ^ -vf bwdif=mode=0,^ hqdn3d=1.5:1.5:3:3,^ crop=718:274:0:2,^ scale=1440:1080^ -c:v libx264 -crf 24 -preset medium -pix_fmt yuv420p -c:a aac -b:a 192k^ out.mp4 pause
Last edited by Sharc; 4th Nov 2026 at 08:14.
-
Thanks Sharc, I'll try that. I saw some red errors go past but they disappeared.
-
Thanks very much to all, this is what I've come up with that works:
My next question... this script runs in a folder to convert all the DV files in that folder. But I have many folders of DV files and want to convert all the files in all the folders in one go. They are located in a parent folder called "DV".Code:for %%A in (*.avi) do C:\ffmpeg\bin\ffmpeg.exe ^ -i "%%A" ^ -vf "bwdif=1:1:0","hqdn3d=4:3:6:4.5","crop=716:572:0:2","scale=1440:1080" ^ -c:v libx264 -crf 24 -preset medium ^ -pix_fmt yuv420p ^ -c:a aac ^ -b:a 192k ^ -ar 48000 ^ "%%~nA.mp4" pause
Is that possible and how would I go about it? I have looked at Google AI but it fails. This is the Powershell code it gave me:
If I can get this working, I'll modify the vf to match my original script.Code:Get-ChildItem -Recurse -Filter *.dv | ForEach-Object { $mp4Path = $_.FullName -replace '\.dv$', '.mp4' \ffmpeg\bin\ffmpeg.exe -i $_.FullName -c:v libx264 -preset medium -crf 20 -c:a aac -b:a 192k "$mp4Path" }
Thanks for any help!Last edited by Alwyn; 4th Nov 2026 at 21:36. Reason: Powershell ref added.
-
Before targeting mass production you may want to take a look at the colorspace. For upscaling SD->HD I would apply bt601 -> bt709 conversion to prevent color distortions upon playback. Or keep the original resolution and leave the upscaling to the TV.
For upscaling I suggest to modify the scale like
Code:scale=1440:1080:in_color_matrix=bt601:in_range=limited:out_color_matrix=bt709:out_range=limited
Can't help you much with the powershell issue. But try putting below in the parent (DV) folder. It should then start with the current (DV) folder and walk through the subfolders (I think this is what you want):
The -n in the second line skips any existing .mp4 with the same name. Leave the -n away if you prefer to be prompted, or use -y to overwrite.Code:for /R %%A in (*.avi) do C:\ffmpeg\bin\ffmpeg.exe ^ -n -i "%%A" ^ -c:v libx264 -crf 24 -preset medium -pix_fmt yuv420p ^ -c:a aac -b:a 192k -ar 48000 -movflags +faststart ^ "%%~dpnA.mp4" pause
Last edited by Sharc; 5th Nov 2026 at 03:39.
-
Alwyn,
I'm hopeless with batch scripts, but if you happen to be interested in using a GUI you could try AnotherGUI. You can drag and drop the source files onto the GUI to queue the encoding jobs, and you can also configure "watch folders"' so it'll automatically encode files. I haven't used the "watched folders" option for quite a while, but from memory it's fairly versatile. For it to work, you have to download some SQLite files and copy them to the AnotherGUI folder. There's links here. https://www.stuudio.ee/AnotherGUI/
I'm pretty sure you can drag and drop whole folders onto the GUI, although I'm not sure if sub-folders are automatically added too.
An ffmpeg preset for x265/AAC encoding with AnotherGUI could look something like this. If you want to write the output files to the same folder as the source files and they have the same extension, this will append "_encoded" to each output file name. If you don't need it to do that, you can delete _encoded from the output name in the preset.
Or you could use an Avisynth script for the filtering and x264/x265 for the encoding, although you'd have to create a script for each source file and handle the audio separately.Code:(Executable ffmpeg.exe) -i "<FullSourceFileName>" -vf bwdif=mode=0,hqdn3d=1.5:1.5:3:3,crop=716:574:0:2,scale=1440:1080 -c:v libx264 -crf 24 -preset medium -pix_fmt yuv420p -c:a aac -b:a 192k -movflags faststart "<OutputPath><OutputFileName>_encoded.mp4"
Normally when upscaling SD to HD, I'd convert the video from rec.601 to rec.709 with an Avisynth plugin, then specify rec.709 as the VUI info for the encoder to write. I don't know how to convert the colors with ffmpeg off the top of my head, but a typical x264 preset for encoding Avisynth scripts looks like this for me:
For encoding Avisynth scripts with x265.exe you have to pipe from ffmpeg. Once again, this is just an encoder preset of mine I copied and pasted as an example.Code:(Executable x264.exe) --level 4.1 --preset slow --tune film --crf 20.0 --b-adapt 2 --me umh --subme 9 --partitions all --no-fast-pskip --stitchable --sar 1:1 --threads 12 --vbv-bufsize 50000 --vbv-maxrate 50000 --colorprim bt709 --transfer bt709 --colormatrix bt709 --output "<OutputPath><OutputFileName>.mkv" "<FullSourceFileName>"
In preferences, it'd be a good idea to set the number of processes to 1, as it defaults to the number of cores your CPU has, which means for a 6 core CPU with hyperthreading it'd try to run 12 encodes simultaneously.Code:(Executable cmd.exe) /d /c "C:\Encoders\ffmpeg\ffmpeg.exe" -i "<FullSourceFileName>" -strict -1 -f yuv4mpegpipe - | "C:\Encoders\x265\x265.exe" --crf 20.0 --profile main10 --preset slow --deblock=-1:-1 --no-open-gop --ctu 32 --rc-lookahead 80 --lookahead-slices 0 --rd 4 --psy-rd 2.0 --rdoq-level 2 --psy-rdoq 1.5 --aq-strength 1.3 --no-strong-intra-smoothing --no-sao --sar 1:1 --colorprim bt709 --transfer bt709 --colormatrix bt709 --output "<OutputPath><OutputFileName>.hevc" --y4m --input -
Last edited by hello_hello; 5th Nov 2026 at 06:21.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Your blood's worth bottling Sharc, thanks very much, that's working superbly.Originally Posted by Sharc
Thanks Hello, I'll study your reply. I had a play with the 709 commands (similar to yours in your script) but they all failed, my syntax was wrong apparently. I think I'll just go with Sharc's suggestion of SD. -
FWIW attached a demo what usually happens to the colors when one forgets the 601->709 conversion for SD->HD upscaling.
-
This stuff is frustrating... an example:
This runs OK:
-vf "bwdif=1:1:0","hqdn3d=4:3:6:4.5","crop=716:572:0:2 ","scale=768:576" ^
This doesn't:
-vf -bwdif=1:1:0 -hqdn3d=4:3:6:4.5 -crop=716:572:0:2 -scale=768:576 ^
With this message:
"Unrecognized option 'hqdn3d=4:3:6:4.5'.
Error splitting the argument list: Option not found"
It obviously does know what hqdn3d is, but won't accept it when using -. -
Last edited by Sharc; 5th Nov 2026 at 08:53.
-
I'm onto it!Originally Posted by Sharc
Got it, thanks. I was misled by the other lines and their -.The different video filters (-vf) need to be comma-separated, -
Success (I think) with color 601 to 709. I used:
colorspace=all=bt709:iall=bt601-6-625:fast=1Last edited by Alwyn; 5th Nov 2026 at 09:48.
-
Probably faster (because it does the scaling and matrix conversion in one pass) with hardly noticeable difference compared to the separate colorspace filter:
last line added to set the metadata with x264 (maybe double-stitching....)Code:-vf scale=1440:1080:in_color_matrix=bt601:in_range=limited:out_color_matrix=bt709:out_range=limited ^ -c:v libx264 -crf 24 -preset medium -pix_fmt yuv420p ^ -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range tv ^
Last edited by Sharc; 5th Nov 2026 at 15:10. Reason: justification why it may be probably faster added
-
... and what comes to my mind is the colormatrix filter for a simple conversion, like
(maybe that's ~similar what the fast=1 in your proposal does)Code:colormatrix=src=bt601:dst=bt709
Similar Threads
-
Help with failing download
By popup in forum Video Streaming DownloadingReplies: 2Last Post: 7th Jan 2026, 21:30 -
Handbrake Failing
By lemmy999 in forum Video ConversionReplies: 6Last Post: 14th Jul 2025, 01:39 -
Cropping keeps failing...
By Rander in forum Video ConversionReplies: 9Last Post: 20th Apr 2024, 20:30 -
Discs Failing
By pvalley in forum Authoring (Blu-ray)Replies: 0Last Post: 10th Sep 2023, 12:38 -
Trying (and failing) to download this show
By seanadl in forum Video Streaming DownloadingReplies: 8Last Post: 29th Nov 2021, 17:39



Could you
I simply drop this BAT into a folder, double-click it and it's done. Just have to sort out the cropping.
Quote