Extract all audio regardless of stream/channel count

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Extract all audio regardless of stream/channel count

Carles Vila
Hi,
I'd like to know if there is a simple way (script) to extract all audios
individually from a video. The video could have N stereo streams (normally
up to 16), M mono streams (up to 16),
or a combination of both. Now I have to write the -map structure manually
after probing the input. Ideally I need to end up with as many mono wavs as
individual channels.
If you could give me a starting point, I could probably figure out.
Thank you!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Extract all audio regardless of stream/channel count

Markku Vainio
Hello,

I've used this my AudioSplitter.bat script placed in windows "send to" folder for quick access. It could probably be much smarter but anyways it does the job for me. It loops now 50 times and creates 24bit wav files.

--------------------------------------
set ch=0
set tr=0
set count=0

:channelsplit
ffmpeg -i %1 -map 0:%tr% -map_channel 0.%tr%.%ch% -acodec pcm_s24le %1_%tr%_0%ch%.wav
set /A ch +=1

IF %ERRORLEVEL% NEQ 0 goto :nexttrack
goto:channelsplit

:nexttrack
if /I %count%==50 goto :eof
set ch=0
set /a tr +=1
set /a count +=1

echo %ch%
echo %tr%
echo %count%

goto:channelsplit

pause
--------------------------------------------



Regards,

Markku.

-----Original Message-----
From: ffmpeg-user [mailto:[hidden email]] On Behalf Of Carles Vila
Sent: 10. helmikuutata 2017 13:40
To: FFmpeg user questions <[hidden email]>
Subject: [FFmpeg-user] Extract all audio regardless of stream/channel count

Hi,
I'd like to know if there is a simple way (script) to extract all audios individually from a video. The video could have N stereo streams (normally up to 16), M mono streams (up to 16), or a combination of both. Now I have to write the -map structure manually after probing the input. Ideally I need to end up with as many mono wavs as individual channels.
If you could give me a starting point, I could probably figure out.
Thank you!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Extract all audio regardless of stream/channel count

Marton Balint
In reply to this post by Carles Vila

On Fri, 10 Feb 2017, Carles Vila wrote:

> Hi,
> I'd like to know if there is a simple way (script) to extract all audios
> individually from a video. The video could have N stereo streams (normally
> up to 16), M mono streams (up to 16),
> or a combination of both. Now I have to write the -map structure manually
> after probing the input. Ideally I need to end up with as many mono wavs as
> individual channels.
> If you could give me a starting point, I could probably figure out.

I think you can only do this by dynamically generating the command line
based on the probed input. So yes, you should write a script which first
probes the input streams with ffprobe (there are many output formats: xml,
json), then your script should determine the command line based on the
number of channels in yout input streams, and finally the script should
execute ffmpeg with the proper command line.

Regards,
Marton
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Extract all audio regardless of stream/channel count

Cley Faye
In reply to this post by Carles Vila
2017-02-10 12:40 GMT+01:00 Carles Vila <[hidden email]>:

> If you could give me a starting point, I could probably figure out.


‚ÄčThis comes with no guarantee, no documentation and very minimal testing,
but since you asked about a starting point...

I put up a small python script that take a file with many streams, detect
audio streams, output mono streams as single output file and stereo streams
as two files, all in one pass.
The script doesn't test for any cornercase, so there.

Even if it's not exactly fit for your task, it shows how you can easily
retrieve the output of ffprobe and produce a minimal ffmpeg command line.
http://pastebin.com/C53fqZG7
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Extract all audio regardless of stream/channel count

Carles Vila
On 11 February 2017 at 02:24, Cley Faye <[hidden email]> wrote:

> 2017-02-10 12:40 GMT+01:00 Carles Vila <[hidden email]>:
>
> > If you could give me a starting point, I could probably figure out.
>
>
> ‚ÄčThis comes with no guarantee, no documentation and very minimal testing,
> but since you asked about a starting point...
>
> I put up a small python script that take a file with many streams, detect
> audio streams, output mono streams as single output file and stereo streams
> as two files, all in one pass.
> The script doesn't test for any cornercase, so there.
>
> Even if it's not exactly fit for your task, it shows how you can easily
> retrieve the output of ffprobe and produce a minimal ffmpeg command line.
> http://pastebin.com/C53fqZG7
> _______________________________________________
>

Thank you Cley for the script, I will take a look at it and I'm sure I can
make it work for my purpose
Best regards
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Extract all audio regardless of stream/channel count

Carles Vila
In reply to this post by Markku Vainio
On 10 February 2017 at 14:12, Markku Vainio <[hidden email]> wrote:

> Hello,
>
> I've used this my AudioSplitter.bat script placed in windows "send to"
> folder for quick access. It could probably be much smarter but anyways it
> does the job for me. It loops now 50 times and creates 24bit wav files.
>
> --------------------------------------
> set ch=0
> set tr=0
> set count=0
>
> :channelsplit
> ffmpeg -i %1 -map 0:%tr% -map_channel 0.%tr%.%ch% -acodec pcm_s24le
> %1_%tr%_0%ch%.wav
> set /A ch +=1
>
> IF %ERRORLEVEL% NEQ 0 goto :nexttrack
> goto:channelsplit
>
> :nexttrack
> if /I %count%==50 goto :eof
> set ch=0
> set /a tr +=1
> set /a count +=1
>
> echo %ch%
> echo %tr%
> echo %count%
>
> goto:channelsplit
>
> pause
> --------------------------------------------
>
> Hi Markku,
This looks useful indeed. Although I'm not on windows (osx) but I see the
idea behind it.
Thanks for sharing
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

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