I am using Linux (Mint 22 Xfce if it makes any difference).
I am new to ffmpeg and want to apply a LUT to a folder full of clips. I am using a script which I managed to modify for my requirements: ffmpeg -i "Input.mp4" -vf lut3d=D-Log_M_to_Rec.709-V1.cube -c:v libx264 -pix_ fmt yuv420p10 -b:v 120M "output.mp4"rec709.mp4 which works perfectly on a clip-by-clip basis. I've spent a couple of days on this and still can't get it to work.
I also tried this copied straight from JV Raines post, not because I want to delogo anything, just to see if it would run. It didn't start. Did I miss something?
for filename in *.avi; do
ffmpeg -i "$filename" -vf delogo=x=160:y=560:w=319:h=79 -c:v libx264 -crf 24 -c:a copy -preset ultrafast "$(basename "$filename" .avi)_delogo.avi" done
Please put me straight.
+ Reply to Thread
Results 1 to 9 of 9
-
-
This could be done with clever FFmpeg-GUI, but Windows only.
Do you have a windows vm with framework 4.8 installed on your linux distro?
So you could use it.
If you can go this way, I'll give you more info. -
You can always use python, which most likely you have already installed,
save that text into "my_python_file.py", put it in directory with your video files, navigate into directory, right click and open terminal, then type: python3 my_python_file.py
Code:#!/usr/bin/python3 from pathlib import Path import subprocess import shlex # this will get video paths from current directory DIRECTORY = Path.cwd() def process(cmd): print('processing:', cmd) cmd = shlex.split(cmd) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) out, err = p.communicate() if p.returncode: #print ffmpeg log if there was an error print(err) def to_rec709(video_path, output_path): video_path = Path(video_path).as_posix() output_path = Path(output_path).as_posix() cmd = f'ffmpeg -y -i "{video_path}" -vf lut3d=D-Log_M_to_Rec.709-V1.cube '\ f'-c:v libx264 -pix_fmt yuv420p10 -b:v 120M "{output_path}"' process(cmd) #create a list of video paths video_paths = [video_path for video_path in DIRECTORY.glob("*.mp4")] if not video_paths: print("no video paths found") #create new directory if it does not exist (within directory where files are) new_directory = DIRECTORY / "rec709" new_directory.mkdir(parents=True, exist_ok=True) for video_path in video_paths: output_path = new_directory / video_path.name to_rec709(video_path, output_path)
If you want to always edit that python file and its directory for videopaths. Change DIRECTORY variable. But then you perhaps need that *.cube in the same directory as python file. Not sure now.Last edited by _Al_; 3rd Dec 2024 at 13:12.
-
If you put it on separate lines no ";" is not needed...
Introduce an extra variable holding the basename of the *.avi
Always use {} i.e: ${NAME}_delogo works but $NAME_delogo does not: that variable ("NAME_delogo") does not exist.
Hope this helps...
Code:for filename in *.avi do NAME=$(basename "${filename}" .avi) ffmpeg -i "${filename}" -vf delogo=x=160:y=560:w=319:h=79 -c:v libx264 -crf 24 -c:a copy -preset ultrafast "${NAME}_delogo.avi" done
-
I think you are trying a Bash script without telling it to run Bash.
Try something like this:
#!/bin/bash
FILES="/path to your input files/*"
for f in $FILES
do
ffmpeg -i "$filename" -vf delogo=x=160:y=560:w=319:h=79 -c:v libx264 -crf 24 -c:a copy -preset ultrafast "$filename_done"
done
put it in a script "myvideo.sh" as plain text, save it, make it executable then run it with ./myvideo.sh
Brian. -
If making bash file an executable, careful, that cube file perhaps need to have whole path included as well or be in that executable directory, ..., but for this, you'd need something: for filename in $(find /home/user/my_videos -type f -name "*.mp4"); do ... As was suggested above, providing files with path to iterate from. Or just first simple idea from babiulep:
Code:for filename in *.mp4 do NAME=$(basename "${filename}" .mp4) ffmpeg -i "${filename}" -vf lut3d=D-Log_M_to_Rec.709-V1.cube -c:v libx264 -pix_fmt yuv420p10 -b:v 120M "${NAME}_to709.mp4" done
Last edited by _Al_; 3rd Dec 2024 at 17:15.
-
Thank you all, with a bit of patience and quite a bit of time, I managed to take your suggestions, do a bit of modification and achieve the object. But Al, that python script frightened the hell out of me!
Last edited by DeJay; 4th Dec 2024 at 07:45.
Similar Threads
-
ffmpeg xfade apply to images cause black screen
By slick zheng in forum Video ConversionReplies: 0Last Post: 24th Apr 2024, 05:48 -
How to feed output of ffmpeg into another ffmpeg filter?
By BosseB in forum Video ConversionReplies: 3Last Post: 27th Mar 2024, 14:53 -
VirtualDub2 apply filter to only portion of image?
By VidNoob123 in forum Newbie / General discussionsReplies: 5Last Post: 31st May 2023, 10:58 -
How to apply the same transition to multiple clips in Kinemaster
By frank1492 in forum EditingReplies: 5Last Post: 8th Dec 2022, 01:34 -
apply gamma and colorspace conversion to match original .mov using ffmpeg
By Drinkitrinki in forum Video ConversionReplies: 18Last Post: 25th May 2020, 17:09