Jump to content

FFmpeg introduction


Pequi

Recommended Posts

OK, as promised, a ffmpeg tutor. I'm not an expert, I just use it for everyday "tweaks".
Hope nothing "wraps".

1) You will need the ffmpeg binaries, available from
https://ffmpeg.zeranoe.com/builds/
Click on the "static versions" and choose the latest stable version, the "GIT" versions might possibly have bugs.
The latest stable is labeled:
ffmpeg-<version>.-win<32 or 64 bit>-static.7z

Extract the contents of the "bin" folder (3 files, including ffmpeg.exe)to somewhere on your %PATH
If you don't know what your %PATH is, or how to add folders to it, Glugle.

If you want, extract the ffmpeg-all.html file from the DOC folder and keep it handy.

2) ffmpeg is a command prompt executable, so either make a right-click "command" entry to right-click folder, or learn how to move around in pseudo DOS, usually by typing "cmd" (XP) or "command" (Win7+) at start - execute, and using "cd" to get to the folder containing the media file.
Glugle again.

3) Test it. Type "ffmpeg" (without the "" ) into your command prompt and it should print something like this:
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3
  bla bla bla
If this does not happen, do NOT continue, go back.

Of course, under Linux, just install the latest from the repos. Your dist will do the paths for you.
Warning - Have not tested batch commands under Linux

Remember, most common video formats are just containers for streams. They contain a video stream, an audio stream and sometimes metadata streams (subtitles, menus, chapters etc)
Mediainfo light is your friend

http://www.codecguide.com/download_other.htm#mediainfo


After installing, right click on the video||music to see what's there.

Here are practical examples. All refer to media that you legally own or some nepharious hacker might have torrented to your HD to frame you.

----------------------------------------------------------------
OK, people complain thet MKV files don't play on their media players, and whine all the time in torrent groups that they should be MP4
Easy:

ffmpeg -i input.mkv -c copy output.mp4
That runs in a few seconds

Example:

ffmpeg -i "Supernatural S11E23 - Alpha and Omega.mkv" -c copy "Supernatural S11E23 - Alpha and Omega.mp4"

The original MKV file is untouched BECAUSE I USED A DIFFERENT NAME for the output file, and you now have a perfect MP4 file to play in whatever.
NEVER use identical names for input/output.

----------------------------------------------------------------------------------
The original file has metadata that either contains tracking info (like stuff downloaded from youtube), or the metadata messes with your player, or someone added a subtitle stream in some obscure language ?
No problem, strip ALL the metadata

ffmpeg -i input -c copy -map_metadata -1 output

Example:

ffmpeg -i "Supernatural S11E23 - Alpha and Omega.mp4" -c copy -map_metadata -1 "Supernatural S11E23 - Alpha and OmegaPEQUI.mp4"

Note that I changed the output name so it would not be overwritten, in this case, both are MP4.

----------------------------------------------------------------------------------
A folder of FLAC files appeared on your HD, and they won't play in your MP3 player ?
I'll use a BATCH here, so I don't have to convert them one by one:

for %a in ("*.flac") do ffmpeg -i "%a" -c:a libmp3lame -q 0 "%~na.mp3"

Note you don't have to name the files, that's done for you.
-q 0 = practically lossless
-q 1 = excellent
-q 2 = very good, I can't tell the difference from the original FLAC.
-q 4 = good enough for most MP3 players and ears
Note, the bigger the number, the smaller the file, but the quality suffers.

----------------------------------------------------------------------------------
The FLAC files contain images of the album, and you don't want them altered in any way ?

for %a in ("*.flac") do ffmpeg -i "%a" -c:a libmp3lame -q 0 -vcodec copy "%~na.mp3"

----------------------------------------------------------------------------------
You have an old computer, and can't play 1080 or even 720 files without glitches ?
Note this takes a LONG time on an old computer, because you are CONVERTING the video stream, which is CPU intensive.

ffmpeg.exe -i input.MP4 -s hd480 out.mp4

Example:

ffmpeg -i "Supernatural S11E23 - Alpha and Omega.mp4" -s hd480 "Supernatural S11E23 - Alpha and OmegaPEQUI.mp4"

-s hd480 = saves file in hd480 format, look at the help file for other options.

----------------------------------------------------------------------------------
If anyone is interested, I can show how to extract subtitles (assuming they are present as a stream), images, how to add audio or subtitles to a video file, remove audio, extract only the audio(useful for youtube videos that only have silly images for music files) etc.
 

Link to comment
Share on other sites


  • Replies 2
  • Views 886
  • Created
  • Last Reply
1 hour ago, jordan4x said:

Nice tuto!

For those who can't deal with command line, there are many graphical user interfaces (GUI) for this program:

WinFF, HandBrake, SUPER, TEnCoder, FFMpegGui...

Thank you. The problem with most GUI frontends is that they can't handle the HUNDREDS of different file types FFMpeg can. Also, most do not have the "copy stream" function, which allows you to convert formats of hour long videos in under 5 seconds on a slow computer. Or stripping metadata.

Of course, I also resort to using the GUI frontends: TenCoder, WonderFox, WinX HD Converter, FormatFactory. Also Avidemux (not FFMpeg based) for correcting timings and Audacity for audio.

;)

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...