Sunday, October 18, 2015

ffmpeg tricks

Join/merge videos

// in bash
for f in *.mp4; do echo "file '$f'" >> files; done
ffmpeg -f concat -i files -c copy francais_sous_titres.mp4

Extract audio from video

ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac

Change playback speed of videos

The video filter works by changing the presentation timestamp (PTS) of each video frame. For example, if there are two succesive frames shown at timestamps 1 and 2, and you want to speed up the video, those timestamps need to become 0.5 and 1, respectively. Thus, we have to multiply them by 0.5.
To slow it down, multiply by a number > 1.

You can speed up or slow down audio with the ​atempo audio filter. To double the speed of audio, multily by 2. To slow it down, multiply by a number < 1.
This number must be in the range [0.5, 2].

ffmpeg -i francais_sous_titres.mp4 -filter:v "setpts=1.25*PTS" -filter:a "atempo=0.8" francais_sous_titres_slow0.8.mp4

0 comments: