VideoHelp Forum




+ Reply to Thread
Results 1 to 9 of 9
  1. Member
    Join Date
    Apr 2017
    Location
    England
    Search Comp PM
    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.
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Member
    Join Date
    Apr 2017
    Location
    England
    Search Comp PM
    Thanks, but no.
    Quote Quote  
  4. You forgot a ";" after 'avi"' elogo.avi" done (so inbetween " and done)
    Quote Quote  
  5. 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)
    Make sure that opened terminal directory is that python file directory (with your video files).

    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.
    Quote Quote  
  6. 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
    Quote Quote  
  7. 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.
    Quote Quote  
  8. 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
    You can run it as: bash whatever.sh if not executable
    Last edited by _Al_; 3rd Dec 2024 at 17:15.
    Quote Quote  
  9. Member
    Join Date
    Apr 2017
    Location
    England
    Search Comp PM
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!