Selecting MPEG TS child streams for filter_complex

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Selecting MPEG TS child streams for filter_complex

Michael Fladischer
Hi,

I'm trying to merge two audio streams from a MPEG TS file using the amix
filter.

Here's the file metadata:
$ ffmpeg -probesize 50M -analyzeduration 50M -i file.ts
Input #0, mpegts, from 'file.ts':
   Duration: 00:09:32.10, start: 0.000000, bitrate: 12944 kb/s
   Program 1
     Metadata:
       service_name    : HDMI-A,HDMI-B
       service_provider: Epiphan Streamer
     Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr,
90k tbn, 60 tbc
     Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100
Hz, stereo, fltp, 322 kb/s
     Stream #0:2[0x102]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr,
90k tbn, 60 tbc
     Stream #0:3[0x103]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100
Hz, stereo, fltp, 322 kb/s

Now I tried to use the child stream IDs of both audio streams in
combination with amix:

$ ffmpeg -f -i file.ts -filter_complex '[i:0x101][i:0x103]amix=inputs=2'
-vn -c:a flac /tmp/out.flac

But this throws an error:
Invalid file index 0 in filtergraph description
[i:0x101][i:0x103]amix=inputs=2.

Do I have to use the stream ID in a different way? I got the [i:<id>]
syntax from here:

https://trac.ffmpeg.org/wiki/Map

Thanks for your help!

Kind regards,
Michael
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Moritz Barsnick
On Mon, Mar 16, 2020 at 09:05:17 +0100, Michael Fladischer wrote:
> Now I tried to use the child stream IDs of both audio streams in
> combination with amix:
>
> $ ffmpeg -f -i file.ts -filter_complex '[i:0x101][i:0x103]amix=inputs=2'
> -vn -c:a flac /tmp/out.flac

Could you kindly show us the *complete* uncut comsole output of your
ffmpeg command.

Also please quote the actual command used, the one you showed has a
syntax error. ;-) (The "-f" should throw an error.)

Thanks,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Michael Fladischer
Hi Moritz,

Am 16.03.2020 um 09:16 schrieb Moritz Barsnick:
> Also please quote the actual command used, the one you showed has a
> syntax error.;-)  (The "-f" should throw an error.)

you are right, I somehow mistook '-f' for "overwrite output file if
exists", instead of '-y'. Now it works.

But there was no syntax error:

$ ffmpeg -f -i file.ts -filter_complex '[i:0x101][i:0x103]amix=inputs=2'
-vn -c:a flac /tmp/auphonic-input-m2s6wfy8.flac
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
   built with gcc 8 (Debian 8.3.0-6)
   configuration: --prefix=/usr --extra-version='1~deb10u1'
--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-opengl --enable-sdl2
--enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
   WARNING: library configuration mismatch
   avcodec     configuration: --prefix=/usr --extra-version='1~deb10u1'
--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-opengl --enable-sdl2
--enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
--enable-version3 --disable-doc --disable-programs --enable-liblensfun
--enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libtesseract --enable-libvo_amrwbenc
   avfilter    configuration: --prefix=/usr --extra-version='1~deb10u1'
--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-opengl --enable-sdl2
--enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
--enable-version3 --disable-doc --disable-programs --enable-liblensfun
--enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libtesseract --enable-libvo_amrwbenc
   libavutil      56. 22.100 / 56. 22.100
   libavcodec     58. 35.100 / 58. 35.100
   libavformat    58. 20.100 / 58. 20.100
   libavdevice    58.  5.100 / 58.  5.100
   libavfilter     7. 40.101 /  7. 40.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  3.100 /  5.  3.100
   libswresample   3.  3.100 /  3.  3.100
   libpostproc    55.  3.100 / 55.  3.100
Invalid file index 0 in filtergraph description
[i:0x101][i:0x103]amix=inputs=2.



_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Moritz Barsnick
On Mon, Mar 16, 2020 at 09:21:56 +0100, Michael Fladischer wrote:
> But there was no syntax error:
>
> $ ffmpeg -f -i file.ts -filter_complex '[i:0x101][i:0x103]amix=inputs=2' -vn -c:a flac /tmp/auphonic-input-m2s6wfy8.flac
[...]
> Invalid file index 0 in filtergraph description [i:0x101][i:0x103]amix=inputs=2.

Yeah, interesting. It's due to the the fact that the "-i" get swallowed
as an option to "-f", and you therefore have no input files specified,
and therefore the filtergraph cannot be set up.

With loglevel verbose, I get:
> Reading option '-f' ... matched as option 'f' (force format) with argument '-i'.

I wonder why ffmpeg doesn't trip over this first. Whatever.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Gyan Doshi-2


On 16-03-2020 01:57 pm, Moritz Barsnick wrote:

> On Mon, Mar 16, 2020 at 09:21:56 +0100, Michael Fladischer wrote:
>> But there was no syntax error:
>>
>> $ ffmpeg -f -i file.ts -filter_complex '[i:0x101][i:0x103]amix=inputs=2' -vn -c:a flac /tmp/auphonic-input-m2s6wfy8.flac
> [...]
>> Invalid file index 0 in filtergraph description [i:0x101][i:0x103]amix=inputs=2.
> Yeah, interesting. It's due to the the fact that the "-i" get swallowed
> as an option to "-f", and you therefore have no input files specified,
> and therefore the filtergraph cannot be set up.
>
> With loglevel verbose, I get:
>> Reading option '-f' ... matched as option 'f' (force format) with argument '-i'.
> I wonder why ffmpeg doesn't trip over this first. Whatever.

-f is paired with -i and file.ts is interpreted as output URL so
-filter_complex gets correctly paired with its arg.

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Moritz Barsnick
On Mon, Mar 16, 2020 at 17:32:42 +0530, Gyan Doshi wrote:
> > With loglevel verbose, I get:
> >> Reading option '-f' ... matched as option 'f' (force format) with argument '-i'.
> > I wonder why ffmpeg doesn't trip over this first. Whatever.
> -f is paired with -i and file.ts is interpreted as output URL so
> -filter_complex gets correctly paired with its arg.

Well understood. However I was wondering about the order of evaluation,
and somehow expecting

> [NULL @ 0xbdaf800] Requested output format '-i' is not a suitable output format

but ffmpeg certainly has its reasons for this order.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Gyan Doshi-2


On 16-03-2020 06:24 pm, Moritz Barsnick wrote:

> On Mon, Mar 16, 2020 at 17:32:42 +0530, Gyan Doshi wrote:
>>> With loglevel verbose, I get:
>>>> Reading option '-f' ... matched as option 'f' (force format) with argument '-i'.
>>> I wonder why ffmpeg doesn't trip over this first. Whatever.
>> -f is paired with -i and file.ts is interpreted as output URL so
>> -filter_complex gets correctly paired with its arg.
> Well understood. However I was wondering about the order of evaluation,
> and somehow expecting
>
>> [NULL @ 0xbdaf800] Requested output format '-i' is not a suitable output format
> but ffmpeg certainly has its reasons for this order.

-filter_complex is a global option, so parsed first, then input files,
then the complex filtergraphs are set up, then output files.

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Carl Zwanzig
On 3/16/2020 6:24 AM, Gyan Doshi wrote:
> -filter_complex is a global option, so parsed first, then input files, then
> the complex filtergraphs are set up, then output files.

Is there any reason, then, not to always put -filter_complex as the first
parameters of the command line? The Synopsis line in the docs shows global
options first but most of the doc examples don't.

Example-
ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]'
-map '[out]' out.mkv"

Or is there another reason for listing inputs, then -filter_complex, then
outputs?

later,

z!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Mark Filipak
On 03/16/2020 04:37 PM, Carl Zwanzig wrote:
> On 3/16/2020 6:24 AM, Gyan Doshi wrote:
>> -filter_complex is a global option, so parsed first, then input files, then the complex filtergraphs are set up, then output files.
>
> Is there any reason, then, not to always put -filter_complex as the first parameters of the command line? The Synopsis line in the docs shows global options first but most of the doc examples don't.
>
> Example-
> ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map '[out]' out.mkv"
>
> Or is there another reason for listing inputs, then -filter_complex, then outputs?

I've been told several times by several gurus that filters, including filter_complex, are output specific must be specified directly before the output to which they apply, and. for processes that have multiple outputs, can be differently for each output.

HTH,
Mark.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Mark Filipak
In reply to this post by Carl Zwanzig
On 03/16/2020 04:37 PM, Carl Zwanzig wrote:
> On 3/16/2020 6:24 AM, Gyan Doshi wrote:
>> -filter_complex is a global option, so parsed first, then input files, then the complex filtergraphs are set up, then output files.
>
> Is there any reason, then, not to always put -filter_complex as the first parameters of the command line? The Synopsis line in the docs shows global options first but most of the doc examples don't.
>
> Example-
> ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map '[out]' out.mkv"
>
> Or is there another reason for listing inputs, then -filter_complex, then outputs?

I've been told several times by several gurus that filters, including filter_complex, are output specific and must be specified directly before the output to which they apply, and, for processes that have multiple outputs, can be different for each output.

HTH,
Mark.

PS: Follow-up. Here's my style of documentation, best viewed as plain text, for the overall structure of commands:

Basic command example:
         1ST INPUT  ADDITIONAL INPUTS      OUTPUTS        ...Note 1
ffmpeg  [A]  -i B   [[C]  -i D ...]  [[E] [F]  G ...]]   ...Note 2
     [A] -i B     : the 1st input's specification.
                  : [A] : the 1st input's options, if any.
                  :  B  : the 1st input's URL.
  [[C] -i D ...]  : additional input specifications, if any.
                  : [C] : the 2nd input's options, if any.
                  :  D  : the 2nd input's URL.
                  : ... : more input specifications.
  [[E] [F] G ...] : output specifications, if any.
                  : [E] : an output's filter chain, if any.
                  : [F] : an output's options, if any.
                  :  G  : an output's URL.
                  : ... : more output specifications.
Note 1: All inputs first, then all outputs.
Note 2: A B C D E F G are tokens that appear here simply to preserve
         space.
Note 3: Global options (not shown) can be anywhere except within
         another option or at the end of the command.
Note 4: Braces, [], denote options here but should not appear in actual
         commands except where ffmpeg docs indicate (for example, input
         and output pads in filter chains).
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Lou Logan
In reply to this post by Carl Zwanzig
On Mon, Mar 16, 2020, at 12:37 PM, Carl Zwanzig wrote:
>
> Or is there another reason for listing inputs, then -filter_complex, then
> outputs?

Simple reason I usually list them in that order is because it is easier
and more logical for me to process it in the form of:

inputs -> filters -> output

Which is a simplification of the diagrams in:
https://ffmpeg.org/ffmpeg.html#Detailed-description
https://ffmpeg.org/ffmpeg.html#Complex-filtergraphs
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

Carl Zwanzig
On 3/16/2020 3:30 PM, Lou Logan wrote:
> Simple reason I usually list them in that order is because it is easier
> and more logical for me to process it in the form of:
>
> inputs -> filters -> output

Accepted that it's convenient although -filter_complex (global) is a
different beast than -filter (positional, on output).

OTOH...
given the doc's synopsis of
        ffmpeg \
        [global_options] \
        {[input_file_options] -i input_url} ... \
        {[output_file_options] output_url} ...

should global options be allowed to intermingle with positional options?
should the examples be rewritten to follow the synopsis (put all globals first)?
(and are there times when a "global" option becomes positional?)

I'm willing to do some of the editing....

z!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Selecting MPEG TS child streams for filter_complex

kumowoon1025
In reply to this post by Carl Zwanzig
Hello,

> Is there any reason, then, not to always put -filter_complex as the first parameters of the command line? The Synopsis line in the docs shows global options first but most of the doc examples don't.
>
> Example-
> ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map '[out]' out.mkv"
>
> Or is there another reason for listing inputs, then -filter_complex, then outputs?

Unless they were precomposed filter “script” files (and even then) I think having input before the filter followed by the output is the intuitive way to structure the command, if that counts as a reason.

Iirc, “complex” filtergraphs as opposed to the older/simpler -vf, -af filters have implicit input and output pads for each chain that can be remapped pretty freely, and not according to its position.


Regards,
Ted Park

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".