FFMPEG Commands

From Unixcat.net Wiki
Revision as of 06:30, 5 January 2024 by ToroidalCore (talk | contribs) (Created page with "Here are some FFMPEG scripts I've come up with for various things, mostly converting media of one format to another. == Video == Converting video from one format or container to another. Lines that look like this are meant to just be run as a single command at the terminal: $ ffmpeg -i infile.avi outfile.mp4 Whereas something meant to run as a script will look like this: #!/bin/sh ffmpeg -i infile.avi outfile.mp4 The above should go in a text file and be made...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here are some FFMPEG scripts I've come up with for various things, mostly converting media of one format to another.

Video

Converting video from one format or container to another. Lines that look like this are meant to just be run as a single command at the terminal:

$ ffmpeg -i infile.avi outfile.mp4

Whereas something meant to run as a script will look like this:

#!/bin/sh

ffmpeg -i infile.avi outfile.mp4

The above should go in a text file and be made executable.

Convert Video to x264

This script is useful if you have a device that's older and just plays x264-encoded files. You probably need libx264 installed.

x264conv.sh

#!/bin/sh

for i in *.mp4 *.mkv
do
        j=$(echo $i | sed 's/x265/x264/g')
        ffmpeg -i "$i" -acodec copy -vcodec h264 "$j"
done

This assumes that the file has x265 in the name. It writes a new file with x265 changed to x264, which is reencoded to x264. You'll have to go in and delete the x265 files if you don't want to save them. You should probably also check that the new x264 files play correctly.