Showing posts with label converter. Show all posts
Showing posts with label converter. Show all posts

Tuesday, 8 December 2020

How to Install and Use FFmpeg on CentOS 7

FFmpeg is a free and open-source collection of tools for handling multimedia files. It contains a set of shared audio and video libraries such as libavcodec, libavformat, and libavutil. With FFmpeg, you can convert between various video and audio formats, set sample rates, capture streaming audio/video, and resize videos.

This tutorial walks you through installing FFmpeg on CentOS 7.

Prerequisites

To be able to add new repositories and install packages on your CentOS system, you must be logged in as a user with sudo privileges .

Installing FFmpeg on CentOS 7

FFmpeg is not available in CentOS 7 core repositories. You can choose to build the FFmpeg tools from the source or to install it via yum from a third-party Yum repository.

We’ll go with the second option and install from the RPM Fusion repository:

  1. The RPM Fusion repository depends on the EPEL software repository. If the EPEL is not enabled on your system, enable it by typing:

    sudo yum install epel-release
  2. Next, enable the RPM Fusion repository by installing the rpm package :

    sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
  3. Once the repository is enabled, install FFmpeg:

    sudo yum install ffmpeg ffmpeg-devel
  4. Verify the FFmpeg installation by checking its version:

    ffmpeg -version

    At the time of writing this article, the current version of FFmpeg available in the RPM Fusion repository is 3.4.7:

    ffmpeg version 3.4.7 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
    ...

That’s it. FFmpeg has been installed on your CentOS machine and you can start using it.

FFmpeg Examples

In this section, we will look at some basic examples on how to use the ffmpeg utility.

Basic conversion

When converting audio and video files using ffmpeg, you do not have to specify the input and output formats. The input file format is auto-detected, and the output format is guessed from the file extension.

  • Convert a video file from mp4 to webm:

    ffmpeg -i input.mp4 output.webm
  • Convert an audio file from mp3 to ogg:

    ffmpeg -i input.mp3 output.ogg

Specifying codecs

You can specify the codecs you want to use with the -c option. The codec can be the name of any supported decoder/encoder or a special value copy that simply copies the input stream.

  • Convert a video file from mp4 to webm using the libvpx video codec and libvorbis audio codec:

    ffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm
  • Convert an audio file from mp3 to ogg encoded with the libopus codec.

    ffmpeg -i input.mp3 -c:a libopus output.ogg

Conclusion

We have shown you how to install FFmpeg on CentOS 7 machines. You can now visit the official FFmpeg Documentation page and learn how to use FFmpeg to convert and your video and audio files.

If you hit a problem or have feedback, leave a comment below.

 

Source : https://linuxize.com/post/how-to-install-ffmpeg-on-centos-7/

 

Cara Mudah Menampilkan Video di Web dengan HTML5

Masih repot menampilkan file video di halaman web? Kini tidak lagi. Kalau dulu, kita membutuhkan script video player, seperti Flow Player, atau yang lain untuk menampilkan video dan memutarnya di halaman web Anda. Namun kini dengan HTML5, Anda cukup mengupload file videonya saja ke hosting atau web server, lalu membuat tag HTML saja, dan selesai.

Wah mudah banget ya??

So… Bagaimana bentuk tag untuk menampilkan file video ke halaman web dengan HTML5? caranya cukup mudah, cukup membuat tag HTML sebagai berikut:

1
2
3
<video width="..." height="..." controls>
  <source src="namafilemovie" type="mimetype">
</video>

dimana atribut ‘width‘ untuk menentukan panjang frame video playernya (dalam satuan pixel); ‘height‘ menentukan lebarnya (pixel); ‘controls‘ untuk menampilkan panel control pada frame video playernya seperti pengatur volume, full screen, seek bar dll; ‘src‘ untuk menentukan file video yang akan ditampilkan (bisa ditulis dalam bentuk URL); ‘type‘ untuk menentukan mime type dari file video tersebut.

Perhatikan contoh berikut ini ya

1
2
3
4
5
6
7
8
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
</video>
</body>
</html>

Penampakan dari kode di atas pada browser adalah sbb:

Web Video Player dengan HTML5

NB: Jangan lupa menuliskan <!DOCTYPE html> pada bagian paling atas HTML Anda, karena kode tersebut merupakan penciri dari HTML5.

Anda dapat mengatur sendiri panjang dan lebar frame videonya, atau menghilangkan/memunculkan controls nya. Lalu format file video apa saja yang disupport HTML5? Format file video yang disupport adalah: *.mp4 (mime type: video/mp4), *.webm (mime type: video/webm), *.ogg (mime type: video/ogg).

Terkadang pula tidak semua jenis browser mensupport ketiga jenis file tersebut, misalnya browser IE dan SAFARI hanya bisa mensupport *.mp4 saja, atau OPERA hanya mensupport *.ogg dan *.webm saja. Sedangkan untuk CHROME dan Firefox mensupport ketiganya.

Penulisan tag <video> bisa juga seperti di bawah ini:

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<body>
 
<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
 
</body>
</html>

Apa maksud kode di atas? Maksudnya adalah memberikan alternatif format file video. Jika browser yang digunakan mensupport *.mp4, maka file ‘movie.mp4’ yang akan dijalankan. Apabila tidak support, maka yang akan dijalankan ‘movie.ogg’. Sedangkan apabila keduanya tidak disupport maka akan muncul pesan ‘Your browser does not support the video tag.’. Jika Anda membuat kode seperti di atas, maka tentu saja Anda harus mengupload file ‘movie.mp4’ dan ‘movie.ogg’ ke server web.

Dengan HTML5, kita juga bisa membuat tombol Play, Pause, Reload sendiri untuk mengatur jalannya video. Untuk melakukan hal ini, kita menggunakan javascript. Perhatikan contoh berikut ini:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html>
<body>
 
<button onclick="playVid()" type="button">Play Video</button>
<button onclick="pauseVid()" type="button">Pause Video</button>
<button onclick="reloadVid()" type="button">Reload Video</button>
<br>
<video id="video1">
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>
 
<script>
var myVideo=document.getElementById("video1");
 
function playVid()
{
  myVideo.play();
}
 
function pauseVid()
{
  myVideo.pause();
}
 
function reloadVid()
{
  myVideo.load();
}
</script>
 
</body>
</html>

Keterangan:

  • Untuk menjalankan video, cukup panggil dengan method play(), untuk mempausenya dengan method pause(), dan untuk mereload video gunakan load().
  • Perhatikan kode di atas, untuk tag videonya diberi id=”video1″. ID ini nanti akan digunakan untuk proses pemanggilan elemen di javascriptnya, yaitu myVideo=document.getElementById("video1")

Tampilan dari kode di atas adalah sbb:

Web Video Player dengan HTML5

Mudah bukan membuatnya? selamat mencoba dan semoga bermanfaat. Untuk referensi lebih lengkap, Anda bisa mempelajarinya di w3schools.com.

 

Jika pakai subtittle VTT

<video width="1280" height="720" controls autoplay>
    <source src="somefile.mp4" type="video/mp4">
    <track default src="somefile.vtt" kind="captions" srclang="de" label="Deutsch">
</video>

 

Converter srt to vtt online

 https://atelier.u-sub.net/srt2vtt/

 

Source : https://blog.rosihanari.net/cara-mudah-menampilkan-video-di-web-dengan-html5/