concat one video file and multiple audio files

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

concat one video file and multiple audio files

ropiafoldetnezi
hi,

this is my first try with ffmpeg, i would like to create av file from
multiple sources:
1 video file (.mp4)
6 separate audio files (.mps)

i would concat the audio files and combine them with the video:
video stream: video1,mp4
audio stream: audio1.mp3 + audio2.mp3 + ... audio6.mp3
lenght of audio stream match the length of the video

the command i tried (on windows 10):
ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3 -i
v1.mp3 -filter_complex
"[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=7:v=1:a=1[outv][outa]"
-map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4

the result i got:
ffmpeg version N-89773-g7fcbebbeaf Copyright (c) 2000-2018 the FFmpeg
developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv
--enable-libass --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-amf --enable-cuda
--enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2
--enable-avisynth --enable-libmfx
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7. 11.101 /  7. 11.101
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2018-01-11T10:20:13.000000Z
  Duration: 00:00:34.16, start: 0.000000, bitrate: 3032 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1920x1080, 3027 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2018-01-11T10:20:13.000000Z
      handler_name    : Alias Data Handler
      encoder         : AVC Coding
[mp3 @ 0000016f74e52380] Estimating duration from bitrate, this may be
inaccurate
Input #1, mp3, from 'f1.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:08.10, start: 0.000000, bitrate: 140 kb/s
    Stream #1:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
[mp3 @ 0000016f74e424c0] Estimating duration from bitrate, this may be
inaccurate
Input #2, mp3, from 'n1.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:02.10, start: 0.000000, bitrate: 177 kb/s
    Stream #2:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
[mp3 @ 0000016f74e85040] Estimating duration from bitrate, this may be
inaccurate
Input #3, mp3, from 'f2.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:08.10, start: 0.000000, bitrate: 140 kb/s
    Stream #3:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
[mp3 @ 0000016f74ea4e40] Estimating duration from bitrate, this may be
inaccurate
Input #4, mp3, from 'm1.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:03.10, start: 0.000000, bitrate: 160 kb/s
    Stream #4:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
[mp3 @ 0000016f74f0bb00] Estimating duration from bitrate, this may be
inaccurate
Input #5, mp3, from 'f3.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:08.14, start: 0.000000, bitrate: 140 kb/s
    Stream #5:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
[mp3 @ 0000016f74ef5dc0] Estimating duration from bitrate, this may be
inaccurate
Input #6, mp3, from 'v1.mp3':
  Metadata:
    date            : 2018-01-11 11:19
  Duration: 00:00:05.07, start: 0.000000, bitrate: 145 kb/s
    Stream #6:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s

the error msg:
Stream specifier ':a:0' in filtergraph description
[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=7:v=1:a=1[outv][outa]
matches no streams.

i also tried with less files but no success, also tried with [0:0][1:0] and
[0:v][0:a] syntax for filter_complex, did not worked;

any help appriciated

--

bye
bal
_______________________________________________
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: concat one video file and multiple audio files

Moritz Barsnick
On Thu, Jan 11, 2018 at 22:57:11 +0100, ropiafoldetnezi wrote:
> multiple sources:
> 1 video file (.mp4)
> 6 separate audio files (.mps)
[...]
> the command i tried (on windows 10):
> ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3 -i
> v1.mp3 -filter_complex
> "[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=7:v=1:a=1[outv][outa]"
> -map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4

You should be concat'ing the audio separately from the video, and then
mapping video and "[outa]" separately.

You can't concat an audio stream to a video.

Moritz
_______________________________________________
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: concat one video file and multiple audio files

ropiafoldetnezi
Thank you!

Is it possible to do the concat and the map in one step (one command)?


On Jan 11, 2018 11:11 PM, "Moritz Barsnick" <[hidden email]> wrote:

On Thu, Jan 11, 2018 at 22:57:11 +0100, ropiafoldetnezi wrote:
> multiple sources:
> 1 video file (.mp4)
> 6 separate audio files (.mps)
[...]
> the command i tried (on windows 10):
> ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3 -i
> v1.mp3 -filter_complex
> "[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=
7:v=1:a=1[outv][outa]"
> -map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4

You should be concat'ing the audio separately from the video, and then
mapping video and "[outa]" separately.

You can't concat an audio stream to a video.

Moritz
_______________________________________________
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: concat one video file and multiple audio files

Nicolas George
In reply to this post by Moritz Barsnick
Moritz Barsnick (2018-01-11):
> You should be concat'ing the audio separately from the video, and then
> mapping video and "[outa]" separately.

Very bad advice that would lead to A-V desync. Please read the
documentation.

Regards,

--
  Nicolas George

_______________________________________________
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".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: concat one video file and multiple audio files

DopeLabs
In reply to this post by ropiafoldetnezi
you can use concat like this

ffmpeg -f concat -i 'textfile.txt' -i video1.mp4 -c copy videoout.mp4

the text file contains the list of audio files you want to concat.


file 'f1.mp3'
file 'n1.mp3'
file 'f2.mp3'
file 'm1.mp3'
file 'f3.mp3'
file 'v1.mp3'

as long as all your audio files are encoded at the same bitrate, samplerate, etc, you shouldnt have any problems.

this also doesnt require a re-encode, you can stream copy which will be much much faster. anything you send through a filter complex usually will need to be re-encoded.


hope this helps =]



> On Jan 11, 2018, at 9:43 50PM, ropiafoldetnezi <[hidden email]> wrote:
>
> Thank you!
>
> Is it possible to do the concat and the map in one step (one command)?
>
>
> On Jan 11, 2018 11:11 PM, "Moritz Barsnick" <[hidden email]> wrote:
>
> On Thu, Jan 11, 2018 at 22:57:11 +0100, ropiafoldetnezi wrote:
>> multiple sources:
>> 1 video file (.mp4)
>> 6 separate audio files (.mps)
> [...]
>> the command i tried (on windows 10):
>> ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3 -i
>> v1.mp3 -filter_complex
>> "[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=
> 7:v=1:a=1[outv][outa]"
>> -map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4
>
> You should be concat'ing the audio separately from the video, and then
> mapping video and "[outa]" separately.
>
> You can't concat an audio stream to a video.
>
> Moritz
> _______________________________________________
> 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".

_______________________________________________
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: concat one video file and multiple audio files

ropiafoldetnezi
hi,

thank you all!

@dopelabs method worked for me best, and as i will make many videos the
speed boost is also welcome, thank you!

as i would like to create videos dynamicly (and generate ffmpeg commands
also), it would be easier for me to have all input in one command (instead
of list file), is it possibel?

thx


On Fri, Jan 12, 2018 at 11:18 AM, DopeLabs <[hidden email]> wrote:

> you can use concat like this
>
> ffmpeg -f concat -i 'textfile.txt' -i video1.mp4 -c copy videoout.mp4
>
> the text file contains the list of audio files you want to concat.
>
>
> file 'f1.mp3'
> file 'n1.mp3'
> file 'f2.mp3'
> file 'm1.mp3'
> file 'f3.mp3'
> file 'v1.mp3'
>
> as long as all your audio files are encoded at the same bitrate,
> samplerate, etc, you shouldnt have any problems.
>
> this also doesnt require a re-encode, you can stream copy which will be
> much much faster. anything you send through a filter complex usually will
> need to be re-encoded.
>
>
> hope this helps =]
>
>
>
> > On Jan 11, 2018, at 9:43 50PM, ropiafoldetnezi <
> [hidden email]> wrote:
> >
> > Thank you!
> >
> > Is it possible to do the concat and the map in one step (one command)?
> >
> >
> > On Jan 11, 2018 11:11 PM, "Moritz Barsnick" <[hidden email]> wrote:
> >
> > On Thu, Jan 11, 2018 at 22:57:11 +0100, ropiafoldetnezi wrote:
> >> multiple sources:
> >> 1 video file (.mp4)
> >> 6 separate audio files (.mps)
> > [...]
> >> the command i tried (on windows 10):
> >> ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3
> -i
> >> v1.mp3 -filter_complex
> >> "[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=
> > 7:v=1:a=1[outv][outa]"
> >> -map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4
> >
> > You should be concat'ing the audio separately from the video, and then
> > mapping video and "[outa]" separately.
> >
> > You can't concat an audio stream to a video.
> >
> > Moritz
> > _______________________________________________
> > 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".
>
> _______________________________________________
> 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".
>



--

üdv
bal
_______________________________________________
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: concat one video file and multiple audio files

DopeLabs
you can chain a few commands into a single '1 liner' if youd like...

for f in 1.mp3 2.mp3 3.mp3 4.mp3; do echo "file $f" >> concat.txt; done && ffmpeg -f concat -i 'concat.txt' -i video1.mp4 -c copy videoout.mp4

technically 2 commands... but this is basically scripting, which falls outside the scope of this mailing list.

cheers

> On Jan 12, 2018, at 6:43 33AM, ropiafoldetnezi <[hidden email]> wrote:
>
> hi,
>
> thank you all!
>
> @dopelabs method worked for me best, and as i will make many videos the
> speed boost is also welcome, thank you!
>
> as i would like to create videos dynamicly (and generate ffmpeg commands
> also), it would be easier for me to have all input in one command (instead
> of list file), is it possibel?
>
> thx
>
>
> On Fri, Jan 12, 2018 at 11:18 AM, DopeLabs <[hidden email]> wrote:
>
>> you can use concat like this
>>
>> ffmpeg -f concat -i 'textfile.txt' -i video1.mp4 -c copy videoout.mp4
>>
>> the text file contains the list of audio files you want to concat.
>>
>>
>> file 'f1.mp3'
>> file 'n1.mp3'
>> file 'f2.mp3'
>> file 'm1.mp3'
>> file 'f3.mp3'
>> file 'v1.mp3'
>>
>> as long as all your audio files are encoded at the same bitrate,
>> samplerate, etc, you shouldnt have any problems.
>>
>> this also doesnt require a re-encode, you can stream copy which will be
>> much much faster. anything you send through a filter complex usually will
>> need to be re-encoded.
>>
>>
>> hope this helps =]
>>
>>
>>
>>> On Jan 11, 2018, at 9:43 50PM, ropiafoldetnezi <
>> [hidden email]> wrote:
>>>
>>> Thank you!
>>>
>>> Is it possible to do the concat and the map in one step (one command)?
>>>
>>>
>>> On Jan 11, 2018 11:11 PM, "Moritz Barsnick" <[hidden email]> wrote:
>>>
>>> On Thu, Jan 11, 2018 at 22:57:11 +0100, ropiafoldetnezi wrote:
>>>> multiple sources:
>>>> 1 video file (.mp4)
>>>> 6 separate audio files (.mps)
>>> [...]
>>>> the command i tried (on windows 10):
>>>> ffmpeg -i video1.mp4 -i f1.mp3 -i n1.mp3 -i f2.mp3 -i m1.mp3 -i f3.mp3
>> -i
>>>> v1.mp3 -filter_complex
>>>> "[0:v:0][1:a:0][2:a:0][3:a:0][4:a:0][5:a:0][6:a:0]concat=n=
>>> 7:v=1:a=1[outv][outa]"
>>>> -map "[outv]" -map "[outa]" output/v1_n1_m1_v1_t_02.mp4
>>>
>>> You should be concat'ing the audio separately from the video, and then
>>> mapping video and "[outa]" separately.
>>>
>>> You can't concat an audio stream to a video.
>>>
>>> Moritz
>>> _______________________________________________
>>> 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".
>>
>> _______________________________________________
>> 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".
>>
>
>
>
> --
>
> üdv
> bal
> _______________________________________________
> 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: concat one video file and multiple audio files

Moritz Barsnick
In reply to this post by Nicolas George
On Fri, Jan 12, 2018 at 11:17:49 +0100, Nicolas George wrote:
> Moritz Barsnick (2018-01-11):
> > You should be concat'ing the audio separately from the video, and then
> > mapping video and "[outa]" separately.
>
> Very bad advice that would lead to A-V desync. Please read the
> documentation.

It was very bad wording from my side, sorry. I meant that ffmpeg needs
to handle the audio and the video in separate chains and mappings,
within the same command line call of course. (Case closed by DopeLabs's
response.)

OTOH, I don't see where the original poster's audio and video were ever
sync'd (they were already separate), so how could this introduce
desync?

Moritz
_______________________________________________
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: concat one video file and multiple audio files

Nicolas George
Moritz Barsnick (2018-01-13):
> It was very bad wording from my side, sorry. I meant that ffmpeg needs
> to handle the audio and the video in separate chains

Still wrong. Read the documentation please before spreading more
mistakes.

Regards,

--
  Nicolas George

_______________________________________________
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".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: concat one video file and multiple audio files

ropiafoldetnezi
hi,

the conversation was helpful for me, thank you!
@DopeLabs the chaining work well also, changed it for windows batch and it
runs fine and fast, thx!

bye
ropiafoldetnezi


On Sat, Jan 13, 2018 at 6:42 PM, Nicolas George <[hidden email]> wrote:

> Moritz Barsnick (2018-01-13):
> > It was very bad wording from my side, sorry. I meant that ffmpeg needs
> > to handle the audio and the video in separate chains
>
> Still wrong. Read the documentation please before spreading more
> mistakes.
>
> Regards,
>
> --
>   Nicolas George
>
> _______________________________________________
> 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".
>



--

üdv
bal
_______________________________________________
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".