Videoview Does Not Play Audio In Video Properly
I have an *.mp4 file which is duration of 2 min. Now it has audio track starting from 30 seconds upto 1.10 min. The rest before 30s and after 1.10min is blank. Now the problem is w
Solution 1:
Ok finally I solved the problem by adding just 1 option -async
ffmpeg -y -i a.mp4 -itsoffset 00:00:30 sng.m4a -map0:0 -map1:0 -c:v copy -preset ultrafast -async 1 out.mp4
By default audio/video timestamps are stretched to match each other; which was my problem of audio starting from intial even after giving itsoffset
.
As per Ffmpeg Doc using async 1
corrects the initial timestamp of audio only. I know that this option is deprecated; but anyhow it solved my case.
Solution 2:
There must be a simpler way to do it but the following works just fine for me:
ffmpeg -y -i a.mp4 -itsoffset 00:00:30 sng.m4a -f lavfi -i "aevalsrc=0" -filter_complex "[1:a][2:a]amix=inputs=2:duration=first:dropout_transition=0, apad[out]" -map0:v -map'[out]' -c:v copy -preset ultrafast -shortest out.mp4
It does the following:
- Create a silent sound
- Mix it with the shifted audio until the end of your m4a file
- Pad with silence indefinitely
- Map this and the input video
- Select the shortest duration (the video duration as the audio duration is infinite because of the pad filter)
Give it a try ;)
Edit: Jay's solution, using "-async 1", is a lot easier, check it!
Post a Comment for "Videoview Does Not Play Audio In Video Properly"