【问题标题】:ffmpeg: how to save h264 raw data as mp4 fileffmpeg:如何将 h264 原始数据保存为 mp4 文件
【发布时间】:2016-04-15 21:53:57
【问题描述】:

我通过 libavcodec 对 h264 数据进行编码。 例如。

while (1) {
  ...
  avcodec_encode_video(pEnc->pCtx, OutBuf, ENC_OUTSIZE, pEnc->pYUVFrame);
  ...
}

如果我直接将 OutBuf 数据保存为 .264 文件,播放器无法播放。现在我想保存 OutBuf

作为 mp4 文件。任何人都知道如何通过 ffmpeg lib 做到这一点?谢谢。

【问题讨论】:

    标签: c++ ffmpeg h.264 mp4


    【解决方案1】:

    您使用avformat_write_headerav_interleaved_write_frameavformat_write_trailer 和朋友。

    它们的用法见FFmpeg的muxing example

    查看类似主题:Raw H264 frames in mpegts container using libavcodec 同时写入文件(不同的容器,相同的 API)

    另请参阅此处的答案链接:FFMpeg encoding RGB images to H264

    【讨论】:

      猜你喜欢
      • 2014-06-14
      • 1970-01-01
      • 2016-04-01
      • 2020-08-12
      • 1970-01-01
      • 1970-01-01
      • 2020-08-21
      • 1970-01-01
      • 2017-05-14
      相关资源
      最近更新 更多