I'm using avconv for trimming and converting videos. Let's say I want to drop the first 7 and last 2.5 seconds of the video stream and one audio stream of an one-hour mts file:

avconv -i input.mts -map 0:0 -map 0:3 -ss 0:0:07 -t 0:59:50.5 out.mov

This works so far, but now I want to add two seconds of fading in and out at the beginning and the end by adding:

-vf fade=type=in:start_frame=350:nb_frames=100 -vf fade=type=out:start_frame=178750:nb_frames=100

Those frames are calculated with the 50 fps that avconv reports for the video source. But there is neither fading in nor out.

1) What goes wrong with the video fading and how to do it right? 2) How to add audio fading. There seems to be an -afade option. but I don't find it documented.

Alternatively, you can propose a different tool for this goal (trim and fade video and audio), preferrably available as package for Debian 8.



ffmpeg -i input.mts -ss 00:00:20.0 -c copy -t 00:00:30.0 output.mkv

Seek 20 seconds -(i)n input.mkv (and discard, by default) let it play for 30 seconds and discard everything else from there. So you've got a 30 seconds video.


First you need to create an image for your fades. Probably a single *.png image, full white or full black depending on your taste. In the same resolution your video was recorded, preferably.

ffmpeg -r 1/2 -i black.png -c:v libx264 -r 50 -y -pix_fmt yuv420p fade2s.mkv

This means, fade 2 seconds (-r input:1 / 2 x 50 frames per second = 100 fps). For the image info you can check The Gimp or ImageMagick. Now you've got your fade effect.

Fade In:

ffmpeg -i fade2s.mkv -y -vf fade=in:0:50 fade_in.mkv

Fade in from 0 to 50 frames (1 second - 50fps)

Fade In + Out: Take the last input as your fade in and add some fade out

ffmpeg -i fade_in.mkv -y -vf fade=out:120:50 fade_in_out.mkv


  • Three of our children were in the hospital the last days, so I wasn't able to check your solution. But I trust you and reward the bounty. I'll come back after I find the time. Thank you. – Philippos Jun 26 '17 at 5:40
  • Thank you again, mainly for leading me to use ffmpeg instead of avconv. I found an ffmpeg-solution now. – Philippos Aug 14 '17 at 5:18

I finally found the time to try the answer suggested by @Mario G., but it seemed extremely cumbersome. I need to do this many dozends of times. I read the documentation of ffmpeg and found it much more powerful than avconv, including fading for audio and video, so the solution is

ffmpeg -i input.mts -map 0:0 -map 0:3 -ss 0:0:07 -to 0:59:57.5 -vf 'fade=t=in:st=7:n=60,fade=t=out:st=3595.5:n=60,crop=out_h=692' -af 'afade=in:st=7:d=2,afade=out:st=3595.5:d=2' out.mov

So the st= parameters for the fade take times in seconds, no need for converting to frames, just the n= is in frames for some reason. Length for audio fade is also in seconds.

I also discovered the -to option to take the end time directly instead of calculating the length.

This command does all steps (channel selection, trimming, fading and cropping) in a single step.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.