ffmpeg is failing to convert mov files from iPhone 4 - ios4

I'm having issue with converting mov files from iPhone 4.
Running this command:
I, [2014-09-15T03:48:33.245231 #9676] INFO -- : Running transcoding...
ffmpeg -y -i /Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video/1410727644xqxzdoxf-IMG_0040_1_.MOV -ss 5 -vframes 1 -f image2 /Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video/1410727644xqxzdoxf-IMG_0040_1_-edited.jpg
E, [2014-09-15T03:48:33.321367 #9676] ERROR -- : Failed encoding...
ffmpeg -y -i /Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video /1410727644xqxzdoxf-IMG_0040_1_.MOV -ss 5 -vframes 1 -f image2 /Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video/1410727644xqxzdoxf-IMG_0040_1_-edited.jpg
My ffmpeg gives me errors like this:
FFMPEG::Error: Failed encoding.Errors: no output file created. Full output: ffmpeg version 2.3.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 20 2014 02:23:29 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 48.100 / 55. 48.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.100 / 4. 11.100
libavresample 1. 3. 0 / 1. 3. 0
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video/1410641311nyv99k1j-IMG_0040_1_.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2014-07-20 09:47:08
model : iPhone 4
model-rus : iPhone 4
encoder : 7.0.4
encoder-rus : 7.0.4
date : 2014-07-20T13:47:08+0400
date-rus : 2014-07-20T13:47:08+0400
make : Apple
make-rus : Apple
Duration: 00:00:01.84, start: 0.000000, bitrate: 827 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 742 kb/s, 23.98 fps, 23.98 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 90
creation_time : 2014-07-20 09:47:08
handler_name : Core Media Data Handler
encoder : H.264
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2014-07-20 09:47:08
handler_name : Core Media Data Handler
[swscaler # 0x7fe1e9800600] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/Users/lun/client/bookagoo/public/uploads/5405e9b0486f75a36c100000/video/1410641311nyv99k1j-IMG_0040_1_-edited.jpg':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
make-rus : Apple
model : iPhone 4
model-rus : iPhone 4
make : Apple
encoder : Lavf55.48.100
date : 2014-07-20T13:47:08+0400
date-rus : 2014-07-20T13:47:08+0400
Stream #0:0(und): Video: mjpeg, yuvj420p, 480x360, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
Metadata:
rotate : 90
creation_time : 2014-07-20 09:47:08
handler_name : Core Media Data Handler
encoder : Lavc55.69.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
It's only happening for mov files. There are couple of tricky places it looks like it's trying to take screenshot from a video.
Maybe anyone witnessed anything similar and can give me a tip?

The problem
Your command is telling ffmpeg to skip the first 5 seconds, but the console output indicates that the input duration is only 00:00:01.84 (just under 2 seconds).
Using the select filter
If you're trying to get a screen shot from a variety of inputs with varying durations you can look at the select filter instead of using -ss.
Example to create a mosaic of various scenes:
ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
Using ffprobe with -ss
Alternatively, with some scripting you can use ffprobe to get the duration, and then calculate an appropriate value for -ss.

Related

How to convert aac to ogg opus keeping bit rate and sample rate unchanged

I'm trying to convert a .aac file to .opus but after inspecting with ffprobe I get different bit and sample rates.
While input file's audio stream bit rate is 245995, the output file's audio stream has no bit rate specified - "format" shows bit rate of 118788.
While input file's audio stream sample rate is 44100, the output's is 48000.
ffprobe -v error -show_format -show_streams input.aac
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/44100
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/28224000
start_pts=N/A
start_time=N/A
duration_ts=106533390807
duration=3774.567418
bit_rate=245995
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=input.aac
nb_streams=1
nb_programs=0
format_name=aac
format_long_name=raw ADTS AAC (Advanced Audio Coding)
start_time=N/A
duration=3774.567418
size=116065589
bit_rate=245995
probe_score=51
[/FORMAT]
ffmpeg -nostdin -i input.aac -c:a libopus output.opus
ffmpeg version N-93449-g013f714 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
configuration: --prefix=/home/vagrant/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/vagrant/ffmpeg_build/include --extra-ldflags=-L/home/vagrant/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/vagrant/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.105 / 58. 47.105
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[aac # 0x55d4b7e21d80] Estimating duration from bitrate, this may be inaccurate
Input #0, aac, from 'input.aac':
Duration: 01:02:54.57, bitrate: 245 kb/s
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 245 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (aac (native) -> opus (libopus))
[libopus # 0x55d4b7e3f8c0] No bit rate set. Defaulting to 96000 bps.
Output #0, opus, to 'output.opus':
Metadata:
encoder : Lavf58.26.101
Stream #0:0: Audio: opus (libopus), 48000 Hz, stereo, flt, 96 kb/s
Metadata:
encoder : Lavc58.47.105 libopus
size= 52103kB time=00:59:53.21 bitrate= 118.8kbits/s speed=66.2x
video:0kB audio:51733kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.715930%
ffprobe -v error -show_format -show_streams output.opus
[STREAM]
index=0
codec_name=opus
codec_long_name=Opus (Opus Interactive Audio Codec)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=172473677
duration=3593.201604
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:ENCODER=Lavc58.47.105 libopus
[/STREAM]
[FORMAT]
filename=output.opus
nb_streams=1
nb_programs=0
format_name=ogg
format_long_name=Ogg
start_time=0.000000
duration=3593.201604
size=53353867
bit_rate=118788
probe_score=100
[/FORMAT]
How can I preserve the quality of the input file? Am I missing something in the ffmpeg cmd?
There is no sample rate of 44100 with Opus, so in this case you have to resample.
The available sampling rates for Opus are 8, 12, 16, 24, or 48 kHz (according to the RFC6716 section Resampling).
There might be no matching bitrate either. Then you are anyway re-encoding and hence quality loss. And finally an attempt to match bitrates does not imply that the data is of equal encoding quality, even though certain correlation exists.

fluent ffmpeg size output option not working

Summary: I'm trying to limit output to 3mb, .outputOptions('-fs 3000000') isn't working for me, the file is coming back with a size of 119260428 or 119mb.
Here is the code to try for yourself, all you need is a test.mp3 large enough that the resulting testoutput.ogg is > 3mb:
var ffmpeg = require("fluent-ffmpeg");
var command = ffmpeg();
var convertToOGG = function(){
var fileName = 'test.mp3'
ffmpeg.ffprobe(fileName, function(err, metadata) {
command
.input(fileName)
.inputFormat("mp3")
.audioChannels(1)
.outputOptions('-fs', 3000000)
.output('testoutput.ogg')
.on("progress", function(progress) {
console.log("Processing: " + progress.timemark);
})
.on("error", function(err, stdout, stderr) {
console.log("Cannot process video: " + err.message);
})
.on("end", function(stdout, stderr) {
ffmpeg.ffprobe('testoutput.ogg', function(err,metadata){
if(metadata.format.size >= 3000000){
console.log("didn't work")
}
})
})
.run();
});
};
convertToOGG();
Per the fluent-ffmpeg documentation you should be able to use a ffmpeg command in an output option: outputOption()
This method allows passing any output-related option to ffmpeg. You can call it with a single argument to pass a single option, optionnaly
with a space-separated parameter:
/* Single option */
ffmpeg('/path/to/file.avi').outputOptions('-someOption');
and in FFMPEG's documentation:
-fs limit_size (output) Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The
size of the output file is slightly more than the requested file size.
It's giving me no errors, just seemingly ignoring the file size limit of 99mb and outputting a 119.3mb file.
Edit - Looks like -fs 3000000 is working for mp3 to wav, but still wont do mp3 to ogg. This is the output from running the command in terminal:
✗ ffmpeg -i test.mp3 -fs 3000000 testoutput.ogg
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mp3 # 0x7fc6a4000000] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'test.mp3':
Metadata:
lyrics-eng : xxx
title : xxx
artist : xxx
album_artist : xxx
album : xxx
genre : xxx
Duration: 03:27:28.74, start: 0.000000, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s
Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 540x360, 90k tbr, 90k tbn, 90k tbc
Metadata:
title : Array
comment : Cover (front)
[swscaler # 0x7fc6a4808800] deprecated pixel format used, make sure you did set range correctly
[ogg # 0x7fc6a3815800] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Output #0, ogg, to 'testoutput.ogg':
Metadata:
lyrics-eng : xxx
title : xxx
artist : xxx
album_artist : xxx
album : xxx
genre : xxx
encoder : Lavf57.56.100
Stream #0:0: Video: theora (libtheora), yuv444p, 540x360, q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc
Metadata:
title : Array
DESCRIPTION : Cover (front)
encoder : Lavc57.64.101 libtheora
lyrics-eng : xxx
artist : xxx
ALBUMARTIST : xxx
album : xxx
genre : xxx
Stream #0:1: Audio: vorbis (libvorbis), 44100 Hz, mono, fltp
Metadata:
encoder : Lavc57.64.101 libvorbis
lyrics-eng : xxx
title : xxx
artist : xxx
ALBUMARTIST : xxx
album : xxx
genre : xxx
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:0 -> #0:1 (mp3 (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=-0.0 Lsize= 116465kB time=03:27:28.71 bitrate= 76.6kbits/s speed=61.2x
video:9kB audio:114907kB subtitle:0kB other streams:0kB global headers:6kB muxing overhead: 1.347787%
The source mp3 contains a cover image. Attempting to transcode the source file to ogg results in an unusually high framerate for the video stream.
There's a problem with the framerate estimation: 90k fps resembles the stream timebase value:
[ogg # 0x7fc6a3815800] Frame rate very high for a muxer not efficiently supporting it.
[...]
Stream #0:0: Video: theora (libtheora), yuv444p, 540x360, q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc
This could be caused by a problem with the source file, a bug in ffmpeg or maybe both.
A quick solution is to ignore the cover image using either -map 0:a or -vn.

ffmpeg does not recognize audio stream in video

I have these flv files that exported from Adobe Connect and I want to extract their audio with ffmpeg. ffmpeg does not recognize the audio on some of them. This log is from one file that has issues:
>ffmpeg.exe -i r7anupl75gl_0_1965937.flv test1.mp3
ffmpeg version N-76123-g002b049 Copyright (c) 2000-2015 the FFmpeg
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
libavutil 55. 4.100 / 55. 4.100
libavcodec 57. 7.100 / 57. 7.100
libavformat 57. 8.102 / 57. 8.102
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 11.100 / 6. 11.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
[flv # 0000000000522140] Could not find codec parameters for stream 1
(Audio: none, 0 channels): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize'
options
Input #0, flv, from 'r7anupl75gl_0_1965937.flv':
Metadata:
lasttimestamp : 5026
lastkeyframetimestamp: 5022
audiodelay : 0
canSeekToEnd : false
creationdate : unknown
metadatacreator : Manitu Group FLV MetaData Injector 2
videosize : 251586025
audiosize : 55776880
datasize : 516
Duration: 01:23:47.75, start: 0.000000, bitrate: 489 kb/s
Stream #0:0: Video: vp6f, yuv420p, 1184x704, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: none, 0 channels
Output #0, mp3, to 'test1.mp3':
Output file #0 does not contain any stream
Note: audio codec is Nellymoser Asao and this command works successfully for some files.
Consider increasing the value for the 'analyzeduration' and 'probesize'
The problem is in first 10-15 min the flv file doesn't actually have any audio. By increasing probesize and analyzeduration it looks further in the file to find audio and detect it.
In my scenario I have to set analyzeduration bigger than 5000000 (5 seconds).

Audio is lost on transcoding from DTS to AAC

On a Synology drive, I'm trying to transcode audio in an .MKV file from DTS to AAC using the native ffmpeg encoder. But without any error message (at least I don't recognize any here), the audio stream is just missing in the output files. I tried it on several different files, all with the same result, leading to the conclusion that either I'm unable to see the error or something's wrong with FFMPEG. I used the standard FFMPEG package provided with OPKG.
This is the output I usually get:
CirkosDaten> ffmpeg -i encodertest.mkv -map 0 -c:v copy -c:s copy -c:a aac
-strict experimental output.mkv
ffmpeg version 2.0.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 3 2015 06:25:48 with gcc 4.6.4 (Marvell GCC release
20150204-c4af733b 64K MAXPAGESIZE ALIGN CVE-2015-0235)
configuration: --prefix=/usr/syno --incdir='${prefix}/include/ffmpeg'
--arch=arm --target-os=linux --cross-prefix=/usr/local/arm-marvell-linux-
gnueabi/bin/arm-marvell-linux-gnueabi- --enable-cross-compile --enable-
optimizations --enable-pic --enable-gpl --enable-shared --disable-static
--enable-version3 --enable-nonfree --enable-libfaac --enable-encoders
--enable-pthreads --disable-bzlib --disable-protocol=rtp --disable-
muxer=image2 --disable-muxer=image2pipe --disable-swscale-alpha --disable-
ffserver --disable-ffplay --disable-devices --disable-bzlib --disable-
altivec --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
libmp3lame --disable-vaapi --disable-decoder=amrnb --disable-encoder=zmbv
--disable-encoder=dca --disable-encoder=ac3 --disable-encoder=ac3_fixed
--disable-encoder=eac3 --disable-decoder=dca --disable-decoder=eac3
--disable-decoder=truehd --cc=/usr/local/arm-marvell-linux-gnueabi/bin/arm-
marvell-linux-gnueabi-ccache-gcc
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Guessed Channel Layout for Input Stream #0.2 : 5.1
Input #0, matroska,webm, from 'encodertest.mkv':
Metadata:
title : encodingtest
creation_time : 2012-09-23 09:38:19
Duration: 00:01:00.94, start: 0.000000, bitrate: 9624 kb/s
Chapter #0.0: start 0.000000, end 55.347000
Metadata:
title : 00:00:00.000
Chapter #0.1: start 55.347000, end 60.936000
Metadata:
title : 00:04:56.171
Stream #0:0: Video: h264 (High), yuv420p, 1920x816 [SAR 1:1 DAR 40:17], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : encodingtest
Stream #0:1(ger): Audio: dts, 48000 Hz, 5.1 (default)
Metadata:
title : DTS
Stream #0:2(eng): Audio: dts, 48000 Hz, 5.1
Metadata:
title : DTS
Stream #0:3(ger): Subtitle: subrip (default)
Metadata:
title : Forced Subs
Output #0, matroska, to 'output.mkv':
Metadata:
title : encodingtest
encoder : Lavf55.12.100
Chapter #0.0: start 0.000000, end 55.347000
Metadata:
title : 00:00:00.000
Chapter #0.1: start 55.347000, end 60.936000
Metadata:
title : 00:04:56.171
Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1920x816 [SAR 1:1 DAR 40:17], q=2-31, 23.98 fps, 1k tbn, 1k tbc (default)
Metadata:
title : encodingtest
Stream #0:1(ger): Subtitle: subrip (default)
Metadata:
title : Forced Subs
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:3 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1461 fps=528 q=-1.0 Lsize= 54636kB time=00:01:00.81 bitrate=7360.1kbits/s
video:54624kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.023249%encodingtest
When I additionally set the bitrate, the output says
Codec AVOption b (set bitrate (in bits/s)) specified for output file #0
(output.mkv) has not been used for any stream. The most likely reason is
either wrong type (e.g. a video option with no video streams) or that it is
a private option of some encoder which was not actually used for any stream.
This indicates that somehow the 5.1, 48kHz DTS stream isn't considered as an input. Why?
EDIT: Is it possible that DTS decoding is turned off somewhere here? I reckoned maybe that's why I get no errors. But I didn't see any obvious option for that in the output.
OK, I think I found the error:
--disable-decoder=dca
So this armv7 FFmpeg build i used and got via OPKG is compiled without DCA decoding.
Probably I'll need to recompile this on my Disk Station with all the codecs :-( - or does anybody know whether it's possible to just upgrade via IPKG/OPKG?
Does anyone else think building FFmpeg yourself is an ordeal? :-)
EDIT: I just tried to used the standard 32bit package from the FFmpeg project, and indeed it works on armv7 too. Problem solved.

FFmpeg audio channel rematrix (5.1 to stereo)

I've got a (very large!) Apple ProRes 422 file with 16ch audio. To be able to use it on a less powerful computer, I'd like to convert it to a standard MP4 file (h264 video codec, stereo audio). The original file has 16 channels of audio, however, and FFmpeg gives an error when I try to convert it ('Rematrix is needed'). How do I do rematrixing of audio channels? Are there additional steps needed?
This is the FFmpeg command I used:
ffmpeg -y -i Capture0000.mov -vcodec libx264 -vb 2000k -pix_fmt yuv420p -coder 0 -profile:v baseline -acodec libfaac -ab 128k /tmp/out.mp4
This is the FFmpeg output:
ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
built on May 8 2014 14:17:45 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/usr/local/ffmpeg_build --extra-cflags=-I/usr/local/ffmpeg_build/include --extra-ldflags=-L/usr/local/ffmpeg_build/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-libxvid --enable-libfaac
libavutil 52. 81.100 / 52. 81.100
libavcodec 55. 60.103 / 55. 60.103
libavformat 55. 37.102 / 55. 37.102
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 5.100 / 4. 5.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Capture0000.mov':
Metadata:
creation_time : 2014-08-17 18:30:31
Duration: 01:01:22.52, start: 0.000000, bitrate: 202001 kb/s
Stream #0:0(eng): Video: prores (apch / 0x68637061), yuv422p10le, 1920x1080, 183513 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 2500 tbn, 2500 tbc (default)
Metadata:
creation_time : 2014-08-17 18:30:31
handler_name : Apple Alias Data Handler
encoder : Apple ProRes 422 (HQ)
Stream #0:1(eng): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, 16 channels, s32, 18432 kb/s (default)
Metadata:
creation_time : 2014-08-17 18:30:31
handler_name : Apple Alias Data Handler
[auto-inserted resampler 0 # 0x3943da0] [SWR # 0x39441a0] Rematrix is needed between 16 channels and 5.1 but there is not enough information to do it
[auto-inserted resampler 0 # 0x3943da0] Failed to configure output pad on auto-inserted resampler 0
Error opening filters!
This is the FFprobe output:
ffprobe version 2.2.git Copyright (c) 2007-2014 the FFmpeg developers
built on May 8 2014 14:17:45 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/usr/local/ffmpeg_build --extra-cflags=-I/usr/local/ffmpeg_build/include --extra-ldflags=-L/usr/local/ffmpeg_build/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-libxvid --enable-libfaac
libavutil 52. 81.100 / 52. 81.100
libavcodec 55. 60.103 / 55. 60.103
libavformat 55. 37.102 / 55. 37.102
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 5.100 / 4. 5.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Capture0000.mov':
Metadata:
creation_time : 2014-08-17 18:30:31
Duration: 01:01:22.52, start: 0.000000, bitrate: 202001 kb/s
Stream #0:0(eng): Video: prores (apch / 0x68637061), yuv422p10le, 1920x1080, 183513 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 2500 tbn, 2500 tbc (default)
Metadata:
creation_time : 2014-08-17 18:30:31
handler_name : Apple Alias Data Handler
encoder : Apple ProRes 422 (HQ)
Stream #0:1(eng): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, 16 channels, s32, 18432 kb/s (default)
Metadata:
creation_time : 2014-08-17 18:30:31
handler_name : Apple Alias Data Handler
Found it! After extracting only the audio, it turned out the first two channels were stereo, and the other four empty, so I added this:
-af 'pan=stereo:c0=FL:c1=FR'
Which takes only the front left and front right channel for the stereo mix.
EDIT: newer versions of FFMpeg require the use of | instead of :, so it would be
stereo|c0=FL|c1=FR
The posted solution completely discards all audio channels except for the first 2. For a 16 channel audio source it's unclear how to mix this manually since I don't know what each channel means, but if you just rely on ffmpeg's built in audio channel conversion it should be better than just ignoring all channels but the first two.
$ ffmpeg -i Capture0000.mov -c:v copy -ac 2 stereo_output.mp4
In the above example -ac 2 will tell ffmpeg to downmix the audio to stereo. It'll then choose a reasonable default audio codec for a .mp4 file. You can of course also choose the audio encoding settings like you did in your question.

Resources