Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

make the same command with not certain files listed in command, but with all files that…

  1. User

    make the same command with not certain files listed in command, but with all files that are larger than 400kb in current folder ffmpeg -i “concat:0.ts|1.ts|2.ts|3.ts|5.ts|6.ts|7.ts|8.ts” -c copy output.mp4

  2. Assistant

    ffmpeg -i "concat:(find.−maxdepth1−typef−size+400k−name′∗.ts′−printf′(find . -maxdepth 1 -type f -size +400k -name '*.ts' -printf '%f\\|' | sed 's/\\|//')" -c copy output.mp4

    Explanation:

    • find . -maxdepth 1 -type f -size +400k -name '*.ts' searches the current directory (.) without going into subdirectories (-maxdepth 1) for regular files (-type f) that are larger than 400kb (-size +400k) and have a .ts file extension (-name '*.ts')
    • -printf '%f\\|' prints only the file names followed by a pipe symbol (|) and escapes it with a backslash to avoid interpretation by the shell
    • sed 's/\\|$//' removes the last pipe symbol from the list of file names
    • The resulting list of file names is substituted in place of 0.ts|1.ts|2.ts|3.ts|5.ts|6.ts|7.ts|8.ts in the original command using command substitution $().
  3. User

    /Applications/ffmpeg -i "concat:(find /Downloads/film/* -type f -size +990k -print | tr '\n' '|')" -c copy output.mp4 produces error: concat:(find /Downloads/film/ -type f -size +990k -print | tr '\n' '|'): No such file or directory

  4. Assistant

    The error is most likely because the shell is treating find and tr as literal strings instead of commands to be executed. You can use command substitution $() to execute the commands and substitute the output into the ffmpeg command.

    Try this updated command instead:

    /Applications/ffmpeg -i "concat:$(find /Downloads/film/ -type f -size +990k -print0 | tr '\0' '|')" -c copy output.mp4
    

    This command should find all regular files in the /Downloads/film/ directory (and its subdirectories) that are larger than 990kb. The -print0 option is used to separate the file names with null characters instead of newlines, which is safer for handling file names with special characters or spaces. The tr '\0' '|' command replaces null characters with pipe symbols.

    The resulting list of file names is substituted in place of concat: in the ffmpeg command using command substitution $(...).