Muxing Video from Cam1 with Audio from Cam2?
After buying 6 new IP cameras recently, I have suddenly discovered that none of them has a microphone :facepalm: I can’t return them because I’ve done some surgery on them to bypass their 12 V power input diodes, but now I want to stream video from them with audio. I do have a crummy older IP camera laying around that does have audio, but the video quality and features are not what I want. What’s the correct syntax to mux the video from new Cam1 with the audio from older Cam2, while completely discarding the unwanted video from Cam2? Preferably without transcoding anything, since I want to minimize CPU usage. I ran the following command, but it just stalls at time=00:00:09.58 and never returns, and the resulting out.mp4 is an invalid movie with a size of 44 bytes. How do apply “-vn” to Input #1 only? Thanks! ffmpeg -re -thread_queue_size 1024 -rtsp_transport tcp -i "rtsp://anonymous:password1@192.168.1.13:554/cam/realmonitor?channel=1&subtype=0" -i "rtsp://anonymous:password@192.168.1.39:554" -vn -acodec copy -t 00:00:10 out.mp4 ffmpeg version N-100466-g29cef1bcd6-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2020 the FFmpeg developers built with Apple clang version 11.0.0 (clang-1100.0.33.17) configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay libavutil 56. 62.100 / 56. 62.100 libavcodec 58.115.102 / 58.115.102 libavformat 58. 65.100 / 58. 65.100 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7. 94.100 / 7. 94.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Input #0, rtsp, from 'rtsp://anonymous:password1@192.168.1.13:554/cam/realmonitor?channel=1&subtype=0': Metadata: title : Media Server Duration: N/A, start: 0.100000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 100 tbr, 90k tbn, 180k tbc Input #1, rtsp, from 'rtsp://anonymous:password@192.168.1.39:554': Metadata: title : Session streamed by "preview" comment : Duration: N/A, start: 0.000000, bitrate: N/A Stream #1:0: Video: h264 (High), yuv420p(progressive), 2560x1440, 29.97 tbr, 90k tbn, 180k tbc Stream #1:1: Audio: aac (LC), 16000 Hz, mono, fltp Output #0, mp4, to 'out.mp4': Metadata: title : Media Server encoder : Lavf58.65.100 Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 16000 Hz, mono, fltp Stream mapping: Stream #1:1 -> #0:0 (copy) Press [q] to stop, [?] for help [rtsp @ 0x7fa887008000] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8) [rtsp @ 0x7fa887008000] max delay reached. need to consume packetx [rtsp @ 0x7fa887008000] RTP: missed 1 packets size= 0kB time=00:00:09.58 bitrate= 0.0kbits/s speed=1.11x
On 2/19/2021 6:23 PM, Steven Kan wrote:
What’s the correct syntax to mux the video from new Cam1 with the audio from older Cam2, while completely discarding the unwanted video from Cam2? Preferably without transcoding anything, since I want to minimize CPU usage.
It's all about the mapping (and this is answered at https://stackoverflow.com/questions/12938581/ffmpeg-mux-video-and-audio-from...) but the command will look something like ffmpeg -i VIDEOSOURCE -i AUDIOSOURCE -map 0.0 -map 1.1 -t 00:00:10 out.mp4 (assume that the video is stream 0 in both and audio is stream 1) Also look up the options -shortest and -apad to see if they may apply (https://ffmpeg.org/documentation.html). I'd consider whether .mkv is better output container than .mp4, which can become corrupt if the file isn't closed properly. Later, z!
Thank you Carl and DEF! Works perfectly! I’m using out.mp4 just for syntax testing. In the actual application I’ll be outputting to: -f flv "rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key” But it’s good to know about container issues!
On Feb 19, 2021, at 7:14 PM, Carl Zwanzig <cpz@tuunq.com> wrote:
On 2/19/2021 6:23 PM, Steven Kan wrote:
What’s the correct syntax to mux the video from new Cam1 with the audio from older Cam2, while completely discarding the unwanted video from Cam2? Preferably without transcoding anything, since I want to minimize CPU usage.
It's all about the mapping (and this is answered at https://stackoverflow.com/questions/12938581/ffmpeg-mux-video-and-audio-from...)
but the command will look something like
ffmpeg -i VIDEOSOURCE -i AUDIOSOURCE -map 0.0 -map 1.1 -t 00:00:10 out.mp4 (assume that the video is stream 0 in both and audio is stream 1)
Also look up the options -shortest and -apad to see if they may apply (https://ffmpeg.org/documentation.html).
I'd consider whether .mkv is better output container than .mp4, which can become corrupt if the file isn't closed properly.
Later,
z! _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
On Sat, 20 Feb 2021 at 03:56, Steven Kan <steven@kan.org> wrote:
What’s the correct syntax to mux the video from new Cam1 with the audio from older Cam2, while completely discarding the unwanted video from Cam2? Preferably without transcoding anything, since I want to minimize CPU usage. I ran the following command, but it just stalls at time=00:00:09.58 and never returns, and the resulting out.mp4 is an invalid movie with a size of 44 bytes. How do apply “-vn” to Input #1 only? Thanks!
ffmpeg -re -thread_queue_size 1024 -rtsp_transport tcp -i "rtsp://anonymous:password1@192.168.1.13:554/cam/realmonitor?channel=1&subtype=0" -i "rtsp://anonymous:password@192.168.1.39:554" -vn -acodec copy -t 00:00:10 out.mp4
you can just use the map option ffmpeg -re -thread_queue_size 1024 -rtsp_transport tcp -i "rtsp://anonymous:password1@192.168.1.13:554/cam/realmonitor?channel=1&subtype=0" -i "rtsp://anonymous:password@192.168.1.39:554" -map 0:v -map 1:a -acodec copy -t 00:00:10 out.mp4
participants (3)
-
Carl Zwanzig -
DEF -
Steven Kan