Linux convert avi to mp4

Как просто и быстро конвертировать видео в Linux

Часто для конвертации видео файлов мы используем различные онлайн-сервисы, однако, что делать если нет доступа к сети или файл слишком большой, в данной статье мы расскажем о двух способах справиться с этой задачей

Ciano

Ciano – одна из самых простых утилит для выполнения данной задачи, однако чтобы её установить нам понадобится дополнительная утилита flatpack, чтобы её установить выполните:

sudo apt install flatpak

После чего установите Ciano:

flatpak remote-add —if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

flatpak install flathub com.github.robertsanseries.ciano

После установки запустите приложение Ciano

Выберите вкладку «Video» в меню слева, далее выберите необходимый формат видео, после чего нажмите на кнопку «+» и выберите все необходимые файлы, далее остается только нажать на кнопку «Start conversion» и ожидать окончания процесса.

FFMPeg

FFMPeg – одна из самых мощных утилит для конвертирования файлов, однако у неё отсутствует графическая оболочка, из-за чего многие новички предпочитают ей Ciano. Чтобы установить FFMPeg выполните:

sudo apt install ffmpeg

Далее откройте терминал и перейдите в директорию, в которой содержатся необходимые видео. Чтобы конвертировать один файл из avi в mp4 выполните:

ffmpeg -i video-file.avi video-file.mp4

Чтобы конвертировать все файлы в директории в mp4 выполните:

for i in *.avi; do ffmpeg -i «$i» «$.mp4»; done

Чтобы открыть справку по FFMPeg выполните

man ffmpeg или ffmpeg —help

Источник

Convert AVI (Xvid) to MP4 (H.264) keeping the same quality

I want to compress an AVI file to MP4 using an h.264 codec. I could not get the same quality. How can I compress it?

Original Video:

Original Video Screen: FFmpeg console output ( ffmpeg -i input.avi ):

FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4) configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopenc ore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libop enjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 [mpeg4 @ 0x626b50] Invalid and inefficient vfw-avi packed B frames detected Input #0, avi, from 'input.avi': Metadata: encoder : VirtualDubMod 1.5.10.2 (build 2542/release) Duration: 01:32:38.13, start: 0.000000, bitrate: 2094 kb/s Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 23.98 tbr, 23.98 tbn, 23.98 tbc Stream #0.1: Audio: ac3, 44100 Hz, 5.1, s16, 384 kb/s At least one output file must be specified 

Test 1

ffmpeg -i input.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 1.mp4 

Test 1 Screen: FFmpeg console output ( ffmpeg -i 1.mp4 )

 FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4) configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:01:00.01, start: 0.000000, bitrate: 618 kb/s Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 437 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(und): Audio: aac, 44100 Hz, 5.1, s16, 176 kb/s Metadata: creation_time : 1970-01-01 00:00:00 At least one output file must be specified 

Test 2

ffmpeg -y -i input.avi -pass 1 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -f mp4 -an -y /dev/null ffmpeg -y -i input.avi -pass 2 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -acodec libfaac -ab 128k -ac 2 2.mp4 

Test 2 Screen: FFmpeg console output ( ffmpeg -i 2.mp4 )

FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4) configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:01:00.01, start: 0.000000, bitrate: 1097 kb/s Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 1028 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 63 kb/s Metadata: creation_time : 1970-01-01 00:00:00 At least one output file must be specified 

Источник

Читайте также:  Имитация нажатия клавиш linux

how to convert avi (xvid) to mkv or mp4 (h264)

Very noob when it comes to video. I’m trying to make sense of what I»m finding via Google. but its mostly Greek to me. I have a bunch of Avi files that won’t play in my WD TV Play box. Mediainfo tells me they are xvid. Specs for the box show that should be fine. but digging through forums says its hit-and-miss. So I’d like to try converting them to h264 encoded MKV or mp4 files. I gather avconv is the tool, but reading the manual just has me really really confused. I tried the very basic example of:

avconv -i file.avi -c copy file.mp4 

it took less than 4 seconds. And it worked. sort of. It «played» in that something came up on the screen. but there was horrible artifacting and scenes would just sort of melt into each other. I want to preserve quality if possible. I’m not concerned about file size. I’m not terribly concerned with the time it takes either, provided I can do them in a batch. Can someone familiar with the process please give me a command with the options? Thank you for your help. I’m posting the mediainfo in case it helps:

General Complete name : \\SERVER\Video\Public\test.avi Format : AVI Format/Info : Audio Video Interleave File size : 189 MiB Duration : 11mn 18s Overall bit rate : 2 335 Kbps Writing application : Lavf52.32.0 Video ID : 0 Format : MPEG-4 Visual Format profile : Advanced Simple@L5 Format settings, BVOP : 2 Format settings, QPel : No Format settings, GMC : No warppoints Format settings, Matrix : Default (H.263) Muxing mode : Packed bitstream Codec ID : XVID Codec ID/Hint : XviD Duration : 11mn 18s Bit rate : 2 129 Kbps Width : 720 pixels Height : 480 pixels Display aspect ratio : 16:9 Frame rate : 29.970 fps Standard : NTSC Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Compression mode : Lossy Bits/(Pixel*Frame) : 0.206 Stream size : 172 MiB (91%) Writing library : XviD 1.2.1 (UTC 2008-12-04) Audio ID : 1 Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Codec ID : 55 Codec ID/Hint : MP3 Duration : 11mn 18s Bit rate mode : Constant Bit rate : 192 Kbps Channel(s) : 2 channels Sampling rate : 48.0 KHz Compression mode : Lossy Stream size : 15.5 MiB (8%) Alignment : Aligned on interleaves Interleave, duration : 24 ms (0.72 video frame) 

You should consider to not reencode from one lossy codec to another. In the case where your video is in Xvid codec, just remux it into the Matroska container.

Читайте также:  Linux запуск приложения от имени другого пользователя

6 Answers 6

avconv -i test.avi -c:v libx264 -c:a copy outputfile.mp4 

This will re-encode your video to h264 (=AVC) and keep your sound unchanged which is mp3 and completely legal to the standard.

A few other options to consider with this commandline are:

  • Tweak the quality of the output video by using the -b parameter (bitrate) or use Constant Rate Factor (CRF) with something like -crf 22
  • Use a libx264 preset such as -preset veryslow for improved video

If you use these the options should be placed after -c:v libx264 option.

You may also look at the GUI programs winff and avidemux which will make things less complicated. (also handbrake is a good one but i never came to terms with it )

Ha! I don’t know how you look at that gobble-de-gook of a manpage and pull that line out as an obvious «standard command». but I’m thankful that you did! It worked. I appreciate it.

Thanks for mentioning Handbrake — I had it and completely forgot about it. I ended up opening it, searching for my movie folder, slurped all the videos in, enqueued them all, and hit «Encode»!

For AAC sound many devices might have a hardware decoder, so keeping it as MP3 is not necessarily better.

In case you are looking for something graphical, you can consider using mkvtoolnix-gui package. It actually depends on the command line utility, but it will execute the command with all the needed options for you.

mkvmerge gui 1

The first thing that you’ll need to do is to add the files containing all the needed streams. You do that (obviously) by pressing add button and selecting the file or by dragging your files into the «Input files» area. You should not use append button, unless your intention is to place the contents of one file after the contents of another (making the final file’s duration the sum of all the appended ones).

Читайте также:  Ускорить работу hdd linux

Since you are saying you are planning to just convert .avi files, then you should simply add one file at the time. Note that the first file that you will add will automatically set the name of the output file, it will match the input name, but the extension will be changed to .mkv . You can of course change that if you wish.

After you add something you will be able to change the parameters of the streams (such as the assigned language, whether the track is «on» by default, and whether a user can chose to disable this stream all together if one wishes.

You can give the title for the stream. I suggest that if you have multi-audio video that you use that together with the language. For example you can have «original» or «single-voice dub» or «director’s commentary» for the track names. Many players will show you these when you select the stream to play, and it is very useful. Try not to repeat the information there, however. There is no reason to write «English language» when you can just set the track’s language code.

There are also some specific options, which will depend upon which stream you are working on.

mkvmerge gui 2

Sometimes you may wish to add some attachments to your file. If you add an image, many file managers will display this picture as the icon for the final video file. If you are muxing some sort of film, and you happen to have the cover for it, it may be a good choice to put it in as the attachment.

mkvmerge gui 3

Finally in the Global tab you are able to set the metadata for the whole file. The most common thing is to set the title. It will be prefilled by the data taken from the first file that you have added to the «Input files».

You can also add chapter information. Mkvmerge is able to read ogm chapter file as well as xml chapters. It also allows you to edit chapter files, but keep in mind that this tab functions as a separate application, so you won’t be editing chapters that are added to your output file, you will need to save them in that tab, and then add them as the input to the file you are now muxing.

The interesting feature of mkvmerge gui is the «Copy to clipboard» which copies the exact terminal command that the application is planning to run. If you intend to mux many files you can set one up, just the way you like it, then copy the command to clipboard and make a bash script that does all the files you want at once.

Источник

Оцените статью
Adblock
detector