FFMPEG : How to swap audio tracks and output the same file - ffmpeg

I have a video file with 4 tracks of audio. I need to swap track 1:2 with track 3:4
Here is what i'm trying to achieve
Input file: 1:2:3:4
Outputfile: 3:4:2:1
So simply swapping the audio tracks, here is what i tried:
ffmpeg -i "test.mxf" -filter_complex "[a:0]amerge=inputs=1[ch1] ;[a:1]amerge=inputs=1[ch2];[a:2]amerge=inputs=1[ch3];[a:3]amerge=inputs=1[ch4]" -map 1:v -map [ch3] -map [ch4] -map [ch1] -map [ch2] -c:v copy -c:a aac -b:a 128k -ar 48000 -ac 2 "out.mxf"
Extracting them as separate channels and then mapping them back into the output.
I'm getting error: Invalid input file index: 1
Heres the output log from ffmpeg
ffmpeg -i "test.mxf" -filter_complex "[a:0]amerge=inputs=1[ch1] ;[a:1]amerge=inputs=1[ch2];[a:2]amerge=inputs=1[ch3];[a:3]amerge=inputs=1[ch4]" -map 1:v -map [ch3] -map [ch4] -map [ch1] -map [ch2] -c:v copy -c:a aac -b:a 128k -ar 48000 -ac 2 "out.mxf"
ffmpeg version 4.3.1-2020-10-01-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Input #0, mxf, from 'test.mxf':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : 50a83ad4-88be-11ec-9d91-d0817add6884
generation_uid : 50a83ad5-88be-11ec-be21-d0817add6884
company_name : Adobe Inc.
product_name : Premiere Pro
product_version : 22.1.2
application_platform: Mac OS X
product_uid : 0c3919fe-46e8-11e5-a151-feff819cdc9f
modification_date: 2022-02-08T09:05:52.000000Z
material_package_umid: 0x060A2B340101010501010D111300000050C9F301189605A21036D0817ADD6884
timecode : 10:00:00:00
Duration: 00:01:41.04, start: 0.000000, bitrate: 55052 kb/s
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, unknown/bt709/bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
file_package_umid: 0x060A2B340101010501010D12131248EF50C9F301189605A2B55DD0817ADD6884
file_package_name: Source Package
track_name : Track 1
Side data:
cpb: bitrate max/min/avg: 50000000/0/0 buffer size: 17825792 vbv_delay: N/A
Stream #0:1: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D12131248EF50C9F301189605A2B55DD0817ADD6884
file_package_name: Source Package
track_name : Track 2
Stream #0:2: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D12131248EF50C9F301189605A2B55DD0817ADD6884
file_package_name: Source Package
track_name : Track 3
Stream #0:3: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D12131248EF50C9F301189605A2B55DD0817ADD6884
file_package_name: Source Package
track_name : Track 4
Stream #0:4: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D12131248EF50C9F301189605A2B55DD0817ADD6884
file_package_name: Source Package
track_name : Track 5
Invalid input file index: 1.

Figured it out, i was using the wrong index for the video, also added the audio codec in the below solution.
ffmpeg -i "test.mxf" -filter_complex "[a:0]amerge=inputs=1[ch1] ;[a:1]amerge=inputs=1[ch2];[a:2]amerge=inputs=1[ch3];[a:3]amerge=inputs=1[ch4]" -map 0:v -map [ch3] -map [ch4] -map [ch1] -map [ch2] -c:v copy -c:a pcm_s24le "out.mxf"
This works for me, if anybody has a better solution kindly share

Related

ffmpeg command to copy video config from ffprobe

What's the command to convert an MP4 to the output format similar to a video with this ffprobe:
ffprobe version N-82151-g1e660fe Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 35.100 / 55. 35.100
libavcodec 57. 65.100 / 57. 65.100
libavformat 57. 57.100 / 57. 57.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 66.100 / 6. 66.100
libswscale 4. 3.100 / 4. 3.100
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, avi, from '.\sample.mp4.hd.mojo':
Metadata:
encoder : Lavf57.57.100
Duration: 00:37:28.85, start: 0.000000, bitrate: 10461 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 960x540 [SAR 1:1 DAR 16:9], 9745 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, 2 channels, s16, 705 kb/s
I've tried
ffmpeg -i "input.mp4" -c:v mjpeg -c:a pcm_s16le -an output.mp4
The output however does not play with the custom player.
Update:
I found a file which seemed to contain some config:
[high]
label=High quality
labelHelp=Converts to high quality
outSuffix=hd
codecParam=-vcodec mjpeg -vf scale=min'(960,iw)':-1 -acodec pcm_s16le -ar 22050 -ac 2 -r 20 -q:v 2
[medium]
label=Medium quality
labelHelp=Converts to medium quality
outSuffix=mid
codecParam=-vcodec mjpeg -vf scale=min'(960,iw)':-1 -acodec pcm_s16le -ar 22050 -ac 2 -r 20 -q:v 5
[low]
label=Low quality
labelHelp=Converts to low quality
outSuffix=low
codecParam=-vcodec mjpeg -vf scale=min'(960,iw)':-1 -acodec pcm_s16le -ar 22050 -ac 2 -r 20 -q:v 8
[main]
label=Convert to NComputing MOJO
labelHelp=Transcodes original file format to the NComputing MOJO format
outSuffix=
codecParam=
Finally I made it to work.
So to make a MOJO video file for NComputing devices here's the ffmpeg command:
ffmpeg -i "input.mp4" -vcodec mjpeg -vf scale=min'(960,iw)':-1 -acodec pcm_s16le -ar 22050 -ac 2 -r 20 -q:v 8 -f avi output.mojo
For low quality video. For other video quality just refer to the mojo.col file.

How can I concatenate 2 videos with audio using ffmpeg? [duplicate]

This question already has an answer here:
How to concatenate videos in ffmpeg with different attributes?
(1 answer)
Closed 2 years ago.
I tried this command:
ffmpeg -f concat -i mylist.txt -c copy output.mp4
But output.mp4 has no audio.
mylist.txt contains:
file '1.mp4'
file '2.mp4'
Information about 1.mp4 and 2.mp4:
C:\Users\Admin\OneDrive\Desktop\New folder>ffmpeg -n -i 1.mp4 -i 2.mp4
ffmpeg version git-2020-05-23-26b4509 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 48.100 / 56. 48.100
libavcodec 58. 87.101 / 58. 87.101
libavformat 58. 43.100 / 58. 43.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 83.100 / 7. 83.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-05-31T08:12:56.000000Z
Duration: 00:00:05.93, start: 0.000000, bitrate: 186 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 184 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-05-31T08:21:56.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-06-01T03:32:58.000000Z
Duration: 00:00:12.23, start: 0.000000, bitrate: 1909 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1708 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-06-01T04:17:17.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 196 kb/s (default)
Metadata:
creation_time : 2020-06-01T04:17:17.000000Z
handler_name : SoundHandler
At least one output file must be specified
For concatenation to work:
According to the concat demuxer documentation:
Each input must have the same number of video and audio streams.
Each video and audio stream must have the same attributes.
Each input must have the same video and audio format.
What is wrong with your inputs
1.mp4 has no audio. 2.mp4 has audio.
1.mp4 needs audio to be able to concatenate to 2.mp4.
Solution
Add silent audio to 1.mp4 using anullsrc filter:
ffmpeg -i input.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -map 0:v -map 1:a -c:v copy -c:a aac -shortest 1b.mp4
Then update mylist.txt to:
file '1b.mp4'
file '2.mp4'
Finally run your ffmpeg command to concatenate:
ffmpeg -f concat -i mylist.txt -c copy -movflags +faststart output.mp4

FFMPEG stream from sdp to youtube/facebook live(RTMP)

Similar to this question, I'm trying to stream to Youtube/Facebook live (rtmp) via Ffmpeg.
The server on which ffmpeg is installed receives a rtp stream (source of the stream uses Vp8 and opus as the codecs), i then use the sdp given below as input for the ffmpeg command
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=FFMPEG Test
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 56.15.102
m=audio 10004 RTP/AVP 111
a=rtpmap:111 OPUS/48000/2
m=video 10006 RTP/AVP 100
a=rtpmap:100 VP8/90000
a=fmtp:100 packetization-mode=1
Where 10004 and 10006 are the audio and video port of the rtp input stream.
I'm using the following FFMPEG command to stream to youtube/facebook live
ffmpeg -protocol_whitelist file,crypto,udp,rtp -i input.sdp -c:a aac -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 426x240 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv "rtmp_url"
Log:
ffmpeg version 4.2.2-1build1~18.04.sav0 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --extra-version='1build1~18.04.sav0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
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
[sdp # 0x56083912d340] Could not find codec parameters for stream 1 (Video: vp8, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, sdp, from 'input.sdp':
Metadata:
title : FFMPEG Test
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Stream #0:1: Video: vp8, yuv420p, 90k tbr, 90k tbn, 90k tbc
Codec AVOption profile () specified for output file #0 (youtube_rtmp_url) 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.
Codec AVOption g (set the group of picture (GOP) size) specified for output file #0 (youtube_rtmp_url) 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.
Codec AVOption preset (Configuration preset) specified for output file #0 (youtube_rtmp_url) 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.
Stream mapping:
Stream #0:0 -> #0:0 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, flv, to 'youtube_rtmp_url':
Metadata:
title : FFMPEG Test
encoder : Lavf58.29.100
Stream #0:0: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54.100 aac
av_interleaved_write_frame(): Broken pipe 134.5kbits/s speed=2.35x
[flv # 0x5608391a7040] Failed to update header with correct duration.
[flv # 0x5608391a7040] Failed to update header with correct filesize.
Error writing trailer of youtube_rtmp_url: Broken pipe
size= 162kB time=00:00:09.86 bitrate= 134.2kbits/s speed=2.32x
video:0kB audio:155kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.493091%
[aac # 0x5608391a7ac0] Qavg: 247.499
Conversion failed!
I have verified that ffmpeg can read the stream, i used a different ffmpeg command to record the stream and that works well. Could someone please point out whats wrong or link to some documentation that might help?

FFmpeg audio stream extraction on non-interleaved AVI - slow compared to AviSynth

I want to extract the audio stream of an avi file as a wav file, it works but it is really slow (~4-5fps) although I just want to copy the stream.
Here is the type of stream I want to extract (ffprobe info):
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Going through AviSynth does it about 100 times faster, but I would prefer a pure FFmpeg solution. Why such a speed difference? It looks like FFmpeg is reading and processing through the whole file whereas AviSynth can just extract the data without reading it.
Example:
ffmpeg -i file.avi -vn -ac 2 -c:a copy audio.wav
or
ffmpeg -i file.avi -map 0:a -ac 2 -c:a copy audio.wav
both work fine but take time.
Using an AviSynth script as input:
ffmpeg -i script.avs -map 0:a -ac 2 -c:a copy audio.wav
with script.avs containing just:
AviSource("file.avi")
does the same but almost instantaneously!
Any idea why AviSynth is so much faster and if there is a way to get the same speed in FFmpeg?
Edit: adding logs
Using FFmpeg directly:
E:\>ffmpeg -i "file.avi" -map 0:a -c:a copy -y -benchmark "output.wav"
ffmpeg version N-92936-ged3b64402e Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181201
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 43.100 / 58. 43.100
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 47.100 / 7. 47.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[avi # 0000018d3c38a680] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'file.avi':
Duration: 00:18:37.49, start: 0.000000, bitrate: 534682 kb/s
Stream #0:0: Video: rawvideo, bgr24, 1280x720, 533183 kb/s, 24.11 fps, 24.11 tbr, 24.10 tbn, 24.10 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Output #0, wav, to 'output.wav':
Metadata:
ISFT : Lavf58.25.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 192445kB time=00:18:37.12 bitrate=1411.2kbits/s speed=4.77x
video:0kB audio:192445kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000040%
bench: utime=1.188s stime=50.766s rtime=234.254s
bench: maxrss=17468kB
Using AviSynth:
E:\>ffmpeg -i "soundout.avs" -map 0:a -c:a copy -y -benchmark "output.wav"
ffmpeg version N-92936-ged3b64402e Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181201
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 43.100 / 58. 43.100
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 47.100 / 7. 47.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avisynth, from 'soundout.avs':
Duration: 00:18:37.49, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 24.11 fps, 24.11 tbr, 24.10 tbn, 24.10 tbc
Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Output #0, wav, to 'output.wav':
Metadata:
ISFT : Lavf58.25.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 192445kB time=00:18:37.11 bitrate=1411.2kbits/s speed= 155x
video:0kB audio:192445kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000040%
bench: utime=0.234s stime=1.047s rtime=7.236s
bench: maxrss=23792kB
Edit: tests after "reencoding" AVI file:
Onto something...
Say my original file is f.avi. Here is ffprobe's results:
[avi # 0x55a9c4b1e740] non-interleaved AVI
Input #0, avi, from 'f.avi':
Duration: 00:00:38.18, start: 0.000000, bitrate: 1104582 kb/s
Stream #0:0: Video: rawvideo, bgr24, 1632x1200, 1104265 kb/s, 23.47 fps, 23.47 tbr, 23.47 tbn, 23.47 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Extracting audio takes a long time.
Now if I "reencode" the file in another AVI:
ffmpeg -i f.avi -c copy f2.avi
I can extract the audio from f2.avi in milliseconds!
FFprobe on f2.avi:
Input #0, avi, from 'f2.avi':
Metadata:
encoder : Lavf57.56.101
Duration: 00:00:38.18, start: 0.000000, bitrate: 1104456 kb/s
Stream #0:0: Video: rawvideo, bgr24, 1632x1200, 1104265 kb/s, 23.47 fps, 23.47 tbr, 23.47 tbn, 23.47 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
It's the same apart from the Metadata, which shouldn't make a difference, but with this comparison I see the problem must have to do with the fact that the original is non-interleaved!
I would assume it was easier to read and extract the audio from a non-interleaved file but maybe this is not conforming to AVI standards, hence the extra work needed?
You answered your question yourself: It looks like you are input bandwidth bottlenecked and ffmpeg reads the raw video just to throw it away, while avisynth (which will probably use the AVI Splitter from DirectShow) only reads the audio data from disk. I don't see a way to make ffmpeg do the same.

ffmpeg overlay image and lower transparency

I have this ffmpeg command that I use to create a video from a photo and a animated GIF border overlay, and a audio track.
ffmpeg -framerate 15 -loop 1 -i photo.jpg -ignore_loop 0 -i overlay.gif -filter_complex "scale=(iw*sar)*max(600/(iw*sar)\,750/ih):ih*max(600/(iw*sar)\,750/ih), crop=600:750, overlay" -i audio.wav -c:v libx264 -c:a aac -b:a 192k -shortest output.mp4
What I want is to lower the opacity of the overlay image.
I have checked a lot of threads, but I can't figure out how to combine something like this with my existing filters.
-filter_complex "blend=all_mode='overlay':all_opacity=0.7"
Any ideas?
Here's the full ffmpeg output of one of my tests:
ffmpeg -framerate 15 -loop 1 -i photo.jpg -ignore_loop 0 -i overlay.gif -filter_complex "scale=(iw*sar)*max(600/(iw*sar)\,750/ih):ih*max(600/(iw*sar)\,750/ih), crop=600:750, blend=all_mode='overlay':all_opacity=0.7" -i audio.wav -c:v libx264 -c:a aac -b:a 192k -shortest output.mp4
ffmpeg version N-83507-g8fa18e0 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enabl
e-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug -
-enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspe
ex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable
-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 47.100 / 55. 47.100
libavcodec 57. 80.100 / 57. 80.100
libavformat 57. 66.102 / 57. 66.102
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 73.100 / 6. 73.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, image2, from 'photo.jpg':
Duration: 00:00:00.07, start: 0.000000, bitrate: 15374 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 400x600 [SAR 72:72 DAR 2:3], 15 fps, 15 tbr, 15 tbn, 15 tbc
Input #1, gif, from 'overlay.gif':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: gif, bgra, 600x750, 5.42 fps, 5 tbr, 100 tbn, 100 tbc
Guessed Channel Layout for Input Stream #2.0 : mono
Input #2, wav, from 'audio.wav':
Duration: 00:00:23.00, bitrate: 705 kb/s
Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
[swscaler # 00000000023300a0] deprecated pixel format used, make sure you did set range correctly
[swscaler # 000000000234d1e0] deprecated pixel format used, make sure you did set range correctly
[Parsed_blend_2 # 00000000022fd0c0] First input link top parameters (size 600x750, SAR 1:1) do not match the corresponding second input link bottom parameters (600x750, SAR 0:1)
[Parsed_blend_2 # 00000000022fd0c0] Failed to configure output pad on Parsed_blend_2
Error configuring complex filters.
Invalid argument
Use the colorchannelmixer filter.
ffmpeg -framerate 15 -loop 1 -i photo.jpg
-ignore_loop 0 -i overlay.gif
-i audio.wav
-filter_complex "[0]scale=(iw*sar)*max(600/(iw*sar)\,750/ih):ih*max(600/(iw*sar)\,750/ih),
crop=600:750[b];
[1]format=argb,colorchannelmixer=aa=0.5[ol];[b][ol]overlay"
-c:v libx264 -c:a aac -b:a 192k -shortest output.mp4
The 0.5 sets it to 50% transparent.

Resources