美文网首页FFmpeg
Ubuntu 安装 FFmpeg

Ubuntu 安装 FFmpeg

作者: Rinaloving | 来源:发表于2022-09-14 09:42 被阅读0次
1. 官网下载FFmpeg
 http://ffmpeg.org/download.html
2. 安装 yasm
  • sudo apt-get install yasm
root@VERDE-SICC-APPLICATION1:~# sudo apt-get install yasm


root@VERDE-SICC-APPLICATION1:~# 
3. 安装 sdl2.0
  • sudo apt-get install libstdl2-dev
root@VERDE-SICC-APPLICATION1:~# sudo apt-get install libstdl2-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libstdl2-dev
root@VERDE-SICC-APPLICATION1:~# 
4. 出错了
  • 如果sdl2.0 安装出现错误的话可以选择编译安装方式:
    官网下载最新版本: http://www.libsdl.org/download-2.0.php
    解压后进入到目录中,依次执行以下命令:
root@VERDE-SICC-APPLICATION1:/usr/local# rz
 ZMODEM  Session started            e50
------------------------            
 Sent  SDL2-2.24.0.tar.gz               
root@VERDE-SICC-APPLICATION1:/usr/local# sudo tar -zxvf SDL2-2.24.0.tar.gz 
SDL2-2.24.0/
SDL2-2.24.0/WhatsNew.txt
SDL2-2.24.0/Xcode/SDLTest/TestDropFile-Info.plist
SDL2-2.24.0/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
root@VERDE-SICC-APPLICATION1:/usr/local# ls
aegis  bin  cloudmonitor  etc  games  include  jdk1.8.0_241  lib  man  sbin  SDL2-2.24.0  SDL2-2.24.0.tar.gz  share  src  wwwroot
root@VERDE-SICC-APPLICATION1:/usr/local# 
下载解压完后编译
./configure
make
sudo make install
过程:
  • ./configure
root@VERDE-SICC-APPLICATION1:/usr/local/SDL2-2.24.0# ./configure 


checking for shmat... yes
checking for IceConnectionNumber in -lICE... no
checking for X11/extensions/Xext.h... yes
-- dynamic libX11 -> libX11.so.6

Using ime           : YES
Using ibus          : NO
Using fcitx         : NO
  • make
root@VERDE-SICC-APPLICATION1:/usr/local/SDL2-2.24.0# make
/bin/bash ./build-scripts//updaterev.sh
/bin/bash ./build-scripts//mkinstalldirs build
mkdir -p -- build
touch build/.created
  CC     build/SDL.lo
  CC     build/SDL_assert.lo
  CC     build/SDL_dataqueue.lo
  LTLINK build/libSDL2_test.la
ar: `u' modifier ignored since `D' is the default (see `U')
  • sudo make install
root@VERDE-SICC-APPLICATION1:/usr/local/SDL2-2.24.0# sudo make install
/bin/bash ./build-scripts//updaterev.sh
/bin/bash ./build-scripts//mkinstalldirs /usr/local/bin
/usr/bin/install -c -m 755 sdl2-config /usr/local/bin/sdl2-config
/bin/bash ./build-scripts//mkinstalldirs /usr/local/include/SDL2
mkdir -p -- /usr/local/include/SDL2
for file in SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_bits.h SDL_blendmode.h SDL_clipboard.h SDL_cpuinfo.h SDL_egl.h SDL_endian.h SDL_error.h SDL_events.h SDL_filesystem.h SDL_gamecontroller.h SDL_gesture.h SDL_guid.h SDL_haptic.h SDL_hidapi.h SDL_hints.h SDL_joystick.h SDL_keyboard.h SDL_keycode.h SDL_loadso.h SDL_locale.h SDL_log.h SDL_main.h SDL_messagebox.h SDL_metal.h SDL_misc.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengl_glext.h SDL_opengles.h SDL_opengles2_gl2ext.h SDL_opengles2_gl2.h SDL_opengles2_gl2platform.h SDL_opengles2.h SDL_opengles2_khrplatform.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_render.h SDL_rwops.h SDL_scancode.h SDL_sensor.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_system.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_touch.h SDL_types.h SDL_version.h SDL_video.h SDL_vulkan.h begin_code.h close_code.h SDL_test_assert.h SDL_test_common.h SDL_test_compare.h SDL_test_crc32.h SDL_test_font.h SDL_test_fuzzer.h SDL_test.h SDL_test_harness.h SDL_test_images.h SDL_test_log.h SDL_test_md5.h SDL_test_memory.h SDL_test_random.h; do \
    /usr/bin/install -c -m 644 /usr/local/SDL2-2.24.0/include/$file /usr/local/include/SDL2/$file; \
done
/usr/bin/install -c -m 644 include/SDL_config.h /usr/local/include/SDL2/SDL_config.h
if test -f include/SDL_revision.h; then \
    /usr/bin/install -c -m 644 include/SDL_revision.h /usr/local/include/SDL2/SDL_revision.h; \
else \
    /usr/bin/install -c -m 644 /usr/local/SDL2-2.24.0/include/SDL_revision.h /usr/local/include/SDL2/SDL_revision.h; \
fi
/bin/bash ./build-scripts//mkinstalldirs /usr/local/lib
/bin/bash ./libtool --quiet --mode=install /usr/bin/install -c build/libSDL2.la /usr/local/lib/libSDL2.la
/bin/bash ./libtool --quiet --mode=install /usr/bin/install -c build/libSDL2main.la /usr/local/lib/libSDL2main.la
/bin/bash ./libtool --quiet --mode=install /usr/bin/install -c build/libSDL2_test.la /usr/local/lib/libSDL2_test.la
/bin/bash ./build-scripts//mkinstalldirs /usr/local/share/aclocal
mkdir -p -- /usr/local/share/aclocal
/usr/bin/install -c -m 644 /usr/local/SDL2-2.24.0/sdl2.m4 /usr/local/share/aclocal/sdl2.m4
/bin/bash ./build-scripts//mkinstalldirs /usr/local/lib/pkgconfig
mkdir -p -- /usr/local/lib/pkgconfig
/usr/bin/install -c -m 644 sdl2.pc /usr/local/lib/pkgconfig
/bin/bash ./build-scripts//mkinstalldirs /usr/local/lib/cmake/SDL2
mkdir -p -- /usr/local/lib/cmake/SDL2
/usr/bin/install -c -m 644 sdl2-config.cmake /usr/local/lib/cmake/SDL2
/usr/bin/install -c -m 644 sdl2-config-version.cmake /usr/local/lib/cmake/SDL2
root@VERDE-SICC-APPLICATION1:/usr/local/SDL2-2.24.0# 
编译安装FFmpeg
  • 上传解压
root@VERDE-SICC-APPLICATION1:/usr/local# rz
 ZMODEM  Session started            e50
------------------------            
 Sent  ffmpeg-snapshot.tar.bz2               
root@VERDE-SICC-APPLICATION1:/usr/local# ls
aegis  bin  cloudmonitor  etc  ffmpeg-snapshot.tar.bz2  games  include  jdk1.8.0_241  lib  man  sbin  SDL2-2.24.0  SDL2-2.24.0.tar.gz  share  src  wwwroot
root@VERDE-SICC-APPLICATION1:/usr/local# ls
aegis  bin  cloudmonitor  etc  ffmpeg-snapshot.tar.bz2  games  include  jdk1.8.0_241  lib  man  sbin  SDL2-2.24.0  SDL2-2.24.0.tar.gz  share  src  wwwroot
root@VERDE-SICC-APPLICATION1:/usr/local# sudo tar -zxvf  
aegis/              cloudmonitor/       games/              jdk1.8.0_241/       man/                SDL2-2.24.0/        share/              wwwroot/
bin/                etc/                include/            lib/                sbin/               SDL2-2.24.0.tar.gz  src/                
root@VERDE-SICC-APPLICATION1:/usr/local# sudo tar -zxvf  
aegis/              cloudmonitor/       games/              jdk1.8.0_241/       man/                SDL2-2.24.0/        share/              wwwroot/
bin/                etc/                include/            lib/                sbin/               SDL2-2.24.0.tar.gz  src/                
root@VERDE-SICC-APPLICATION1:/usr/local# ls
aegis  bin  cloudmonitor  etc  ffmpeg-snapshot.tar.bz2  games  include  jdk1.8.0_241  lib  man  sbin  SDL2-2.24.0  SDL2-2.24.0.tar.gz  share  src  wwwroot
root@VERDE-SICC-APPLICATION1:/usr/local# tar jxvf ffmpeg-snapshot.tar.bz2 
ffmpeg/
ffmpeg/README.md
ffmpeg/libswresample/
ffmpeg/libswresample/Makefile
ffmpeg/libswresample/version.c
ffmpeg/libswresample/aarch64/
ffmpeg/libswresample/aarch64/resample.S
......
ffmpeg/libpostproc/version_major.h
ffmpeg/libpostproc/version.h
root@VERDE-SICC-APPLICATION1:/usr/local# 
5. 编译安装FFmpeg

./configure
make
sudo make install

过程(略):
6.查看是否安装成功
root@VERDE-SICC-APPLICATION1:/usr/local/ffmpeg# ffmpeg -version
ffmpeg version N-108120-g37a503ac87 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: 
libavutil      57. 36.101 / 57. 36.101
libavcodec     59. 43.100 / 59. 43.100
libavformat    59. 31.100 / 59. 31.100
libavdevice    59.  8.101 / 59.  8.101
libavfilter     8. 48.100 /  8. 48.100
libswscale      6.  8.112 /  6.  8.112
libswresample   4.  9.100 /  4.  9.100
root@VERDE-SICC-APPLICATION1:/usr/local/ffmpeg# 
7. 备注:方法可用libstdl2-dev 改为libsdl2-dev
8. 查看视频信息
  • ffprobe -i qq.mp4 -print_format json -show_format -show_streams -show_data
root@VERDE-SICC-APPLICATION1:/usr/local# mkdir myvideo
root@VERDE-SICC-APPLICATION1:/usr/local# chmod 777 myvideo/
root@VERDE-SICC-APPLICATION1:/usr/local# ls
aegis  cloudmonitor  ffmpeg                   games    jdk1.8.0_241  man      sbin         SDL2-2.24.0.tar.gz  src
bin    etc           ffmpeg-snapshot.tar.bz2  include  lib           myvideo  SDL2-2.24.0  share               wwwroot
root@VERDE-SICC-APPLICATION1:/usr/local# cd myvideo/
root@VERDE-SICC-APPLICATION1:/usr/local/myvideo# rz
 ZMODEM  Session started            e50
------------------------            
 Sent  qq.mp4               0000023be50
root@VERDE-SICC-APPLICATION1:/usr/local/myvideo# ls
qq.mp4
root@VERDE-SICC-APPLICATION1:/usr/local/myvideo# ffprobe -i qq.mp4 -print_format json -show_format -show_streams -show_data
ffprobe version N-108120-g37a503ac87 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: 
  libavutil      57. 36.101 / 57. 36.101
  libavcodec     59. 43.100 / 59. 43.100
  libavformat    59. 31.100 / 59. 31.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 48.100 /  8. 48.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
{
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'qq.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41iso4
    creation_time   : 2022-01-12T04:28:08.000000Z
  Duration: 00:00:53.23, start: 0.000000, bitrate: 372 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m, progressive), 720x720, 237 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      creation_time   : 2022-01-12T04:28:08.000000Z
      handler_name    : Vireo Eyes v2.7.3
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2022-01-12T04:28:08.000000Z
      handler_name    : Vireo Ears v2.7.3
      vendor_id       : [0][0][0][0]
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 720,
            "height": 720,
            "coded_width": 720,
            "coded_height": 720,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 2,
            "pix_fmt": "yuv420p",
            "level": 31,
            "color_range": "tv",
            "color_space": "smpte170m",
            "color_transfer": "smpte170m",
            "color_primaries": "bt470bg",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "id": "0x1",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "30/1",
            "time_base": "1/15360",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 815616,
            "duration": "53.100000",
            "bit_rate": "237477",
            "bits_per_raw_sample": "8",
            "nb_frames": "1593",
            "extradata": "\n00000000: 0164 001f ffe1 001c 6764 001f ac56 240b  .d......gd...V$.\n00000010: 416e 9a82 8303 2000 0003 0020 000f 0001  An.... .... ....\n00000020: e306 3130 0100 0668 e88e cb22 c0         ..10...h...\".\n",
            "extradata_size": 45,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2022-01-12T04:28:08.000000Z",
                "language": "und",
                "handler_name": "Vireo Eyes v2.7.3",
                "vendor_id": "[0][0][0][0]",
                "encoder": "AVC Coding"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "id": "0x2",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 2554880,
            "duration": "53.226667",
            "bit_rate": "128443",
            "nb_frames": "2495",
            "extradata": "\n00000000: 1190                                     ..\n",
            "extradata_size": 2,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2022-01-12T04:28:08.000000Z",
                "language": "und",
                "handler_name": "Vireo Ears v2.7.3",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "format": {
        "filename": "qq.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "53.226667",
        "size": "2477166",
        "bit_rate": "372319",
        "probe_score": 100,
        "tags": {
            "major_brand": "mp42",
            "minor_version": "0",
            "compatible_brands": "mp42mp41iso4",
            "creation_time": "2022-01-12T04:28:08.000000Z"
        }
    }
}
root@VERDE-SICC-APPLICATION1:/usr/local/myvideo# 

相关文章

网友评论

    本文标题:Ubuntu 安装 FFmpeg

    本文链接:https://www.haomeiwen.com/subject/kfyrortx.html