Click here to Skip to main content
14,211,795 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.

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.
Updated 1-May-19 4:08am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
(Will make audio 3.0 seconds later)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190619.2 | Last Updated 1 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100