FFMPEG - Batch convert multiple audio formats in nested folders to AIFF & keep filename and meta data - bash

I'm trying to convert all of my music library in various folders (mp3 / wav / m4a) to aif. I also need to:
Convert files in all nested subdirectories
Convert to 44khz 16 bit aif
Copy meta data to new file
Copy embedded artwork
Put all new files in the same output directory
I have spent some time going through answers on here but can only convert to aif so far;
find ./ -type f \( -name "*.wav" -o -name "*.aac" -o -name "*.m4a" -o -name "*.mp3" \) -exec ffmpeg -i '{}' '{}.aif' \;
Can someone help me update the script to do all of the things I need?
Any help mucho appreciated :)
(I've been through multiple posts explaining how to do each of these things but I can't get this to work on batch processing!)

I am unable to get ffmpeg to add artwork to aif file. Also, only Title and Comment fields are mapped/preserved (on my version). All others lost or not mapped.
Issue is with the aif format as target output.
Feature/Bug reported.
Confirmed no problem adding artwork, mp3 -> mp3, and preserving all tags (except comment !!!).
My command:
ffmpeg \
-i "${fullpathfile}" \
-i "${startDIR}/${fileroot}.png" \
-map 0:a \
-map 1:0 \
-c:0 copy \
-c:1 copy \
-id3v2_version 4 \
"${libraryDIR}/${fileroot}.${sufOut}"
My environment:
Ubuntu MATE 20.04
Linux 5.4.0-135-generic
#152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022
ffmpeg version 4.2.7-0ubuntu0.1
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
My test script:
#!/bin/bash
doTransform()
{
cd "${libraryDIR}" ;
skip_start=0
time_end=unknown
while read line
do
#sufIn=mp3
sufIn=`echo "${line}" | awk '{ n=split( $0, val, "." ) ; print val[n] ; }' `
fileroot=`basename "${line}" ".${sufIn}" `
rm -f "${libraryDIR}/${fileroot}.${sufOut}"
ffprobe -hide_banner "${line}"
echo -e "\n sufIn = ${sufIn} ..."
echo " Hit return to continue ..." >&2
read k <&2
case "${sufOut}" in
"${sufIn}" )
#codec="-codec copy" ;;
codec="-c:0 copy -c:1 copy" ;;
* )
case "${SufIn}" in
mp3 )
#codec="-codec copy" ;;
codec="-c:0 copy -c:1 copy" ;;
* )
# Issues with AIC/AIF format and codec specificaiton
codec="-c:0 copy -c:1 copy" ;;
esac
::
esac
#-to ${time_end} \
#-b:a 192k \
#-i "${fullpathfile}" \
ffmpeg \
-i "${line}" \
-i "${startDIR}/${fileroot}.png" \
-map 0:a \
-map 1:0 \
${codec} \
-ss ${skip_start} \
-id3v2_version 4 \
"${libraryDIR}/${fileroot}.${sufOut}"
### MP3 -> MP3 : metadata is preseved (except comment) for
### MP3 -> MP3 : only Title and Comment preserved, all others lost
### Try these again after upgrade to 22.04
# -metadata title="Album cover" \
# -metadata comment="Cover (front)" \
# -metadata:s:a:0 title="Album cover" \
# -metadata:s:a:0 comment="Cover (front)" \
done
}
startDIR=`pwd`
sourceDIR=${startDIR}/FFMPEG_Test
libraryDIR=${startDIR}/Output
sufOut=mp3
sufOut=aif
#-ipath "${libraryDIR}" \
#\( -ipath "${libraryDIR}" \) \
find "${sourceDIR}" \
-type f \( -name "*.wav" -o -name "*.aac" -o -name "*.m4a" -o -name "*.mp3" \) \
-print |
grep -v '/Output' |
doTransform

Related

Why am I getting FFMPEG "cannot set sample format 0x10000 2 (Invalid argument)" error? [duplicate]

I am trying to capture a pcm stream from a Roland USB device with ffmpeg and wrap it with wav. The command line I am using is the following:
ffmpeg -f alsa -acodec pcm_s32le -ac 2 -ar 48000 -i hw:2,0 out.wav
Which comply with the settings of the hardware. I can also capture the stream with Audacity. The problem is that FFMPEG throws "cannot set sample format error". Any idea of what may be happening and how I can fix this?
Thanks in advance.
FFMPEG OUTPUT
user#user:~$ ffmpeg -f alsa -acodec pcm_s32le -ac 2 -ar 48000 -i hw:2,0 out.wav
ffmpeg version N-85548-g3390a2b Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libvorbis --enable-libopus --enable-ffplay
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 92.100 / 57. 92.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
[alsa # 0x34b6780] cannot set sample format 0x10008 10 (Invalid argument)
hw:2,0: Input/output error
ARECORD OUTPUT:
user#user:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: PCH [HDA Intel PCH], device 0: ALC3236 Analog [ALC3236 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: DUOCAPTURE [DUO-CAPTURE], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
After Deimus help I checked the setting for my card in arecord and used the correct line for FFMPEG (Notice that I have changed the capture frequency on the hardware).
ARECORD OUTPUT
user#user:~$ arecord --dump-hw-params -D hw:2,0
Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:2,0":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S24_3LE
SUBFORMAT: STD
SAMPLE_BITS: 24
FRAME_BITS: 48
CHANNELS: 2
RATE: 44100
PERIOD_TIME: (1020 1981429)
PERIOD_SIZE: [45 87381]
PERIOD_BYTES: [270 524286]
PERIODS: [2 1024]
BUFFER_TIME: (2040 3962858)
BUFFER_SIZE: [90 174762]
BUFFER_BYTES: [540 1048572]
TICK_TIME: ALL
--------------------
arecord: set_params:1233: Sample format non available
Available formats:
- S24_3LE
Correct command line
ffmpeg -f alsa -acodec pcm_s24le -ac 2 -ar 44100 -i hw:2,0 out.wav
Use the --dump-hw-params option of arecord tool to check the supported sample formats.
Man page for arecord
Then you can use the -sample_fmt option of ffmpeg to specficy the format eg. s32
Audio options for ffmpeg are here
Refer to output of arecord --dump-hw-params -D hw:2,0 where hw:2,0 is your target device.
arecord output will show available sample formats under FORMAT and Available formats. Other useful info is also shown such as CHANNELS and RATE. Example:
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S32_LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 64]
CHANNELS: 2
RATE: [44100 192000]
PERIOD_TIME: (83 11888617)
PERIOD_SIZE: [16 524288]
PERIOD_BYTES: [128 4194304]
PERIODS: [2 32]
BUFFER_TIME: (166 23777234)
BUFFER_SIZE: [32 1048576]
BUFFER_BYTES: [128 4194304]
TICK_TIME: ALL
--------------------
Available formats:
- S16_LE
- S32_LE
In your ffmpeg command choose the appropriate decoder to match the sample format. You can also choose the channels and sample rate:
ffmpeg -f alsa -c:a pcm_s32le -channels 2 -sample_rate 44100 -i hw:2,0 output.wav
Examples of decoders to use:
S16LE = -c:a pcm_s16le
S24LE = -c:a pcm_s24le
S32LE = -c:a pcm_s32le
Also see ffmpeg -decoders and FFmpeg Documentation: ALSA input.

How to process .ts files used by flowplayer?

Flowplay seems to be used by jove.com
https://www.jove.com/video/59612/3d-kinematic-gait-analysis-for-preclinical-studies-in-rodents
Take the above URL as an example, it will use .ts files like this (via Google Chrome devtools)
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_3.ts
But I am not sure how to make the .ts file viewable locally.
https://askubuntu.com/questions/3645/how-do-i-convert-ts-files-into-something-useful
I tried something like this. But I always get errors.
$ ffmpeg -i 50191_1.ts -c:v libx264 -crf 0 -c:a copy output.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
50191_1.ts: Invalid data found when processing input
Does anybody know how to convert the .ts files?
EDIT: I got something like this.
$ cat 59612_.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:17
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="https://cloudflare2.jove.com/CDNSource/hls/59612/59612.key"
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_0.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_1.ts
#EXTINF:6.606600,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_2.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_3.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_4.ts
#EXTINF:10.877533,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_5.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_6.ts
#EXTINF:7.907900,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_7.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_8.ts
#EXTINF:10.910900,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_9.ts
#EXTINF:9.676333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_10.ts
#EXTINF:8.375033,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_11.ts
#EXTINF:12.645967,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_12.ts
#EXTINF:13.146467,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_13.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_14.ts
#EXTINF:6.840167,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_15.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_16.ts
#EXTINF:10.877533,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_17.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_18.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_19.ts
#EXTINF:6.706700,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_20.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_21.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_22.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_23.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_24.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_25.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_26.ts
#EXTINF:16.649967,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_27.ts
#EXTINF:8.308300,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_28.ts
#EXTINF:8.308300,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_29.ts
#EXTINF:5.672333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_30.ts
#EXTINF:10.677333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_31.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_32.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_33.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_34.ts
#EXTINF:7.507500,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_35.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_36.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_37.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_38.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_39.ts
#EXTINF:7.273933,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_40.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_41.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_42.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_43.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_44.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_45.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_46.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_47.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_48.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_49.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_50.ts
#EXTINF:16.683333,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_51.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_52.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_53.ts
#EXTINF:13.079733,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_54.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_55.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_56.ts
#EXTINF:13.113100,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_57.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_58.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_59.ts
#EXTINF:8.341667,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_60.ts
#EXTINF:6.573233,
https://cloudflare2.jove.com/CDNSource/hls/59612/59612_61.ts
#EXT-X-ENDLIST
#EXT-X-KEY:METHOD=AES-128,URI="https://cloudflare2.jove.com/CDNSource/hls/59612/59612.key"
This HLS videostream is encrypted. AES-128 is not DRM, so with the key present it can be decrypted.
HLS videostream
The easy way is to just open the HLS videostream with FFmpeg (which it automatically decrypts) and cut the desired segment:
ffmpeg -ss 32 -i https://cloudflare2.jove.com/CDNSource/hls/59612/59612_.m3u8 -t 17 -c copy output.mp4
-ss 32: skip to 32s.
-t 17: set duration to 17s.
-c copy: perform a stream-copy (no loss in quality).
Individual segment
This requires you to decrypt the segment yourself.
When you download the decryption key 59612.key, you'll see a lot of gibberish: Aæª~ý÷øŽ©ýÛO®ø.
You'll have to convert this to a hex binary representation. This can be done with hexdump...
curl -s https://cloudflare2.jove.com/CDNSource/hls/59612/59612.key | hexdump -e '16/1 "%02x"
41e61c18aa7efdf7f88ea9fddb4faef8
...or with one of my favorite tools, xidel:
xidel -s https://cloudflare2.jove.com/CDNSource/hls/59612/59612.key -e 'x:string-to-hexBinary($raw)'
41E61C18AA7EFDF7F88EA9FDDB4FAEF8
Next you can decrypt the 60th segment (for instance) with ffmpeg:
ffmpeg \
-key 41E61C18AA7EFDF7F88EA9FDDB4FAEF8 \
-iv 0000000000000000000000000000003C \
-i crypto:https://cloudflare2.jove.com/CDNSource/hls/59612/59612_60.ts \
-c copy \
output.mp4
-iv 0000000000000000000000000000003C: 60 (decimal) = 3C (hexa-decimal).
...or with openssl:
openssl \
aes-128-cbc \
-in <(curl -s https://cloudflare2.jove.com/CDNSource/hls/59612/59612_60.ts) \
-out 59612_60-decrypted.ts \
-d -iv 60 -K 41E61C18AA7EFDF7F88EA9FDDB4FAEF8

Unable to convert MP3 file to PCM with ffmpeg

I have compiled ffmpeg to convert mp3 file with this config, as the ffmpeg output size is matter to me, I have disabled everything in ffmpeg:
#!/bin/bash
. abi_settings.sh $1 $2 $3
pushd ffmpeg
case $1 in
armeabi-v7a | armeabi-v7a-neon)
CPU='cortex-a8'
;;
x86)
CPU='i686'
;;
esac
make clean
./configure \
--target-os="$TARGET_OS" \
--cross-prefix="$CROSS_PREFIX" \
--arch="$NDK_ABI" \
--cpu="$CPU" \
--enable-runtime-cpudetect \
--sysroot="$NDK_SYSROOT" \
--disable-all \
--disable-network \
--enable-avcodec \
--enable-avformat \
--enable-swresample \
--enable-avfilter \
--enable-parser=mpegaudio \
--enable-demuxer=mp3,wav \
--enable-muxer=mp3,wav \
--enable-decoder=pcm*,mp3*\
--enable-encoder=pcm*,libmp3lame \
--enable-filter=aresample \
--enable-protocol=file \
--enable-ffmpeg \
--enable-libmp3lame \
--enable-pthreads \
--disable-debug \
--disable-ffserver \
--enable-version3 \
--enable-hardcoded-tables \
--disable-ffplay \
--disable-ffprobe \
--enable-gpl \
--enable-yasm \
--disable-doc \
--disable-shared \
--enable-static \
--enable-small \
--enable-nonfree \
--pkg-config="${2}/ffmpeg-pkg-config" \
--prefix="${2}/build/${1}" \
--extra-cflags="-I${TOOLCHAIN_PREFIX}/include $CFLAGS" \
--extra-ldflags="-L${TOOLCHAIN_PREFIX}/lib $LDFLAGS" \
--extra-libs="-lm" \
--extra-cxxflags="$CXX_FLAGS" || exit 1
make -j${NUMBER_OF_CORES} && make install || exit 1
popd
but when I want to convert mp3 to pcm, I get this error:
configuration: --target-os=linux --cross-prefix=/root/ffmpeg2/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/ffmpeg2/ffmpeg-android/toolchain-android/sysroot --disable-all --disable-network --enable-avcodec --enable-avformat --enable-swresample --enable-avfilter --enable-parser=mpegaudio --enable-demuxer='mp3,wav' --enable-muxer='mp3,wav' --enable-decoder='pcm*,mp3*--enable-encoder=pcm*,libmp3lame' --enable-filter=aresample --enable-protocol=file --enable-ffmpeg --enable-libmp3lame --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --enable-small --enable-nonfree --pkg-config=/root/ffmpeg2/ffmpeg-android/ffmpeg-pkg-config --prefix=/root/ffmpeg2/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/ffmpeg2/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/ffmpeg2/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs=-lm --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavfilter 6. 31.100 / 6. 31.100
libswresample 2. 0.101 / 2. 0.101
[mp3 # 0xb72041d0] Skipping 0 bytes of junk at 0.
[mp3 # 0xb72041d0] Estimating duration from bitrate, this may be inaccurate
[mp3 # 0xb72041d0] Could not find codec parameters for stream 0 (Audio: mp3, 44100 Hz, 1 channels, 256 kb/s): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
/storage/emulated/0/Android/data/com.edspace.alefba/files/alefba/page/voices/109/cource_1.mp3: could not find codec parameters
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, mp3, from '/storage/emulated/0/Android/data/com.edspace.alefba/files/alefba/page/voices/109/cource_1.mp3':
Duration: 00:00:08.67, start: 0.000000, bitrate: 256 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, 1 channels, 256 kb/s
[NULL # 0xb7242370] Requested output format 's16le' is not a suitable output format
/storage/emulated/0/Android/data/com.edspace.alefba/files/alefba/page/voices/109/cource_1.pcm: Invalid
what should I change in configure parameters to make it work?
EDIT:
it seem that the problem is with output format:
Requested output format 's16le' is not a suitable output format , but I do not know how can I fix that
Change to
--enable-muxer=mp3,pcm_s16le,wav \

FFmpeg - Unrecognized option 'map [outv]'

I am merging some video files with FFmpeg and having an issue with my custom build. I'm using the following Java code for wrapping the ffmpeg command:
List<String> cmds = new ArrayList<>();
cmds.add("ffmpeg");
cmds.add("-i");
cmds.add("input1.mp4");
...
cmds.add("-map [outv]");
cmds.add("-map [a]");
...
cmds.add("output.mp4");
ProcessBuilder pb = new ProcessBuilder(cmds);
pb.directory(fileExec);
Process process = pb.start();
int exitVal = process.waitFor();
The command I am using is (abbreviated filter_complex):
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex “... [bla1][bla2]overlay=main_w-overlay_w:main_h-overlay_h:format=yuv420[outv]” -c:v libx264 -preset ultrafast -b:v 45000k -aspect 1.7777778 -map [outv] -map [a] -c:a libfdk_aac -ac 2 -b:a 128k -t 24 output.mp4
I get the error:
Unrecognized option 'map [outv]'.
Am I missing a configuration option to include map? Where would I find this information of what options are required for the map command? Or is my ffmpeg just too old like lots of the other similar questions? 2015-02-25 is pretty recent!
Full command:
ffmpeg -y -i VID_20150609_154943_5583.mp4 -i VID_20150609_154943_24253.mp4 -i VID_20150609_154943_16083.mp4 -i stamp.png -f lavfi -i color=black -filter_complex " [0:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=out:st=7.99:d=2:alpha=1,setpts=expr=PTS-STARTPTS[va0] ; [0:a]afade=t=out:st=7.99:d=2[a0] ; [1:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=in:st=0:d=2:alpha=1,fade=t=out:st=15.98:d=2:alpha=1,setpts=expr=PTS-STARTPTS+7.99/TB[va1] ; [1:a]afade=t=in:st=0:d=2,afade=t=out:st=15.98:d=2[a1] ; aevalsrc=0:d=7.99[s1] ; [s1][a1]concat=n=2:v=0:a=1[ac1] ; [2:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=in:st=0:d=2:alpha=1,setpts=expr=PTS-STARTPTS+15.98/TB[va2] ; [2:a]afade=t=in:st=0:d=2[a2] ; aevalsrc=0:d=15.98[s2] ; [s2][a2]concat=n=2:v=0:a=1[ac2] ; [4:v]scale=1280x720,trim=duration=23.97[over0] ; [a0][ac1][ac2]amix=inputs=3[a]; [over0][va0]overlay[over1];[over1][va1]overlay[over2];[over2][va2]overlay[over3] ; [over3][3:v]overlay=main_w-overlay_w:main_h-overlay_h:format=yuv420[outv] " -c:v libx264 -preset ultrafast -b:v 45000k -aspect 1.7777778 -map [outv] -map [a] -c:a libfdk_aac -ac 2 -b:a 128k -t 23.97 VID_20150609_155417.mp4
ffmpeg version git-2015-02-25-b0d3322 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --enable-pic --disable-shared --enable-static --cross-prefix=/home/jon/Development/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=/home/jon/Development/android-ndk-r10d/platforms/android-9/arch-arm/ --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie' --extra-ldflags='-L../x264 -fPIE -pie' --enable-version3 --enable-gpl --disable-doc --enable-yasm --disable-decoders --enable-decoder='mpeg4,aac,h264,mpegvideo,mpeg1video,mpeg2video,png,mjpeg' --disable-encoders --enable-encoder='mpeg4,aac,h264,libx264,mpeg1video,mpeg2video,png' --disable-parsers --enable-parser='aac,mpeg4video,ac3,h261,h264,vc1,mpegvideo' --disable-demuxers --enable-demuxer='aac,h264,mpegvideo,m4v,mov,vc1,mp4,concat,image2' --disable-muxers --enable-muxer='h264,mpeg1video,mpeg2video,m4v,mov,vc1,md5,mp4' --enable-protocols --enable-indev='v4l,v4l2' --disable-filters --enable-filter='aresample,scale,movie,overlay' --enable-avfilter --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-symver --enable-network --enable-libx264 --enable-zlib
libavutil 54. 19.100 / 54. 19.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 23.105 / 56. 23.105
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.101 / 5. 11.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Unrecognized option 'map [outv]'.
This question is not really a problem with ffmpeg, but a miss usage of the Java function ProcessBuilder. When providing ProcessBuilder with a list of string arguments, I was giving ['ffmpeg, ..., '-map [outv]', ...]. This instead should be ['ffmpeg, ..., '-map', '[outv]', ...] because ProcessBuilder treats each list item as an argument. Hence ffmpeg not recognising the argument 'map [outv]'.
Thanks to #slhck for helping me figure this out.

Mixing a FLV audio stream with a WAV background track, and converting to MP3 with SoX and FFmpeg

I'm building a Flash-based recording application for a contracted web site. It streams the recorded voice (via SWF) to a Red5 server, then uses a combination of FFmpeg and SoX to compile the vocal audio with a lower-in-volume background music track. This all has to happen on-demand, that is, when a user "saves" his or her vocal recording.
Here is an example command I will be running. Names have been changed to protect the innocent. The filenames describe their role in the final file:
sox --combine mix -p --no-show-progress --norm "|ffmpeg -i /usr/share/red5/webapps/audiorecorder/stream/SPOKEN_VOICE.flv -t wav pipe:1" /var/www/ufiles/music/BACKGROUND_MUSIC.wav - | ffmpeg -i pipe:1 /var/www/ufiles/recordings/COMPILED_AUDIO_RECORDING.mp3
When I run this command in the shell, this is what happens:
$ sox --combine mix -p --no-show-progress --norm "|ffmpeg -i audioStream_1321399534128_21.flv -ar 44100 -ac 2 -t wav pipe:1" wrong.wav - | ffmpeg -i pipe:1 ~/www/trauma101.com/compiled.mp3
ffmpeg version N-34884-g7575980, Copyright (c) 2000-2011 the FFmpeg developers
built on Nov 15 2011 14:06:49 with gcc 4.4.5
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libx264 --enable-x11grab --enable-libspeex
libavutil 51. 25. 0 / 51. 25. 0
libavcodec 53. 34. 0 / 53. 34. 0
libavformat 53. 20. 0 / 53. 20. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 48. 1 / 2. 48. 1
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
ffmpeg version N-34884-g7575980, Copyright (c) 2000-2011 the FFmpeg developers
built on Nov 15 2011 14:06:49 with gcc 4.4.5
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libx264 --enable-x11grab --enable-libspeex
libavutil 51. 25. 0 / 51. 25. 0
libavcodec 53. 34. 0 / 53. 34. 0
libavformat 53. 20. 0 / 53. 20. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 48. 1 / 2. 48. 1
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
[libspeex # 0x1e36b20] Missing Speex header, assuming defaults.
Input #0, flv, from 'audioStream_1321399534128_21.flv':
Metadata:
novideocodec : 0
server : Red5 Server 1.0.0 RC2 Rev: 4295
creationdate : Tue Nov 15 15:25:41 PST 2011
canSeekToEnd : true
Duration: 00:00:06.77, start: 0.000000, bitrate: 43 kb/s
Stream #0:0: Audio: speex, 16000 Hz, 1 channels, s16
Invalid duration specification for t: wav
sox FAIL formats: can't open input pipe `|ffmpeg -i audioStream_1321399534128_21.flv -ar 44100 -ac 2 -t wav pipe:1': premature EOF
I think the issue is stemming from the conversion from FLV to WAV in FFmpeg, and since it's being piped in it causes the whole process to fail. I always get that duration warning, but when FFmpeg outputs to a .wav file and the SoX command is run separately, I can still get a WAV from SoX and convert that to MP3 manually. I'd like to do all this in one line, piping the data between applications.
What do I do?
Problem is here:
sox FAIL formats: can't open input pipe
I assume you want sox to read from a pipe, normalize and convert to wav. In that case the mix argument is redundant. Something like this would do:
sox -p -t wav - gain -n | ...

Resources