Ffmpeg video conversion command line examples

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

Convert a video to a different resolution

This one converts a video to 1366x600 resolution (-vf scale=1366:600) and leaves subtitles intact (-scodec copy -map 0):

ffmpeg -i input.mkv -vf scale=1366:600 -scodec copy -map 0 output.mkv

Record a selenium session running in Xvfb

This is actually the whole script which launches Xvfb, starts selenium servers, records the screen with ffmpeg for maximum 2 minutes, and launches a codecept / selenium test:

    su - selenium -c "
    Xvfb :10 -ac -screen 0 1280x1024x24 &>/home/selenium/xvfb.log &
    sleep 3
    export DISPLAY=:10
    java -Dwebdriver.firefox.marionette=false -jar selenium-server-standalone-3.0.1.jar &>/home/selenium/selenium.log &
    sleep 2
    # record the screen for maximum 2 minutes
    rm -f /home/selenium/video.mp4
    timeout 2m ffmpeg -video_size 1280x1024 -f x11grab -i :10.0+0,0 -f ismv -movflags empty_moov+frag_keyframe -pix_fmt yuv420p /home/selenium/video.mp4 &>/home/selenium/ffmpeg.log &
    codecept build && codecept run --steps --env testing
    # we can stop ffmpeg now
    kill -2 $(pidof ffmpeg)
    killall java Xvfb &>/dev/null