[FFmpeg-user] ffmpeg cutting movies into multiple parts
blubee blubeeme
gurenchan at gmail.com
Sun Jun 5 05:56:52 CEST 2016
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
<https://www.ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment>
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=0for f in $DIRdo
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?
More information about the ffmpeg-user
mailing list