Search code examples
textffmpegfind

in bash/linux: How to create the file text for output completed converted from FFmpeg..?


i don't find in google, how to create file text for output completed from FFmpeg in batch?

example: i find 1000 files old video (.avi) but i want to know what is done completed output example ECHO $files > text.txt.. but i don't find in google or here STACKOVERFLOW..

i use batch in file .sh, there are command FIND, FFMPEG

fortmat4find='.avi'
format4output='mp4'
.....
.....
sh -c "find . -iname $format4find -exec ffmpeg -n -i {} {}-CONVERTED$format4output > text.txt \;";

result nothing output to text.txt as completed converted..

inside of text.txt will be result like this:

./folder1/folder2/AAA.avi-CONVERTED.mp4
./folder4/folder5/AAA.avi-CONVERTED.mp4
....
...

i check in guide.. but nothing find information..


Solution

  • echo

    #!/bin/bash
    
    format4find=".mkv"
    format4output=".mp4"
    
    find . -name "*$format4find" -exec sh -c '
    EXT=$1
    shift 1
    for INP; do
      DUR=$(ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 "$INP")
      OUT="${INP%.*}-CONVERTED$EXT"
      echo "$DUR $INP $OUT"
      if ffmpeg -n -i "$INP" "$OUT"; then
        echo "$OUT" >> completed.log
      else
        echo "$INP → error" >> error.log
      fi
    done' sh $format4output {} +