Some useful FFmpeg commands (info, demux, ...)

7/24/2010 | Comments: 7

If you happen to have the wonderful FFmpeg, there are many cool things you can do with it. I'll name just a few things that I'm often in need of. Please note that I'm playing around with all the possibilities myself, so the following lines will grow over time...

Get information about a media file:

ffmpeg -i video.avi

Extract (demux) the audio track from a video file:

ffmpeg -i video.mts -acodec copy -vn audio.ac3

Extract (demux) the video track from a video file:

ffmpeg -i video.mts -vcodec copy -an -f h264 ffNT.h264

Merge an audio and a video track (mux):

ffmpeg -i video.h264 -i audio.ac3 -vcodec copy -acodec copy videoaudio.ts

Resize an original Full-HD (16:9) video file from a camcorder down to DVD resolution (and MPEG) for further processing, e.g. burning on DVD (e.g. with DVDStyler), but keep the source aspect ratio of 16:9:

ffmpeg -i video.ts -s 720x405 -aspect "1.7777" -vb 8000k video.mpg

Resize a video to a certain width, retaining the aspect ratio (width = 640px, in this example; the "-strict -2" may be necessary on Linux because of licence issues):

ffmpeg -i video.mp4 [-strict -2] -vf "scale=640:-1" video-resize640.mp4

Comments

Querk McGoober   1/10/2012

Thanks for these. Looked for an eternity for this kind of info.

ffmpeg is the best video tool ever and it's free

Peanutbutter Jelly   1/29/2012

Wanted to delay the audio of my ts video. Needed to move the a/v into their own ts containers (instead of raw formats) first, or else I would get "first pts value must set." Thanks!

fakename   9/16/2012

This is excellent. Quick and easy. Thanks for posting these.

Marcus   11/27/2012

How do I extract subtitles, specifically PGS subtitles?

Goosio, friend of Maltese children everywhere-io   12/ 6/2012

Marcus, you'll have to use VobSub Ripper. It requires the disc image complete with IFO. It rips the subpictures directly to the VobSub timed binary format.

If you have the VOB but not the IFO, it's more involved. It requires either DVDSubEdit or VobEdit. Use VobEdit to Demux if the VOB has multiple languages, as DVDSubEdit may clump the subpicture streams (.SUP) together.

Once you save the SUP(s), you'll need to manipulate the file(s) in SubtitleCreator and save it as the VobSub timed binary format (.IDX). Assuming you had to use VobEdit, you can have SubtitleCreator add multiple languages to the IDX by opening the different SUPs you extracted and then appending to the IDX you created.

Of course, you can use CCExtractorWin to extract the closed captions to the SubRip timed text format (.SRT). Depends on if they exist in the video. RLE subpictures are more common than CC.

Good luck!

curtis@ram9   1/22/2013

rad!

kage_no_king   2/15/2013

Is there any way to mux a video + audio + subtitle with command line ?

Leave Comment