[FFmpeg-user] Problem getting 2 croped video streams +audio
Moritz Barsnick
barsnick at gmx.net
Mon Jan 20 23:08:57 EET 2020
Hi Fabrice,
On Mon, Jan 20, 2020 at 18:19:22 +0100, Fabrice DUPRAT via ffmpeg-user wrote:
> From a rtsp flux (1 video stream + 1 audio stream), I would like to record 3
> files: 2 video files containing only the video stream (corresponding to left
> and right parts of the video) and 1 audio file containing only the audio
> stream (mono).
>
> My command is doing something but the left file is containing the full size
> video and according to its size also probably contain some audio (not
> detected by VLC reader), can you help me please ?
[...]
> ffmpeg -loglevel warning -r 12 -rtsp_transport tcp -i
> "rtsp://login:pass@XXXX:554/12"
> -map 0:a:0 -t 00:00:10 audio.wav
> -map 0:v:0 -filter_complex [0:v]crop=in_w/2:in_h:0:0[out_L] -filter_complex [0:v]crop=in_w/2:in_h:in_w/2:0[out_R]
> -map [out_L] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_L" videoL.mp4
> -map [out_R] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_R" videoR.mp4
>
> OUTPUT OF ABOVE COMMAND
>
> c:v libx265 -metadata title="id_R" videoR.mp4
On this list, we kindly ask you to provide us with the complete, uncut
output of your ffmpeg command. And that implies not using
"-hide_banner" (which you didn't, obviously), and not reducing the log
level.
With "-loglevel warning", you are asking ffmpeg not to give you all the
useful information. Useful not only for us, but also for you. For
example, ffmpeg tells you which inputs it is mapping to which filters,
which it is mapping to which outputs.
That said, I can explain your issue from the command line:
> -map 0:a:0 -t 00:00:10 audio.wav
> -map 0:v:0 -filter_complex [0:v]crop=in_w/2:in_h:0:0[out_L] -filter_complex [0:v]crop=in_w/2:in_h:in_w/2:0[out_R]
> -map [out_L] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_L" videoL.mp4
> -map [out_R] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_R" videoR.mp4
You are providing three outputs (as you did explain), but four "-map"
instructions. So the second and the third "-map" both map to output
videoL.mp4. In other words, videoL.mp4 will contain both "0:v:0" and
"[out_L]" as separate video streams. If you fiddle with VLC's menus,
you will see both streams.
(Furthermore I thought that you cannot use "-filter_complex" twice, but
it turns out you can.. You can also define several chains by using one
such option and separating the chains with ';'."
This would be your correct command line (guesssing a bit here -
untested):
$ ffmpeg -r 12 -rtsp_transport tcp -i "rtsp://login:pass@XXXX:554/12" \
-map 0:a:0 -t 00:00:10 audio.wav \
-filter_complex "[0:v]crop=in_w/2:in_h:0:0[out_L]; [0:v]crop=in_w/2:in_h:in_w/2:0[out_R]" \
-map [out_L] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_L" videoL.mp4 \
-map [out_R] -t 00:00:10 -r 12 -y -c:v libx265 -metadata title="id_R" videoR.mp4
(Not sure whether you can use "[0:v]" twice, but you'll see.)
Cheers,
Moritz
More information about the ffmpeg-user
mailing list