FFmpeg commands: Difference between revisions

From ALT Linux Wiki
No edit summary
 
Line 1: Line 1:
[[ru:Soft/FFmpeg]]
Initially, when I started to use Linux, I was looking for different GUI shells for different tasks (for installing apps, updating the system, and video converter).  But, with time I understand what many actions more comfortable run in the console. Almost everything converters in Linux is GUI under Ffmpeg. But GUI, often, limits the possibility of being utilized or implemented not correctly. In this article, I want to research of using ffmpeg in ALT Linux.
Initially, when I started to use Linux, I was looking for different GUI shells for different tasks (for installing apps, updating the system, and video converter).  But, with time I understand what many actions more comfortable run in the console. Almost everything converters in Linux is GUI under Ffmpeg. But GUI, often, limits the possibility of being utilized or implemented not correctly. In this article, I want to research of using ffmpeg in ALT Linux.



Latest revision as of 23:58, 2 July 2024

Initially, when I started to use Linux, I was looking for different GUI shells for different tasks (for installing apps, updating the system, and video converter). But, with time I understand what many actions more comfortable run in the console. Almost everything converters in Linux is GUI under Ffmpeg. But GUI, often, limits the possibility of being utilized or implemented not correctly. In this article, I want to research of using ffmpeg in ALT Linux.

-13:16, 29 January 2024 (UTC)Petr-akhlamov (talk)

Features

Video converting

For aac need to indicate option -strict experimental.

AVI

$ ffmpeg -i '/home/petr/video/tvrip.mpg' -vcodec libx264 tvrip.avi

MP4

$ ffmpeg -i '/home/petr/video/karlson.avi' -vcodec libx264 /home/petr/karlson.mp4

WMV

$ ffmpeg -i '/home/petr/video/karlson.avi' -vcodec wmv2 -acodec wmav2 karlson.wmv

Webm to MP4

$ ffmpeg -i 'Stan LePard Memorial - Windows 98: Velkommen.webm' -vsync vfr '/home/petr/MS Vwlkommen.mp4'

Audio converting

$ ffmpeg -i '/home/petr/music/Story aint over.mp3' /home/petr/musicfromMF.ogg

Where -i input file, and next path is output. Ending of out file is format (mp3, wav, ogg, wma, aac, flac)

For aac need to indicate option -strict experimental.

$ ffmpeg -i '/home/petr/music/Story aint over.mp3' -strict experimental /home/petr/musicfromMF.aac

Video compression without losses

$ ffmpeg -i timemachinens.mp4 timemachinecompress.mp4 -c:v libx264 -crf 18 -preset veryslow -c:a copy -strict experimental

Changing video resolution

I want to copy the video to phone. He has a small screen. You can change the video resolution, to make the video take less space.

ffmpeg -i '/home/petr/video/Kitten (1996).avi' -strict experimental -s 320x240 /home/petr/Kitten.mp4

As a result, the video is with low resolution, but and low size - 1,6 Gb -> 218,4 Mb. It takes less space, and on a small screen you will not notice the difference.

Extract of audio track

For example, i want to cut sounds from cartoon. I take him, avi file and use next command:

ffmpeg -i '/home/petr/video/carlson.avi' /home/petr/karlson.mp3

I get mp3-file, audiotrack from cartoon, open Audacity and cut needed moments.

Multiple converting

For example, for you need to convert files *avi, *.mkv, *.mp4 and *.mov with some options.

For that we are create special script. Where is bold, need to indicate own parameters:

#!/bin/sh
mkdir conv
for f in *.avi; do
    ffmpeg -i "$f" -acodec copy -strict experimental -s 1280x720 conv/"${f%.*}".mkv
done
for f in *.m{p4,kv,ov}; do
    ffmpeg -i "$f" -acodec copy -strict experimental -s 1280x720 conv/"${f%.*}".mkv
done

Save it as conv.sh and make it to run:

chmod +x conv.sh

Go to catalog with files and run this script.[1]