For audio and video:
So this (as an example) works well for me (it does slo-mo of the 4 second segment, starting from 00: 00: 12.5, and at the same time transcodes to mp4):
ffmpeg -loglevel error \ -ss 12.5 -t 4.0 \ -i orig.MOV \ -filter_complex \ "[0:v]setpts=8.0*PTS[v];[0:a]asetrate=5512.5,aresample=44100[a]" \ -map "[v]" -map "[a]" \ -r 30 -strict -2 \ out.mp4
I found that the asetrate=...,aresample=... combo works better than atempo , especially because the latter is limited to [0.5;2.0] . Also note the final -r 30 , which sets the frame rate to 30 frames per second. In some of the videos that I processed, for some strange reason, without it, the result will be a huge file at a speed of 2400 frames per second! It also ensures that all segments of my clip will have the same frame rate (see below).
Other arguments, as usual: -ss sets the start of the clip; because it is up to -i , it works fast as well as correctly (on the timeline of the original). -t is the duration, also in the original timeline.
Background and details:
Well, I had a similar question, because my good slo-mo video from the new iPhone7 + (where I edited only part to be slo-mo) did not seem to be recognized / understood by Google Photos, iPhoto, etc. .
After a little pause (it helped more SO questions and good ffmpeg docs ), I threw it back to the next bash script. This is a bit more than the original question, since I also wanted to convert from .MOV to .mp4 , as well as cut some time at the beginning / end. With this, I was able to execute a batch clip and process a whole bunch of .MOV files from the iPhone into clips that I could upload, share or play. An example of one of the commands:
./slo-part.sh IMG_0067.MOV clip_0067.mp4 14.0 23.0 25.5 27.67
Convenience script:
Here is the slo-part.sh script:
#!/usr/bin/env bash # Slow down a portion of a movie clip _usage="Usage : $0 file_in file_out start start_slo stop_slo stop" function log { local msg=$1 local t=$(date +"%Y-%m-%d %H:%M:%S") echo "$t $msg" } function calc { printf "%g" $(bc<<<"$1") } IN=$1 OUT=$2 A=$3 B=$4 C=$5 D=$6 : ${IN:?$_usage} : ${OUT:?$_usage} : ${A:?$_usage} : ${B:?$_usage} : ${C:?$_usage} : ${D:?$_usage} RATE=30 AB=$(calc "$B-$A") BC=$(calc "$C-$B") CD=$(calc "$D-$C") # scratch dir scratch=tmp.$$ mkdir -p $scratch if (( $(bc <<< "$AB > 0.0") )); then log "Extracting part-1: from $A to $B ($AB)" ffmpeg -loglevel error -ss $A -t $AB -i $IN -r $RATE -strict -2 $scratch/part-1.mp4 fi if (( $(bc <<< "$BC > 0.0") )); then log "Extracting part-2: from $B to $C ($BC) and slow it down 8x" ffmpeg -loglevel error -ss $B -t $BC -i $IN -filter_complex "[0:v]setpts=8.0*PTS[v];[0:a]asetrate=5512.5,aresample=44100[a]" -map "[v]" -map "[a]" -r $RATE -strict -2 $scratch/part-2.mp4 fi if (( $(bc <<< "$CD > 0.0") )); then log "Extracting part-3: from $C to $D ($CD)" ffmpeg -loglevel error -ss $C -t $CD -i $IN -r $RATE -strict -2 $scratch/part-3.mp4 fi log "Concat all parts, output to $OUT" ffmpeg -loglevel error -y -f concat -i <(for f in $scratch/part-*.mp4; do echo "file '$PWD/$f'"; done) -c copy $OUT rm -rf $scratch