Skip to content

slayer81/ffmpeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

ffmpeg cheatsheet

Useful links:

  1. Useful ffmpeg commands to do all sorts of cool things
  2. Very granular config options
  3. A quick guide to using ffmpeg to convert media files
  4. Extract specific audio tracks from video
  5. Convert avi to mp4, lossless and free (as in freedom)

Concatenate multiple video files together

Step 1: Create a text file containing all the files
ls *.mp4 | while read each; do echo "file '$each'" >> mylist.txt; done

Step 2: Use the concat demuxer method
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_filename.mp4

Convert container from mkv to mp4

ffmpeg -i my_movie.mkv -vcodec copy -acodec copy -strict -2 my_movie.mp4

Extract specific audio track from video (track 2)

ffmpeg -i "original_file.mp4" -map 0:v -map 0:2 -c:v libx265 -preset medium -crf 28 -c:a copy original_file_audio_track.aac

Merge an audio and video file

Option 1:
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4

Option 2:
ffmpeg -I video.mp4 -I audio.m4a -c:a copy outputFile.mp4

Option 3:
ffmpeg -i video.mp4 -i audio.wav -c copy output.mkv

Get file metadata using python

def get_metadata(file):
    ffmpegBase = '/usr/local/bin/ffmpeg -i '
    os.chdir(BaseDir)
    readMD = subprocess.Popen(
        ['/usr/local/bin/ffmpeg','-i', file], 
        stdout=subprocess.PIPE, 
        stderr=subprocess.STDOUT)
    print(readMD.stdout.read().decode("utf-8"))```

About

ffmpeg reference doc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published