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.
Related
I am attempting to generate an MP4 video by combining images and audio with FFmpeg-Kit-React-Native but it is not being displayed in web browsers.
For your reference I'm attaching the package link below:
ffmpeg-kit-react-native
The commands I utilized to produce the video are as follows:
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360 -f mp4 ${outputFile}
-loop 1 -i ${imageFile} -i ${audioFile.uri} -shortest -acodec copy ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -b:v 2M -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -pix_fmt yuv420p ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -f mp4 ${outputFile}
I have attached a link to the video I generated using a single image and one audio file
Additionally, I am unable to install external encoding packages such as full-gpl, full, https-gpl, and min-gpl on the Android side.
You do not specify a video codec for your format (-f mp4). In that case ffmpeg uses 'a' default video codec. If i run ffprobe on your file, the output for the video stream is:
Video: mpeg4 (Simple Profile)
According to https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#mpeg-4_mp4, firefox does not support this codec (as to the other browsers, please do your own research).
The solution is to use one of the supported video codecs, e.g. AVC (H.264) or VP9.
To specify the H.264 codec in ffmpeg use the argument -codec:v libx264.
To list all available encoders, run: ffmpeg -encoders
If the required codecs are not listed in the output, you have to configure ffmpeg and specify, e.g. --enable libx264.
See also: FFmpeg - H.264 Video Encoding Guide
I am building FFMpeg with custom options to reduce the final size of .so files on android. I want to convert a mp4 file to a gif. Some options I have already set as I am doing some other processing on mp4 video and aac audio. Now I am stuck at successfully converting a mp4 video to gif.
Following is my options specified
--disable-everything
--enable-decoder=mpeg4,mpegvideo,aac,gif
--enable-parser=aac,mpeg4video,mpegaudio,mpegvideo,gif
--enable-demuxer=mpegvideo,aac,mov,gif
--enable-muxer=mp4,gif,mov
--enable-protocol=file
--enable-encoder=mpeg4,mov,gif
--enable-filter=scale,fps,copy,palettegen,vflip,paletteuse,crop
What other options do i need to add to successfully run this command?
ffmpeg -y -i input.mp4 -vf "fps=15,scale=320:-1:flags=lanczos" -pix_fmt rgb24 output.gif
After enabling logs I figured out I was missing decoder for h264. Here is the updated options. Adding h264 to decoder, parser, encoder, demuxer, muxer (though adding to all of them is unnecessary but it works) The combined .so files for arm is less than 3MB.
--disable-everything
--enable-decoder=mpeg4,mpegvideo,aac,gif,h264
--enable-parser=aac,mpeg4video,mpegaudio,mpegvideo,gif,h264
--enable-demuxer=mpegvideo,aac,mov,gif,h264
--enable-muxer=mp4,gif,mov,h264
--enable-protocol=file
--enable-encoder=mpeg4,mov,gif,h264
--enable-filter=scale,fps,copy,palettegen,vflip,paletteuse,crop
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.
I loop over some files and convert them with ffmpeg. I provide -vcodec h264. When the input video already is encoded with that codec: will the video stream be copied? How to make sure it's not reencoded in that case? Is it what -sameq was used previously?
You need to use -c:v copy if you want the raw H.264 stream to be passed on without re-encoding:
ffmpeg -i myh264file.mp4 -c:v copy -c:a copy myh264output.mp4
-c:a copy will also copy the audio
-c copy will copy both audio and video as in:
ffmpeg -i myh264file.mp4 -c copy myh264output.mp4
Detecting H.264 streams is not straight forward. You will need to code this.
For the -sameq settings please refer to this statement.
I would recommend upgrading to a recent version of ffmpeg if it is not already done as -vcodec is not used anymore, now it is -c:v.
The documentation on ffmpeg could help you.
I have three 3gp file,and I use sox to combine them
sox --combine sequence C:\1.3gp C:\2.3gp C:\3.3gp C:\newaudio.3gp
but It's show that "FAIL formats:no handler for file extension 3gp"
Its means that I have to install some extension?
I'm trying to do it with sox,Can anybody give me any suggestions ?
Or It's possible do it with ffmpeg ?
3gp is a multimedia container and not supported by sox.
You can extract the audio with ffmpeg and further process it with sox although ffmpeg can also do a lot of audio processing.
Here's one way to convert the data to wav, concatenate and convert back to 3gp:
ffmpeg -i 1.3gp 1.wav
ffmpeg -i 2.3gp 2.wav
ffmpeg -i 3.3gp 3.wav
Concatenate, maybe other things with sox (sequence is default so no need to specify):
sox 1.wav 2.wav 3.wav long.wav
Convert back to 3gp:
ffmpeg -i long.wav newaudio.3gp