I was trying to control ffmpeg file segment function through a bash script to cut a large movie file into smaller pieces.
I took a look at the documentation here but this doesn't really cover what I would like to do.
I'd like to mix the segment function with some of my own stuff from bash. Here is an example part of the script.
#!/bin/bash
DIR="/../../*"
OUT_DIR="/../../"
file_extension=""
filename=""
input_file=""
input_file_dir=""
output_file=""
working_directory=""
output_file_dir=""
part_count=0
for f in $DIR
do
filename=$(basename "$f")
input_file="$filename"
filename=${filename::-4}
file_extension=${f: -3}
input_file_dir=$(dirname "$f")"/"
part_count="$(printf "%03d" "$counter")"
output_file="$filename"_"$part_count"."$file_extension
//my file name generation takes place here
output_file_dir="$OUT_DIR$filename"_"$part_count".mkv"
let part_count=$part_count+1
ffmpeg -i "$f" -c:v libx264 -crf 22 -map 0 -strict -2 -segment_time 600 -g 9 -sc_threshold 0 -force_key_frames "expr:gte(t,n_forced*9)" -f segment "$OUT_DIR"
done
The line above "$OUT_DIR" doesn't work and throws a cryptic error. If I remove "$OUT_DIR" and put anything, example "test.mkv" then the files get written out correctly but in the wrong location.
Can I do this with ffmpeg segment command and bash?
/../../
means "the root (top) directory, and then up two more". – JigglyNaga Jun 05 '16 at 10:39$counter
is undefined andffmpeg
's output is a directory. – JigglyNaga Jun 06 '16 at 09:25