First you need to extract the frame that you wish to freeze. This is easy:
avconv -i test.webm -vf "select='eq(n,1)'" out.jpeg
Then you want to put that frame for the appropriate time interval.
avconv -i test.webm -loop 1 -i out.jpeg -an \
-filter_complex "[1:v]trim=start=0:end=5[ol];[0:v]setpts=125+PTS[nv];[nv][ol]overlay=eof_action=pass[final]" \
-map '[final]' -c:v libtheora -q:v 8 outtest.ogv
Firstly you will see that i didn't want to mess with audio, but if you'll find it too difficult, let me know and i will look into the quick way to align it as well.
Now what i'm doing here consists of several strange things. Firstly i am taking that frame that was generated before and i am creating a continuous loop video from it. And afterwards i cut first 5 seconds of it with the first filter trim
. Then i do a quick and dirty move of all the timestamps of the main video by 5 seconds (125 frames). And finally comes an overlay filter, which places the grabbed frame entirely over the blank screen that was generated by shifting the video 5 seconds into the future.
Tested with avconv version v12_dev0-680-g3a724a7 built on Jan 22 2015 18:13:02
How to build avconv
:
- In terminal go to any directory where you are comfortable to place libav's code
- run
git clone git://git.libav.org/libav.git libav
- enter into libav direcotry
- run
--enable-gpl --enable-version3 --disable-encoders --enable-encoder=mjpeg --enable-encoder=flac --enable-encoder=ffvhuff --enable-encoder=libspeex --enable-encoder=libtheora --enable-encoder=libvorbis --enable-encoder=libxvid --enable-encoder=libopenjpeg --enable-libschroedinger --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libxvid --bindir=/home/USERNAME/bin
- Note that here i am assuming that you have ~/bin directory, that is added to your execution PATH. If you don't just remove that option
- Run
make
- It is possible that you will not have some libraries, if you encounter such errors either install them or remove "enable" options for those libs. Keep in mind that removing those options can make it impossible to generate files with some codecs.
- Run
make install
(or if you chose to not place binary within your user directory, sudo make install
).
Edit: Unfortunately due to a bug, video becomes shorter than it should have been. I have reported it https://bugzilla.libav.org/show_bug.cgi?id=858