ffmpeg实现mp4文件转h264文件

Jetson TX2不要试图安装ffmpeg(即使是在SD卡上)
1,空间资源稀缺。
2,安装有异常挂机。

推荐在ubuntu虚拟机上安装ffmpeg:
1,下载FFmpeg 源代码:http://ffmpeg.org/download.html
2,安装yasm:sudo apt-get install yasm
3,编译安装ffmpeg:

./configure
make
sudo make install

4,检测安装是否成功:

zhou@zhou-VirtualBox:/home/ffmpeg$ ffmpeg -version
ffmpeg version N-98725-gcfc6552 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration:
libavutil      56. 58.100 / 56. 58.100
libavcodec     58.100.100 / 58.100.100
libavformat    58. 50.100 / 58. 50.100
libavdevice    58. 11.101 / 58. 11.101
libavfilter     7. 87.100 /  7. 87.100
libswscale      5.  8.100 /  5.  8.100
libswresample   3.  8.100 /  3.  8.100

mp4文件转h264文件:
1,命令:ffmpeg -i input.mp4 -codec copy -bsf: h264_mp4toannexb -f h264 output.h264

  • -i input.mp4: 是输入的MP4文件
  • -codec copy: 从mp4中拷贝
  • -bsf: h264_mp4toannexb: 从mp4拷贝到annexB封装
  • -f h264: 采用h264格式
  • output.264: 输出的文件
    2,执行命令输出:
zhou@zhou-VirtualBox:/home/ffmpeg/data/fire$ ffmpeg -i input.mp4 -codec copy -bsf: h264_mp4toannexb -f h264 output.h264
ffmpeg version N-98725-gcfc6552 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration:
  libavutil      56. 58.100 / 56. 58.100
  libavcodec     58.100.100 / 58.100.100
  libavformat    58. 50.100 / 58. 50.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:32.03, start: 0.000000, bitrate: 6561 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2560x1440, 6434 kb/s, 20 fps, 20 tbr, 10240 tbn, 40 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, h264, to 'output.h264':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.50.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2560x1440, q=2-31, 6434 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  640 fps=0.0 q=-1.0 Lsize=   25135kB time=00:00:31.90 bitrate=6454.8kbits/s speed=1.74e+03x
video:25135kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

3,使用VLC media player播放输出文件output.h264。

你可能感兴趣的:(ffmpeg实现mp4文件转h264文件)