如何将H264视频文件转换为带音频的MP4文件 [英] How to convert H264 video file to MP4 file with audio

查看:1066
本文介绍了如何将H264视频文件转换为带音频的MP4文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to convert H264 video file to MP4 file with audio.
When i am converting H264 to MP4, i could not get the audio when playing the video.





什么我试过了:



我尝试使用ffMPEG将H264文件转换为MP4文件。它转换但音频不会来。你能告诉我在C#.Net中可以实现的原因和方法。



What I have tried:

I tried converting H264 file to MP4 file using ffMPEG. Its converted but audio is not coming. can you tell me the reason and how it can be achieved in C#.Net.

推荐答案

H264是一种视频流格式 - 它不包含任何音频流数据完全。

MP4是一个包,可以包含音频和视频流 - 但它不能发明来自视频数据的音频流!



从你的电影源文件开始:它可能包含视频和音频流,你需要获取/转换它们才能构建一个工作的MP4文件。



使用VLC检查原文:工具...编解码信息将显示原始文件中存在哪些流。 FFMPEG可以将视频和音频流提取为单独的文件,然后再将它们组合起来。



提取音频流:

H264 is a video stream format - it doesn't contain any audio stream data at all.
MP4 is a package, which can contain both audio and video stream(s) - but it can't "invent" an audio stream from video data!

Start with your movie source file: it probably contains both video and audio streams, and you will need to fetch / convert both in order to build a "working" MP4 file.

Check you original with VLC: "Tools...Codec Information" will show you what streams are present in the original file. FFMPEG can extract both Video and Audio streams to separate files, and then combine them back again.

Extract Audio stream:
ffmpeg -i GoodAudioInput.mp4 -c:a copy -vn -sn audio.m4a

获取视频流:

Get Video stream:

ffmpeg -i GoodVideoInput.mp4 -c:v copy -sn -an video.mp4

将两者合并:

Merge the two:

ffmpeg -i video.mp4 -i audio.m4a -c:v copy -c:a aac -strict experimental merged.mp4

重新同步音频:

To resync audio:

ffmpeg -i video.mp4 -itsoffset 3.0 -i audio.m4a -c:v copy -c:a aac -strict experimental merged.mp4

(将在3.0秒后制作音频)

(Will make audio 3.0 seconds later)


这篇关于如何将H264视频文件转换为带音频的MP4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆