I have wav file in which sound starts exactly at 00:00:00 (checked with sonic-visualiser).
I also have mp4 file without audio and when I combine them with:
ffmpeg -i videoOnly.mp4 -i audio.wav -c:v copy -c:a aac -strict experimental out.mp4
And then examine wav file generated from combined file:
ffmpeg -i out.mp4 out.wav
I see 50ms of silence before actual sound starts. The videoOnly.mp4 doesn't have 'edts' atom, so it's not related to 'elst' atom.
The question is why audio is shifted and how to avoid that?
I figured it out and I think this may be ffmpeg / avconv issue ...
The reason why I've mentioned 'edts' and 'elst' atoms is that I've replaced 'edts' with 'free' in hex editor and since 'elst' is inside of 'edts' I simply ignored it.
However I thought that maybe ffmpeg / avconv doesn't ignore it, so in next try I've replaced 'elst' with zeros in hex editor and did the same steps again.
The result was mp4 file with audio which doesn't have 50ms delay.
Here is avconv version which I was using:
avconv version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Dec 7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
Related
Having an issue here using ffmpeg's add-on Rubberband. When I try to stretch a WAV audio file with a given ratio, the WAV file is generated fine but then, when I want to parse its header, I can see an invalid audio format.
'Unknwon format: 22127'
Have reported this issue on this GitHub tracker. All details are there:
https://github.com/rackfx/Node-WAV-File-Info/issues/11
But now I am very unsure and wonder if it's not a Rubberband bug? Or am I missing something in the ffmpeg command to ensure correct audio format is set?
That's the ffmpeg command I used to generate that stretched WAV file with the invalid audio format (using ffmpeg v3.0.2 here)
ffmpeg -thread_queue_size 2048 -i /home/michael-heuberger/binarykitchen/code/videomail.io/var/local/tmp/clients/videomail.io/11e6-aebd-f5430180-84c7-074d5706928b/videomail_preview.wav -y -acodec libvorbis -ac 1 -filter:a rubberband=tempo=1.454366279637038 -loglevel warning /home/michael-heuberger/binarykitchen/code/videomail.io/var/local/tmp/clients/videomail.io/11e6-aebd-f5430180-84c7-074d5706928b/videomail_preview_for_webm_stretched.wav
Any clues?
Remove -c:a libvorbis. ffmpeg will then automatically choose a common and compatible audio format for WAV.
In manual it says:
ffmpeg -i input.mkv -filter:v 'setpts=0.5*PTS' output.mkv
But when I run:
ffmpeg -i input.mp4 -filter:v 'setpts=0.5*PTS' speedup.mp4
I get an error:
[AVFilterGraph # 0000000002500600] No such filter: 'setpts=0.5*PTS'
Error opening filters!
Not sure if it means that filter can't be opened at all or simply this filter is not available.
How do I run it correctly? Or maybe my release does not support it, then where can I get the release that would work right? Win32/x64 binary
Use both setpts and atempo to speed up both video and audio:
ffmpeg -i input-video.mp4 -vf "setpts=0.68*PTS" -filter:a "atempo=1.467" output-video.mp4
From: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
You'll have to do the right math for the numbers, of course. The setpts needs to be smaller to make the video go faster, but atempo needs to be larger to speed up the audio.
Audio value needed = 1 / Video value
if you have your ffmpeg.exe (mine for windows) for ex you can list all the available filters with this command line, you can edit the txt file c:\filters.txt to see them.
ffmpeg -filters > c:\yfilters.txt
in mine i can se the filter SETPS (VIDEO TO VIDEO only):
setpts V->V Set PTS for the output video frame.
your command line is correct and work with the ffmpeg version that have this filter(try to download the latest version)
this command line works also for me :
ffmpeg -i video_input -vf "setpts=factor*PTS" video_output
the factor can be :
1.for speeding the video 0.2,0.4,0.6,0.8..(<1)
2.for slowing the video:1.2,1.4,1.6,1.8,2.0,3.0,4.0,5.0,10.0... (>1)
Try using double quotes. e.g. ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" speedup.mp4
I have converted my video to mp4 x264 baseline format and it works fine with all pc/mobile phones , the problem is it takes long time to load the video while googling came to know that ffmpeg converts and sets the index file at the eof the video so it loads to the end to read and then plays the video, So any advices would be appreciatable to cut short the loading time.
Note:tryied out QT index swapper2 but dint give much difference , please advice .
this is the cmd i used to convert -
ffmpeg -i … -c:v libx264 -profile:v baseline -level 1 …
Thanks for your time .
You have several options to relocate the moov atom so the video can begin playback before it is completely downloaded by the client.
-movflags faststart
The easiest is the option -movflags faststart when re-encoding:
ffmpeg -i input -c:v libx264 -profile:v baseline -movflags faststart output.mp4
If you already encoded your .mp4 file, but simply want to move the atom:
ffmpeg -i input.mp4 -codec copy -movflags faststart output.mp4
You may need to get a more recent ffmpeg version to use this option. See the FFmpeg download page for links to ffmpeg builds for Linux, OS X, and Windows, or you can follow a step-by-step guide to compile ffmpeg.
qt-faststart
Alternatively you can use the qt-faststart tool that comes with the ffmpeg source:
cd ~/ffmpeg/tools
make qt-faststart
./qt-faststart input.mp4 output.mp4
MP4Box
Or you could use MP4Box (usually provided by the gpac package depending on your distro):
MP4Box -add input.mp4 output.mp4
Also See
FFmpeg and x264 Encoding Guide
FFmpeg and AAC Audio Encoding Guide
I'm trying to combine and encode some files from wav to m4a. I installed both ffmpeg and sox from source to make sure nothing was disabled. When I do the conversion with ffmpeg
ffmpeg -i input.wav -acodec aac -strict experimental output.m4a
it works fine. When I use SoX
sox input.wav output.m4a
I get the error
[NULL # 0x251b4e0] Codec is experimental but experimental codecs are not enabled, see -strict -2
sox FAIL ffmpeg: ffmpeg could not open CODEC
sox FAIL formats: can't open output file `output.m4a':
I need to way to get SoX to tell ffmpeg that its ok to use the experimental codecs.
Also I already tried using this guide http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide to install the fdk-acc encoder, but it didn't work. The experimental one works fine so I'd rather just use that.
I don't think sox supports m4a formats. you can do sox --help to see the audio file formats supported.
Hi i have command to merge video files
but i want to join an image to a video file.
What i am doing:
1) convert image to mp4 using ffmpeg
2) joining this converted video to my selected video using mencoder
but it prommpts an error:
cannot mix video only files with audio-video files try -nosound.
i also added -nosound but with this the resultant file does not contains any audio.
what to do?
ffmpeg command:
-y -i Garden.jpg -s 640x480 converted.mp4
this converted .mp4 file is created properly but with no audio
mencoder command:
-oac mp3lame -ovc lavc -noodml -o output.mp4 converted.mp4 selected.mp4
Please help..
If you target is Windows, converting the result to msmpeg4v2 (avi) or mpeg1video (mpg) or asf (wmv) would probably work best.
Note, ASF files often have .wmv or .wma extensions in Windows. It should also be mentioned that Microsoft claims a patent on the ASF format, and may sue or threaten users who create ASF files with non-Microsoft software. It is strongly advised to avoid ASF where possible.
Read this for full list.
Here is a free command line tool which can join MPEG 1 files:
http://mpgtx.sourceforge.net/#Download
(Windows exe available). Did not try it on my own, however.
EDIT: another alternative may be to utilize VirtualDub. You have to write your merge command to a script and pass the script name per command line:
http://www.virtualdub.org/blog/pivot/entry.php?id=20
However, you have to get yourself through the syntax of the scripting language
http://www.virtualdub.org/docs/vdscript.txt
(I did not try this by myself programmatically, have only used virtual dub via GUI interface to concat video files, which worked really well.)
FFmpeg can accomplish this easily with the following command:
ffmpeg -i vid-1.mp4 -i vid-2.mp4 -ar 44100 -ab 64k -ac 1 -c:a libmp3lame -filter_complex '[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' output.mp4