My problem is that i need to extract with FFMPEG the audio contained in a video with the same duration. But for some files that i tested, the audio's duration is sometimes shorter than the video's duration. I need to have the exact same duration between the audio and the video file.
The command that i have already tried is this following:
ffmpeg -i input_video.mp4 output_audio.wav
How can i fix this with options in my command ?
I found the solution. To get an audio extract with the exact same length. I use the option -async 1 like this:
ffmpeg -i input_video.mp4 -async 1 output_audio.wav
Related
The problem
As per this post, I use the following command to convert a flac file to mp3 while keeping all metadata:
ffmpeg -i input.flac -ab 320k -map_metadata 0 -id3v2_version 3 output.mp3
When inspecting the converted mp3 file by right-clicking it, going to properties and then details, everything looks in order. The value for "Length" is correct.
When inspecting the converted mp3 file with Mp3tag, the value for "Length" is different. From my testing, the "Length" value is consistently about 28% of what it is supposed to be.
Normally, this isn't an issue. Most music players I use, read the correct length value, same as Windows. However, I've recently discovered that Spotify Mobile for some reason ignores the length value that can be seen in the Windows panel and uses the one that can be seen in Mp3tag.
I want to figure out what command I should use so that after the flac file has been converted to mp3, Mp3tag shows the correct length, and there by, Spotify Mobile reads the correct length as well.
What I have tried
1.
After converting the file to Mp3, I've tried reencoding the mp3 file into a... mp3 file using the following command:
ffmpeg -i original.mp3 -c:v copy -c:a mp3 -vn -ar 44100 -ac 2 -b:a 320k copy.mp3
As can be seen in the image above, this fixes the issue and the length is showing correctly in Mp3tag and in Spotify Mobile.
Issues with this: Reencoding reduces quality and I don't know how to combine the previous flac conversion command and this one into one line.
2.
I tried https://cloudconvert.com/flac-to-mp3 and it worked. The length is displayed correctly in Mp3tag. (What commands did they use on the server???)
Issues with this: I don't want to rely on a cloud service for conversion, I have a lot of files to convert and I'd prefer it to be done locally.
Some demo files
Here is a folder with a flac file, a bad mp3 file (wrong length) and a good mp3 file. It looks like if you preview the music in google drive, it also plays the wrong length for the bad mp3 (39s not 2m19s), while vlc, groove player, spotify (desktop not mobile) all play the correct full length (2m19s) for the bad mp3 file.
Folder: here's the link
It seems I had an outdated version of ffmpeg... (ffmpeg version git-2020-05-23-26b4509) I updated to the latest version and the issue went away. Learned my lesson the hard way.
Would still appreciate an explanation on why this was happening. I'm curious. Why were there two values for length?
I have tried to find a solution already, but just cannot make it work. I want to export an .ogg-video by combining a video slideshow (mp4) with an audio file (wav) by using ffmpeg in python. The audio is shorter than the video and should have an offset of 2000 milliseconds, so that it starts approximately in the middle of the video. The code that I tried is essentially this:
subprocess.call('ffmpeg.exe -itsoffset 0 -i slideshows/slideshow.mp4 -itsoffset 2000 -i sounds/audio.wav -codec:v libtheora -codec:a libvorbis output.ogg', shell= True)
FYI: I need to create a couple of different video formats from the video and audio input, so substituting the ogg with a different format is no option. I have already successfully created .mp4-video-files and .webm-video-files from the material, but need the .ogg in addition. Also, Power Point does not like any of the exported videos, maybe this might be relevant for finding the problem here (I also unsuccessfully tried to fix this issue).
I want to merge a .WAV audio file with a .MP4 video file to create a new .MP4 video file.
And i am currently using the following codes to do that :
ffmpeg -i input_vid.mp4 -i input_audio.wav -vcodec copy -acodec copy output.mp4
But it is only creating output.mp4 file but no videos embedded with that means if i am playing that output.mp4 file then nothing is playing.
And i don't know where i am doing wrong so that it is creating like this.
I know this type of questions already asked by may persons but that didn't help me much so if anybody can find where i am doing wrong or how to solve this problem please help me to solve my problem.
Remove -acodec copy. That option forces a direct copy of the WAV bytes into MP4's audio track.
A valid audio MP4 must contain an MPEG audio track (mp3 or aac). Once you remove -acodec copy then FFmpeg will still copy the video (picture) part but also automatically encode from WAV to AAC for you. AAC is the standar audio codec inside MP4 files (can add MP3 too since all 3 formats are compatible MPEG files).
I'm already taking advatage of two command line utilities. I'm using ffmpeg to convert m4a to mp3, and then I'm combining a few mp3's into one large one using mp3wrap. The resulting file is something like this:
BackgroundMusic.mp3 > Audio1.mp3 > Audio2.mp3
I need something more like
Audio1.mp3 > Audio2.mp3
|_____________________|
|
BackgroundMusic.mp3
To where the background music runs continuously in the background. Would be nice to be able to change the volume of each track too.
Does anyone know a command line program like mp3wrap but can also add in a background track?
I will not be able to use a GUI program such as Audacity, as all of this will be automated on the server.
Thanks!
You can do this with FFmpeg alone.
ffmpeg -i input_audio1 -i input_audio2 -i input_background_audio -filter_complex "
aevalsrc=0:d=10[s1];
[0:a]volume=volume=0.1[volume0];
[1:a]volume=volume=0.1[volume1];
[2:a]volume=volume=0.1[volume2];
[s1][volume1]concat=n=2:v=0:a=1[ac1];
[volume0][ac1]amix=inputs=2[amixed1];
[amixed1][volume2]amix=inputs=2:duration=first" output_audio
You need to use filter_complex to chain all the filters that you are going to use for adjusting the volumes, silent spaces, concat, etc. filters.
As the first step you can concatenate two audio files that you need to play one after the other. To do that I have first created and silent audio using aevalsrc filter with the same duration as the first audio clip. Then use concat filter to concatenate silent audio and the second audio.
To adjust the audio I have used volume filter. You can adjust the volume values accordingly. To mix the audios you can use amix filter. You can specify duration attribute to get the first input which is [amixed1] duration. With that option you can stop the whole audio with the duration of audio1+audio2 without play it for the full duration of background audio duration.
Hope this helps!
I need to change brightness and contrast to a video permanently, I tried this:
mplayer -vf eq=50:50 a.mp4 -dumpstream
mv stream.dump b.mp4
But it saves as a file which look likes the original file. Any idea?
You want to use mencoder to transcode the video to apply the video filter eq=50:50. When you use -dumpstream with mplayer, it simply dumps the stream while the video filter is being applied to playback. Take a look at the mencoder options, but you'll need to chose a video codec and some options for that codec (like bitrate). Then you can apply the brightness and contrast filter.