Make UDP-RTMP bridge with FFMPEG - audio

I need to make this chain, using computer 2 as a "bridge" between Computer 1 and the streming server.
Computer 1 ----> Computer 2 ----> Streaming server (Wowza).
So I'm trying to set this:
Computer 1 --(via UDP)--> Computer 2 --(Via RTMP)--> Wowza
What I've tried:
1. At Computer 1
Entry:
ffmpeg -i sample.mp4 -c:v copy -c:a copy -f mpegts udp://192.168.0.109:5010
Result: Worked. Computer 1 sends the data correctly.
2. At Computer 2
Entry:
ffmpeg -i upd://192.168.0.109:5010 output.mp4
Result: Worked. Computer 2 gets data correctly. Output.mp4 is generated well.
Entry:
ffmpeg -i sample.mp4 -c:v copy -c:a copy -f flv rtmp://wowzaServerAddress
Result: Worked. Wowza shows online the video from sample.mp4
Entry:
ffmpeg -re -i udp://#:5010 -f flv rtmp://wowzaServerAddress
Result:
stuck at:
ffmpeg version N-77234-g906c0b7 Copyright (c) 2000-2015 the FFmpeg
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --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. 10.100 / 55. 10.100
libavcodec 57. 17.100 / 57. 17.100
libavformat 57. 20.100 / 57. 20.100
libavdevice 57.0.100 / 57. 0.100
libavfilter 6.21.100 / 6. 21.100
libswscale 4.0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
**Entry:**
ffmpeg -i udp://192.168.0.109:5010 -c:v copy -c:a copy -f flv rtmp://wowzaServerAddress
**Result:**
*... repeated a lot ...*
Last message repeated 1 times
[h264 # 000001cef0462200] decode_slice_header error
[h264 # 000001cef0462200] no frame!
*... repeated a lot ...*
Input #0, mpegts, from 'udp://192.168.0.109:5010':
Duration: N/A, start: 128.032333, bitrate: N/A
Program 1
Metadata:
service_name: RARBG.COM - Spotlight.2015.1080p.WEB-DL.DD5.1.H264-RARBG
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(tv, bt709), 1916x1032 [SAR 1:1 DAR 479:258], 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 200 kb/s
[flv # 000001cef132a1c0] Codec for stream 0 does not use global headers but container format requires global headers
[flv # 000001cef132a1c0] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, flv, to '**rtmp://wowzaServerAddress**':
Metadata:
encoder: Lavf57.20.100
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1916x1032 [SAR
1:1 DAR 479:258], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 90k tbc
Stream #0:1(eng): Audio: aac ([10][0][0][0] / 0x000A), 48000 Hz, stereo,
200 kb/s
Stream mapping:
Stream #0:0 - #0:0 (copy)
Stream #0:1 - #0:1 (copy)
Press [q] to stop, [?] for help
[flv # 000001cef132a1c0] Malformed AAC bitstream detected: use the audio
bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[flv # 000001cef132a1c0] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
[flv # 000001cef132a1c0] Failed to update header with correct duration.
[flv # 000001cef132a1c0] Failed to update header with correct filesize.
Error writing trailer of rtmp://**wowzaServerAddress**: Invalid data found when processing inputframe= 1 fps=0.0 q=-1.0 Lsize= 0kB time= 00:00:02.13 bitrate= 1.6kbits/s
video:33kB audio:59kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

Related

FFMPEG: Specifying Output Stream Type When Combing Multiple Filters

I currently have 3 separate ffmpeg commands that do the following:
Overlay a watermark on a video: ffmpeg -i samplegreen.webm -i foregrounds/myimage.png -r 30 -filter_complex "overlay=(W-w)/2:H-h" -af "adelay=700" output.mp4
Overlay the results of 1) onto a beach video: ffmpeg -i backgrounds/beachsunsetmp4.mp4 -i output.mp4 -filter_complex "[1:v]chromakey=0x005d0b:0.1485:0.03[ckout];[0:v][ckout]overlay[o]" -map [o] -map 1:a -shortest somefolder/sample_video.mp4
Merge the audio of the results of 2) with another audio file: ffmpeg -i somefolder/sample_video.mp4 -i backgrounds/beachsunsetmp4.mp3 -filter_complex '[0:a][1:a]amerge=inputs=2[a]' -map 0:v -map '[a]' -c:v copy -ac 2 -shortest anotherfolder/sample_video.mp4
Now, this all works as intended, however, I was looking into attempting to combine them all into a single command, combining all the filters, like so:
ffmpeg -i samplegreen.webm -i foregrounds/myimage.png -r 30 -i backgrounds/beachsunsetmp4.mp4 -i backgrounds/beachsunsetmp4.mp3 -filter_complex \
"[0]overlay=(W-w)/2:H-h[output_1]; \
[output_1]chromakey=0x005d0b:0.1485:0.03[ckout]; \
[2:v][ckout]overlay[output_2]; \
[output_2][3:a] amerge=inputs=2 [output_3]" \
-af "adelay=700" -map [output_3] shortest final.mp4
It fails with the following error (Media type mismatch between the 'Parsed_overlay_2' filter output pad 0 (video) and the 'Parsed_amerge_3' filter input pad 0 (audio)):
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, matroska,webm, from 'samplegreen.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Input #1, png_pipe, from 'foregrounds/myimage.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 350x86, 25 tbr, 25 tbn, 25 tbc
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'backgrounds/beachsunsetmp4.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2021-02-16T18:24:40.000000Z
Duration: 00:00:32.53, start: 0.000000, bitrate: 3032 kb/s
Stream #2:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 3027 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2021-02-16T18:24:40.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
[mp3 # 0x7f86cf809000] Estimating duration from bitrate, this may be inaccurate
Input #3, mp3, from 'backgrounds/beachsunsetmp4.mp3':
Metadata:
date : 2021-02-18 06:49
id3v2_priv.XMP : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 6.0-c003 79.164527, 2020/10/15-17:48:32 ">\x0a <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\x0a <rdf
Duration: 00:00:32.60, start: 0.000000, bitrate: 132 kb/s
Stream #3:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
[Parsed_overlay_2 # 0x7f86cd4039c0] Media type mismatch between the 'Parsed_overlay_2' filter output pad 0 (video) and the 'Parsed_amerge_3' filter input pad 0 (audio)
[AVFilterGraph # 0x7f86cd402a40] Cannot create the link overlay:0 -> amerge:0
Error initializing complex filters.
Invalid argument
As far as I can tell, the issue is that the filter, amerge, wants 2 audio streams. Normally, I could take the input stream argument (which is a video), and make it use the audio by doing something like [0:a][1:a]amerge=inputs=2[results]. However, since my input stream is the output of a preceding filter, that doesn't seem to work (i.e. [output_2:a]). It bombs out with:
[matroska,webm # 0x7fecca000000] Invalid stream specifier: output_2:a.
Last message repeated 1 times
Stream specifier 'output_2:a' in filtergraph description [0]overlay=(W-w)/2:H-h[output_1]; [output_1]chromakey=0x005d0b:0.1485:0.03[ckout]; [2:v][ckout]overlay[output_2]; [output_2:a][3:a] amerge=inputs=2 [output_3] matches no streams.
So all of that said... Is there a way to specify that I'd like to use the audio stream from the output of a preceding filter? Or any other ways to combine all of these filters into a single command?
Thanks.
Any help would be greatly appreciated!
Except for a few filters like concat, a filter will take either only video inputs or only audio.
Here's the combined command.
ffmpeg \
-i samplegreen.webm \
-i foregrounds/myimage.png \
-i backgrounds/beachsunsetmp4.mp4 \
-i backgrounds/beachsunsetmp4.mp3 \
-filter_complex \
"[0][1]overlay=(W-w)/2:H-h,chromakey=0x005d0b:0.1485:0.03[ckout]; \
[2][ckout]overlay=shortest=1[v]; \
[0]adelay=700:all=1[0a]; \
[0a][3]amerge=inputs=2[a]" \
-map '[v]' -map '[a]' \
-shortest -r 30 -ac 2 \
output.mp4

ffmpeg issue after adding background audio

So I have an issue to which I cannot find an answer. I have a video which is 7min 38sec long after concat. When I want to add background audio to this video it cuts off the last 7sec of the original video. I cannot find the reason.
If anyone could help me in any way, it would be amazing because I have been troubleshooting this past 3 days.
My FFmpeg version is ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers.
For concat I use this: FFmpeg -f concat -safe 0 -i txtfile.txt -c copy -ac 2 output.mp4
For adding background audio I use this: ffmpeg -i output.mp4 -i background.mp3 -c:v copy -filter_complex "[0:a]aformat=fltp:44100:stereo,apad[0a];[1]aformat=fltp:44100:stereo,volume=0.2[1a];[0a][1a]amerge[a]" -map 0:v -map "[a]" -ac 2 -shortest output_with_background.mp4
And the console output while doing its stuff is:
ffmpeg version 4.2.3 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-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. 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
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baee72440] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\videos.txt':
Duration: N/A, start: -0.023220, bitrate: 18916 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 18861 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 54 kb/s
Metadata:
handler_name : SoundHandler
File 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\output.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\output.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 18861 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 54 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baee72440] Auto-inserting h264_mp4toannexb bitstream filter
Last message repeated 5 times
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baeeec180] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baee72440] Auto-inserting h264_mp4toannexb bitstream filter
Last message repeated 14 times
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baee72440] Auto-inserting h264_mp4toannexb bitstream filter
Last message repeated 20 times
[mov,mp4,m4a,3gp,3g2,mj2 # 0000024baee72440] Auto-inserting h264_mp4toannexb bitstream filter
Last message repeated 7 times
frame= 52 fps= 42 q=-1.0 Lsize= 7838kB time=00:07:38.82 bitrate= 139.9kbits/s speed= 374x
video:4802kB audio:2956kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.044608%
ffmpeg version 4.2.3 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-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. 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
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:07:38.85, start: 0.000000, bitrate: 139 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 87 kb/s, 0.12 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 52 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mp3, from 'C:\Users\shooey\Desktop\junky\Content\assets\background.mp3':
Metadata:
major_brand : dash
Software : Lavf57.56.101
minor_version : 0
compatible_brands: iso6mp41
Duration: 00:20:03.02, start: 0.025057, bitrate: 167 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 167 kb/s
Metadata:
encoder : LAME3.100
File 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\output_bckg.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:1 (aac) -> aformat
Stream #1:0 (mp3float) -> aformat
Stream #0:0 -> #0:0 (copy)
amerge -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_amerge_4 # 0000017093965c80] No channel layout for input 1
[Parsed_amerge_4 # 0000017093965c80] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, mp4, to 'C:\Users\shooey\Desktop\junky\Content\07-04-2021\output_bckg.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 87 kb/s, 0.12 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.54.100 aac
frame= 52 fps=5.5 q=-1.0 Lsize= 11993kB time=00:07:31.67 bitrate= 217.5kbits/s speed= 48x
video:4802kB audio:7111kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.670061%
[aac # 00000170935b4980] Qavg: 319.394
I think I found the answer by myself. I took the background.mp3 which I wanted to add and made it into a .aac audio file. After that I used the same command for adding audio but instead of -shortest I used -t 00:07:38 because it was the length of the video and I found that FFmpeg has a hard time recognizing the boundaries in videos.

Even after converting the Audio from Mono to Stereo in ffmpeg the video still has No sound Unless

I Change the audio Mode in VLC from Stereo to Mono then the Audio will play Normal
I used ffmpeg to convert the audio to Stereo using this
ffmpeg -i bokan_test_1.mkv -map 0 -map -0:s? -c:v copy -c:a ac3 -ac 2 -b:a 640k "E:\Test\output.S01E05.mkv"
I even used Handbrake still No audio in VLC unless I change the audio mode to Mono
Edit:
full log when running the ffmpeg command above
E:\test audio>ffmpeg -i bokan_test_1.mkv -map 0 -map -0:s? -c:v copy -c:a ac3 -ac 2 -b:a 640k "E:\Test\output.S01E06.mkv"
ffmpeg version 4.3.1-2021-01-01-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev5, 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-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --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-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
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
Input #0, matroska,webm, from 'bokan_test_1.mkv':
Metadata:
encoder : libebml v1.3.0 + libmatroska v1.4.0
creation_time : 2015-07-27T22:38:36.000000Z
Duration: 00:20:01.02, start: 0.000000, bitrate: 3497 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1440x1080, SAR 1:1 DAR 4:3, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Stream #0:1(ara): Audio: aac (HE-AAC), 44100 Hz, stereo, fltp (default)
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> ac3 (native))
Press [q] to stop, [?] for help
Output #0, matroska, to 'E:\Azmi\output.S01E06.mkv':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 1440x1080 [SAR 1:1 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc (default)
Stream #0:1(ara): Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, stereo, fltp, 640 kb/s (default)
Metadata:
encoder : Lavc58.91.100 ac3
frame=35994 fps=5263 q=-1.0 Lsize= 595496kB time=00:20:01.03 bitrate=4061.8kbits/s speed= 176x
video:501161kB audio:93829kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.085007%

Volume adjust and channel merge on video using FFMPEG

I'm trying to convert a recorded AVI (1 video stream, 2 audio streams[1st is stereo, 2nd is mono]) video file to H264/AAC.
I want the second audio stream to be at 60% volume and the first at 100%.
I also want to merge the first and second audio stream.
Output should be H264 with AAC audio.
The command I tried to use is:
"ffmpeg.exe"
-i "input.avi"
-filter_complex "
[0:a:0]aformat=channel_layouts=stereo,volume=1.0[a1];
[0:a:1]aformat=channel_layouts=mono,volume=0.6[a2];
[a1][a2]amerge,pan=stereo|c0<c0+c2|c1<c1+c2[out]
"
-map 0:v
-map "[out]"
-c:v libx264 -preset slow -crf 26
-c:a aac -strict experimental -ab 128000 -ac 2 -ar 48000
"output.mp4"
But I get the error:
[AVFilterGraph # 0000000ceb630c00] The following filters could not choose their formats: Parsed_amerge_4
Consider inserting the (a)format filter near their input or output.
Error configuring complex filters.
Error number -5 occurred
What am I doing wrong and how can it be fixed?
Complete Console Log:
ffmpeg version N-76456-g6df2c94 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 14.100 / 57. 14.100
libavformat 57. 14.100 / 57. 14.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
[avi # 000000b1cfa6bc20] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : stereo
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, avi, from 'input.avi':
Metadata:
encoder : DxtoryCore ver2.0.0.122
ISRC : Video:Lagarith Lossless Codec Audio0:Lautsprecher (2- USB Audio CODEC ) Audio1:Mikrofon (2- USB Audio CODEC )
Duration: 00:27:55.60, start: 0.000000, bitrate: 181780 kb/s
Stream #0:0: Video: lagarith (LAGS / 0x5347414C), rgb24, 1920x1017, 179663 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Stream #0:2: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
[Parsed_amerge_4 # 000000b1cfaf3200] No channel layout for input 1
Last message repeated 1 times
[AVFilterGraph # 000000b1cfa70c00] The following filters could not choose their formats: Parsed_amerge_4
Consider inserting the (a)format filter near their input or output.
Error configuring complex filters.
Error number -5 occurred
It seems this can be fixed by splitting all audio streams into separate channels first and then feeding it back into the amerge filter.
"ffmpeg.exe"
-i "input.avi"
-filter_complex "
[0:a:0]volume=1.0,channelsplit=channel_layout=stereo[a1][a2];
[0:a:1]volume=0.6,channelsplit=channel_layout=mono[a3];
[a1][a2][a3]amerge=inputs=3,pan=stereo|c0<c0+c2|c1<c1+c2[out]
"
-map 0:v
-map "[out]"
-c:v libx264 -preset slow -crf 26
-c:a aac -strict experimental -ab 128000 -ac 2 -ar 48000
"output.mp4"

ffmpeg 1 image (JPG) + 1 audio file (MP3) = 1 video (WEBM) using real encode (-re)

I'd like to make video streaming to distribute it in a streaming.
The mp3 file is being extracted from a video file (which is being recorded live) and, while audio being extracted (MP3), I want to take this audio file and a image it and spread it in a real time streaming. But -re is not working for this.
To extract audio file i use:
ffmpeg.exe -re -i file(LIVE).AVI -vn -ar 22050 -ab 16k -r 1 -ac 1 -f mp3 C:\Users\" & wshNetwork.Username & "\Documents\audio.mp3"
This work very well to make the MP3 file. Using -re.
After that, I'm using this command to marge the auvio file with the jpg image:
ffmpeg.exe -loop 1 -f image2 -i c:\picture.jpg -re -i c:\Users\" & wshNetwork.Username & "\Documents\audio.mp3 -vb 10k -ar 22050 -ab 16k -ac 1 -r 1 -bufsize 300k -f webm www.adress.com
This second command is not working because the -re is not working, and produce a video with the picture and a choppy audio.
the output is:
ffmpeg version N-63113-g72dcd48 Copyright (c) 2000-2014 the FFmpeg developers
built on May 12 2014 22:10:08 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-decklink --enable-zlib
libavutil 52. 83.100 / 52. 83.100
libavcodec 55. 61.100 / 55. 61.100
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, image2, from 'c:\imagens\radiobb.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc), 553x342 [SAR 96:96 DAR 553:342], 25
fps, 25 tbr, 25 tbn, 25 tbc
[mp3 # 0000000002b8f660] Estimating duration from bitrate, this may be inaccurat
e
Input #1, mp3, from 'C:\Users\f3548956\Documents\audio.mp3':
Metadata:
encoder : Lavf55.37.102
Duration: 00:00:09.34, start: 0.050113, bitrate: 16 kb/s
Stream #1:0: Audio: mp3, 22050 Hz, mono, s16p, 16 kb/s
[swscaler # 0000000002ae1640] deprecated pixel format used, make sure you did se
t range correctly
[libvpx # 0000000002a8da40] v1.3.0
Output #0, webm, to 'http://172.17.146.***:8080/publish/tvbb100?password=****'
:
Metadata:
encoder : Lavf55.37.102
Stream #0:0: Video: vp8 (libvpx), yuv420p, 553x342 [SAR 1:1 DAR 553:342], q=
-1--1, 10 kb/s, 1k tbn, 25 tbc
Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp, 16 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libvpx)
Stream #1:0 -> #0:1 (mp3 -> libvorbis)
Press [q] to stop, [?] for help
frame= 33 fps=0.0 q=0.0 size= 4kB time=00:00:01.32 bitrate= 23.3kbits/s
frame= 67 fps= 66 q=0.0 size= 4kB time=00:00:02.68 bitrate= 11.5kbits/s
frame= 101 fps= 66 q=0.0 size= 11kB time=00:00:04.04 bitrate= 22.4kbits/s
frame= 133 fps= 66 q=0.0 size= 11kB time=00:00:05.32 bitrate= 17.0kbits/s
Can anybody help me?

Resources