Re: [FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Paul B Mahol
On 1/19/20, Michael Koch  wrote:
> Am 19.01.2020 um 21:56 schrieb Paul B Mahol:
>> On 1/19/20, Michael Koch  wrote:
>>> Am 19.01.2020 um 21:01 schrieb Paul B Mahol:
 On 1/19/20, Michael Koch  wrote:
> Hello,
>
> I've just found a problem that can be reproduced as follows:
>
> Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
> played.
>
> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y
> video.mp4
>
>
> Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
> at t=3s. The file is ok when played.
>
> ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
> -y audio.wav
>
>
> Step 3: Combine both files into one video, and the audio sources shall
> be mixed:
>
> ffmpeg -i video.mp4 -i audio.wav -filter_complex
> "[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
>
> The output video has the correct length 6s, but I don't understand why
> the 1kHz tone disappears after 4s and the last 2s are silence.
>
> The console output is below.
 Can not reproduce using nut container.
>>> When I change the output filename to out.nut, then it works as expected
>>> (but with terrible image quality). Why doesn't it work with mp4 output?
>> Use different video encoder. Who knows?
>
> When I add -c:v mpeg4 then it works fine.
> When I add -c:v libx264 then the audio output is 2s too short.
> Is it a bug, or is something wrong with my command line?
>

Dunno.

> Michael
>
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Michael Koch

Am 19.01.2020 um 21:56 schrieb Paul B Mahol:

On 1/19/20, Michael Koch  wrote:

Am 19.01.2020 um 21:01 schrieb Paul B Mahol:

On 1/19/20, Michael Koch  wrote:

Hello,

I've just found a problem that can be reproduced as follows:

Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
played.

ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y
video.mp4


Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
at t=3s. The file is ok when played.

ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
-y audio.wav


Step 3: Combine both files into one video, and the audio sources shall
be mixed:

ffmpeg -i video.mp4 -i audio.wav -filter_complex
"[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4

The output video has the correct length 6s, but I don't understand why
the 1kHz tone disappears after 4s and the last 2s are silence.

The console output is below.

Can not reproduce using nut container.

When I change the output filename to out.nut, then it works as expected
(but with terrible image quality). Why doesn't it work with mp4 output?

Use different video encoder. Who knows?


When I add -c:v mpeg4 then it works fine.
When I add -c:v libx264 then the audio output is 2s too short.
Is it a bug, or is something wrong with my command line?

Michael

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Paul B Mahol
On 1/19/20, Michael Koch  wrote:
> Am 19.01.2020 um 21:01 schrieb Paul B Mahol:
>> On 1/19/20, Michael Koch  wrote:
>>> Hello,
>>>
>>> I've just found a problem that can be reproduced as follows:
>>>
>>> Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
>>> played.
>>>
>>> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y
>>> video.mp4
>>>
>>>
>>> Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
>>> at t=3s. The file is ok when played.
>>>
>>> ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
>>> -y audio.wav
>>>
>>>
>>> Step 3: Combine both files into one video, and the audio sources shall
>>> be mixed:
>>>
>>> ffmpeg -i video.mp4 -i audio.wav -filter_complex
>>> "[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
>>>
>>> The output video has the correct length 6s, but I don't understand why
>>> the 1kHz tone disappears after 4s and the last 2s are silence.
>>>
>>> The console output is below.
>> Can not reproduce using nut container.
>
> When I change the output filename to out.nut, then it works as expected
> (but with terrible image quality). Why doesn't it work with mp4 output?

Use different video encoder. Who knows?

>
> Michael
>
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Michael Koch

Am 19.01.2020 um 21:01 schrieb Paul B Mahol:

On 1/19/20, Michael Koch  wrote:

Hello,

I've just found a problem that can be reproduced as follows:

Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
played.

ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y video.mp4


Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
at t=3s. The file is ok when played.

ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
-y audio.wav


Step 3: Combine both files into one video, and the audio sources shall
be mixed:

ffmpeg -i video.mp4 -i audio.wav -filter_complex
"[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4

The output video has the correct length 6s, but I don't understand why
the 1kHz tone disappears after 4s and the last 2s are silence.

The console output is below.

Can not reproduce using nut container.


When I change the output filename to out.nut, then it works as expected 
(but with terrible image quality). Why doesn't it work with mp4 output?


Michael

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Paul B Mahol
On 1/19/20, Michael Koch  wrote:
> Hello,
>
> I've just found a problem that can be reproduced as follows:
>
> Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
> played.
>
> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y video.mp4
>
>
> Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
> at t=3s. The file is ok when played.
>
> ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
> -y audio.wav
>
>
> Step 3: Combine both files into one video, and the audio sources shall
> be mixed:
>
> ffmpeg -i video.mp4 -i audio.wav -filter_complex
> "[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
>
> The output video has the correct length 6s, but I don't understand why
> the 1kHz tone disappears after 4s and the last 2s are silence.
>
> The console output is below.

Can not reproduce using nut container.

> Michael
>
>
>
> F:\Test_Audio>c:\ffmpeg\ffmpeg -i video.mp4 -i audio.wav -filter_complex
> "[0:a][
> 1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
> ffmpeg version git-2020-01-15-0dc0837 Copyright (c) 2000-2020 the FFmpeg
> develop
> ers
>built with gcc 9.2.1 (GCC) 20200111
>configuration: --enable-gpl --enable-version3 --enable-sdl2
> --enable-fontconfi
> g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d
> --enable-libb
> luray --enable-libfreetype --enable-libmp3lame
> --enable-libopencore-amrnb --enab
> le-libopencore-amrwb --enable-libopenjpeg --enable-libopus
> --enable-libshine --e
> nable-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 --enab
> le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
> --enable-libmysofa --en
> able-libspeex --enable-libxvid --enable-libaom --enable-libmfx
> --enable-ffnvcode
> c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec
> --enable-dxva2 -
> -enable-avisynth --enable-libopenmpt --enable-amf
>libavutil  56. 38.100 / 56. 38.100
>libavcodec 58. 65.103 / 58. 65.103
>libavformat58. 35.102 / 58. 35.102
>libavdevice58.  9.103 / 58.  9.103
>libavfilter 7. 71.100 /  7. 71.100
>libswscale  5.  6.100 /  5.  6.100
>libswresample   3.  6.100 /  3.  6.100
>libpostproc55.  6.100 / 55.  6.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
>Metadata:
>  major_brand : isom
>  minor_version   : 512
>  compatible_brands: isomiso2avc1mp41
>  encoder : Lavf58.35.102
>Duration: 00:00:06.02, start: 0.00, bitrate: 938 kb/s
>  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 640x480 [
> SAR 1:1 DAR 4:3], 864 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
>  Metadata:
>handler_name: VideoHandler
>  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
> mono, fltp,
>   68 kb/s (default)
>  Metadata:
>handler_name: SoundHandler
> Guessed Channel Layout for Input Stream #1.0 : mono
> Input #1, wav, from 'audio.wav':
>Metadata:
>  encoder : Lavf58.35.102
>Duration: 00:00:10.00, bitrate: 705 kb/s
>  Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz,
> mono, s16,
> 705 kb/s
> Stream mapping:
>Stream #0:1 (aac) -> amix:input0 (graph 0)
>Stream #1:0 (pcm_s16le) -> amix:input1 (graph 0)
>amix (graph 0) -> Stream #0:0 (aac)
>Stream #0:0 -> #0:1 (h264 (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [libx264 @ 029d7540] using SAR=1/1
> [libx264 @ 029d7540] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2
> AVX FMA3 BMI2 AVX2
> [libx264 @ 029d7540] profile High, level 3.0, 4:2:0, 8-bit
> [libx264 @ 029d7540] 264 - core 159 - H.264/MPEG-4 AVC codec -
> Copyleft
> 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3
> deblock=1
> :0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1
> me_rang
> e=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1
> chroma_qp_
> offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
> interla
> ced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
> b_adapt=1 b_bias
> =0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
> scenecut=40
> intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60
> qpmin=0 qpma
> x=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
> Output #0, mp4, to 'out.mp4':
>Metadata:
>  major_brand : isom
>  minor_version   : 512
>  compatible_brands: isomiso2avc1mp41
>  encoder : Lavf58.35.102
>  Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono,
> fltp, 69 k
> b/s (default)
>  Metadata:
>encoder : Lavc58.65.103 aac
>  Stream #0:1(und): Video: h264 (libx264) (avc1 / 0x31637661),
> yuv420p, 

[FFmpeg-user] Mix a video with an audio file

2020-01-19 Thread Michael Koch

Hello,

I've just found a problem that can be reproduced as follows:

Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when 
played.


ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y video.mp4


Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone 
at t=3s. The file is ok when played.


ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10 
-y audio.wav



Step 3: Combine both files into one video, and the audio sources shall 
be mixed:


ffmpeg -i video.mp4 -i audio.wav -filter_complex 
"[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4


The output video has the correct length 6s, but I don't understand why 
the 1kHz tone disappears after 4s and the last 2s are silence.


The console output is below.

Michael



F:\Test_Audio>c:\ffmpeg\ffmpeg -i video.mp4 -i audio.wav -filter_complex 
"[0:a][

1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
ffmpeg version git-2020-01-15-0dc0837 Copyright (c) 2000-2020 the FFmpeg 
develop

ers
  built with gcc 9.2.1 (GCC) 20200111
  configuration: --enable-gpl --enable-version3 --enable-sdl2 
--enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d 
--enable-libb
luray --enable-libfreetype --enable-libmp3lame 
--enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus 
--enable-libshine --e
nable-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 --enab
le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc 
--enable-libmysofa --en
able-libspeex --enable-libxvid --enable-libaom --enable-libmfx 
--enable-ffnvcode
c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec 
--enable-dxva2 -

-enable-avisynth --enable-libopenmpt --enable-amf
  libavutil  56. 38.100 / 56. 38.100
  libavcodec 58. 65.103 / 58. 65.103
  libavformat    58. 35.102 / 58. 35.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter 7. 71.100 /  7. 71.100
  libswscale  5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf58.35.102
  Duration: 00:00:06.02, start: 0.00, bitrate: 938 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 
640x480 [

SAR 1:1 DAR 4:3], 864 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
  handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 
mono, fltp,

 68 kb/s (default)
    Metadata:
  handler_name    : SoundHandler
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from 'audio.wav':
  Metadata:
    encoder : Lavf58.35.102
  Duration: 00:00:10.00, bitrate: 705 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 
mono, s16,

705 kb/s
Stream mapping:
  Stream #0:1 (aac) -> amix:input0 (graph 0)
  Stream #1:0 (pcm_s16le) -> amix:input1 (graph 0)
  amix (graph 0) -> Stream #0:0 (aac)
  Stream #0:0 -> #0:1 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 029d7540] using SAR=1/1
[libx264 @ 029d7540] using cpu capabilities: MMX2 SSE2Fast SSSE3 
SSE4.2

AVX FMA3 BMI2 AVX2
[libx264 @ 029d7540] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 029d7540] 264 - core 159 - H.264/MPEG-4 AVC codec - 
Copyleft
2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 
deblock=1
:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 
me_rang
e=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 
chroma_qp_
offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 
interla
ced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 
b_adapt=1 b_bias
=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 
scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 
qpmin=0 qpma

x=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf58.35.102
    Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, 
fltp, 69 k

b/s (default)
    Metadata:
  encoder : Lavc58.65.103 aac
    Stream #0:1(und): Video: h264 (libx264) (avc1 / 0x31637661), 
yuv420p, 640x48

0 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
  handler_name    : VideoHandler
  encoder : Lavc58.65.103 libx264
    Side data:
  cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  111 fps=0.0 q=28.0 size= 256kB time=00:00:02.36