I have a problem saving a streaming with ffmpeg.
The problem is that video is not in sync with audio.
The video comes 2-3 seconds before the audio.
I try by removing and editing options but nothing change, I make some research too and I try all solution described in this great answer posted here, but it didn't work for me.
I tried to download a chunk from playlist and I've got a .ts file with audio/video in sync.
If I play the streaming with VLC player I can hear the audio without video for some seconds, then the video appear and is in sync with audio.
ffplay play the same streaming correctly too: seems like there is the time information inside audio and video codec and can be played correctly in sync.
How can I ask ffmpeg to take audio and video in sync?
If you need ffmpeg or ffplay outputs I will post them.
Edit: as requested, I report the full ffmpeg output of a simple command to save stream output to file:
$ ffmpeg -i http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/master.m3u8?hdnts=st=1554271074~exp=1554271524~acl=/*~hmac=14df2434241f7fd52f5a6012094367180f8567a1a733f7ef9eeef3dc7b46ebb2 -c copy out.mp4
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-openssl --disable-lzma --enable-nonfree
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_2_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_2_av-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_1_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_1_av-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_2_a-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_2_a-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_2_av-b.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_1_av-b.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_2_a-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427138_2_a-b.ts?sd=10&rebase=on' for reading
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] decode_slice_header error
[h264 # 0x7ffdf0028200] no frame!
[NULL # 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] decode_slice_header error
[h264 # 0x7ffdf0028200] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[NULL # 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[h264 # 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] decode_slice_header error
[h264 # 0x7ffdf0028200] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[NULL # 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] decode_slice_header error
[h264 # 0x7ffdf0028200] no frame!
[NULL # 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[h264 # 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 # 0x7ffdf0028200] decode_slice_header error
[h264 # 0x7ffdf0028200] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
[NULL # 0x7ffdef028000] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 # 0x7ffdef02a400] decode_slice_header error
[h264 # 0x7ffdef02a400] no frame!
Input #0, hls,applehttp, from 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/master.m3u8?hdnts=st=1554271074~exp=1554271524~acl=/*~hmac=14df2434241f7fd52f5a6012094367180f8567a1a733f7ef9eeef3dc7b46ebb2':
Duration: N/A, start: 65871.264133, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 528000
Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 400x224, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
variant_bitrate : 528000
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 528000
Stream #0:2: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 528000
Program 1
Metadata:
variant_bitrate : 528000
Stream #0:3: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 400x224, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
variant_bitrate : 528000
Stream #0:4: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 528000
Stream #0:5: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 528000
Program 2
Metadata:
variant_bitrate : 1328000
Stream #0:6: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x404, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
variant_bitrate : 1328000
Stream #0:7: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 1328000
Stream #0:8: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 1328000
Program 3
Metadata:
variant_bitrate : 1328000
Stream #0:9: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x404, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
variant_bitrate : 1328000
Stream #0:10: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 1328000
Stream #0:11: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 1328000
Program 4
Metadata:
variant_bitrate : 128000
Stream #0:12: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 128000
Stream #0:13: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 128000
Program 5
Metadata:
variant_bitrate : 128000
Stream #0:14: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 128000
Stream #0:15: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 128000
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv), 720x404, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
Metadata:
variant_bitrate : 1328000
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 528000
Stream mapping:
Stream #0:6 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls,applehttp # 0x7ffdef800000] No longer receiving playlist 1rate=1167.5kbits/s speed=4.93x
[hls,applehttp # 0x7ffdef800000] No longer receiving playlist 5
[hls,applehttp # 0x7ffdef800000] No longer receiving playlist 3
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427139_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427139_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] No longer receiving playlist 4
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427140_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427140_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_1_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427141_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/index_2_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp # 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1#372883/segment155427141_2_av-p.ts?sd=10&rebase=on' for reading
[mp4 # 0x7ffdf0170600] Non-monotonous DTS in output stream 0:1; previous: 1440768, current: 1439744; changing to 1440769. This may result in incorrect timestamps in the output file.
(...)
Related
I have a .mp4 file generated with ffmpeg as follows.
ffmpeg -y -i video_extended.mp4 -itsoffset 00:00:04.00 -i output5-1.wav -map 0:0 -map 1:0 -c:v copy -c:a aac -ac 6 -ar 48000 -b:a 128k -async 1 mixed.mp4
Playing mixed.mp4 file with ffplay is fine and there is no impact to the sound quality. Below is the output I get from ffplay when using the command ffplay -i mixed.mp4
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
> 'mixed_h264_aac_512k_async_qp0_all_I.mp4': Metadata:
> major_brand : isom
> minor_version : 512
> compatible_brands: isomiso2avc1mp41
> encoder : Lavf58.76.100 Duration: 00:00:16.02, start: 0.000000, bitrate: 49136 kb/s Stream #0:0[0x1](und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv422p10le(progressive),
> 1920x1080, 65409 kb/s, 59.94 fps, 59.94 tbr, 11988 tbn (default)
> Metadata:
> handler_name : VideoHandler
> vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 71 kb/s (default)
> Metadata:
> handler_name : SoundHandler
> vendor_id : [0][0][0][0] Switch subtitle stream from #-1 to #-1 vq= 1606KB sq= 0B f=0/0
Then, I decode the mixed.mp4 file back to raw PCM using the following command.
ffmpeg -i mixed.mp4 -vn -acodec pcm_s16le -f s16le -ar 48000 -ac 6 raw_audio.pcm
However, this raw_audio.pcm contains a lot of noise and ffplay output shows the following output
[s16le # 0x7f7490000c80] Estimating duration from bitrate, this may be inaccurate
Input #0, s16le, from 'separated_audio_s16.pcm':
Duration: 00:00:16.02, bitrate: 4607 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 6 channels, s16, 4608 kb/s
[pcm_s16le # 0x7f749002b940] Multiple frames in a packet.
[pcm_s16le # 0x7f749002b940] Invalid PCM packet, data has size 8 but at least a size of 12 was expected
Last message repeated 32 times
[pcm_s16le # 0x7f749002b940] Invalid PCM packet, data has size 8 but at least a size of 12 was expected
Last message repeated 11 times
Switch subtitle stream from #-1 to #-1 vq= 0KB sq= 0B f=0/0
[pcm_s16le # 0x7f749002b940] Invalid PCM packet, data has size 8 but at least a size of 12 was expected
Last message repeated 11 times
[pcm_s16le # 0x7f749002b940] Invalid PCM packet, data has size 8 but at least a size of 12 was expected
Last message repeated 11 times
[pcm_s16le # 0x7f749002b940] Invalid PCM packet, data has size 8 but at least a size of 12 was expected
Can someone please explain the issue here? Note that the ffplay command that works correctly for mixed.mp4 shows fltp as the audio format, whereas when playing the raw_audio.pcm file, it is seen as s16.
Is this a resampling issue in ffmpeg, and how can I rectify this?
I’m using ffmpeg and ffplay versions 5.0.1 in a Fedora 36 system.
Thank you.
I'm trying to implement a video converting solution on AWS Lambda following their article named Processing user-generated content using AWS Lambda and FFmpeg.
However when I run my command with subprocess.Popen() it returns -11 which translates to SIGSEGV (segmentation fault).
I've tried to process the video with the newest (4.3.1) static build from John Van Sickle's site as with the "official" ffmpeg-lambda-layer but it seems like it doesn't matter which one I use, the result is the same.
If I download the video to the Lambda's /tmp directory and add this downloaded file as an input to FFmpeg it works correctly (with the same parameters). However I'm trying to prevent this as the /tmp directory's max. size is only 512 MB which is not quite enough for me.
The relevant code which returns SIGSEGV:
ffmpeg_cmd = '/opt/bin/ffmpeg -stream_loop -1 -i "' + s3_source_signed_url + '" -i /opt/bin/audio.mp3 -i /opt/bin/watermark.png -shortest -y -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 30 -g 60 -b:v 4500k -c:a copy -map 0:v:0 -map 1:a:0 -filter_complex scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,overlay=(W-w)/2:(H-h)/2,format=yuv420p -loglevel verbose -f flv -'
command1 = shlex.split(ffmpeg_cmd)
p1 = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p1.communicate()
print(p1.returncode) #prints -11
stderr of FFmpeg:
ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzvbi --enable-libzimg
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
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[tcp # 0x728cc00] Starting connection attempt to 52.219.74.177 port 443
[tcp # 0x728cc00] Successfully connected to 52.219.74.177 port 443
[h264 # 0x729b780] Reinit context to 1280x720, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://bucket.s3.amazonaws.com --> presigned url with 15 min expiration time':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2015-09-02T07:42:42.000000Z
Duration: 00:00:15.64, start: 0.000000, bitrate: 2640 kb/s
Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, left), 1280x720 [SAR 1:1 DAR 16:9], 2475 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2015-09-02T07:42:42.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
creation_time : 2015-09-02T07:42:42.000000Z
handler_name : L-SMASH Audio Handler
[mp3 # 0x733f340] Skipping 0 bytes of junk at 1344.
Input #1, mp3, from '/opt/bin/audio.mp3':
Metadata:
encoded_by : Logic Pro X
date : 2021-01-03
coding_history :
time_reference : 158760000
umid : 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004500F9E4
encoder : Lavf58.49.100
Duration: 00:04:01.21, start: 0.025057, bitrate: 320 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavc58.97
Input #2, png_pipe, from '/opt/bin/watermark.png':
Duration: N/A, bitrate: N/A
Stream #2:0: Video: png, 1 reference frame, rgba(pc), 701x190 [SAR 1521:1521 DAR 701:190], 25 tbr, 25 tbn, 25 tbc
[Parsed_scale_0 # 0x7341140] w:1920 h:1080 flags:'bilinear' interl:0
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #2:0 (png) -> overlay:overlay
format -> Stream #0:0 (libx264)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264 # 0x72d8600] Reinit context to 1280x720, pix_fmt: yuv420p
[Parsed_scale_0 # 0x733c1c0] w:1920 h:1080 flags:'bilinear' interl:0
[graph 0 input from stream 0:0 # 0x7669200] w:1280 h:720 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[graph 0 input from stream 2:0 # 0x766a980] w:701 h:190 pixfmt:rgba tb:1/25 fr:25/1 sar:1521/1521 sws_param:flags=2
[auto_scaler_0 # 0x7670240] w:iw h:ih flags:'bilinear' interl:0
[deinterlace_in_2_0 # 0x766b680] auto-inserting filter 'auto_scaler_0' between the filter 'graph 0 input from stream 2:0' and the filter 'deinterlace_in_2_0'
[Parsed_scale_0 # 0x733c1c0] w:1280 h:720 fmt:yuv420p sar:1/1 -> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x2
[Parsed_pad_1 # 0x733ce00] w:1920 h:1080 -> w:1920 h:1080 x:0 y:0 color:0x000000FF
[Parsed_setsar_2 # 0x733da00] w:1920 h:1080 sar:1/1 dar:16/9 -> sar:1/1 dar:16/9
[auto_scaler_0 # 0x7670240] w:701 h:190 fmt:rgba sar:1521/1521 -> w:701 h:190 fmt:yuva420p sar:1/1 flags:0x2
[Parsed_overlay_3 # 0x733e440] main w:1920 h:1080 fmt:yuv420p overlay w:701 h:190 fmt:yuva420p
[Parsed_overlay_3 # 0x733e440] [framesync # 0x733e5a8] Selected 1/50 time base
[Parsed_overlay_3 # 0x733e440] [framesync # 0x733e5a8] Sync level 2
[libx264 # 0x72c1c00] using SAR=1/1
[libx264 # 0x72c1c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x72c1c00] profile Progressive High, level 4.0, 4:2:0, 8-bit
[libx264 # 0x72c1c00] 264 - core 157 r2969 d4099dd - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=9 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=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=1 keyint=60 keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=4500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'pipe:':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264), 1 reference frame ([7][0][0][0] / 0x0007), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 4500 kb/s, 30 fps, 1k tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/4500000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavc58.97
frame= 27 fps=0.0 q=32.0 size= 247kB time=00:00:00.03 bitrate=59500.0kbits/s speed=0.0672x
frame= 77 fps= 77 q=27.0 size= 1115kB time=00:00:02.03 bitrate=4478.0kbits/s speed=2.03x
frame= 126 fps= 83 q=25.0 size= 2302kB time=00:00:04.00 bitrate=4712.4kbits/s speed=2.64x
frame= 177 fps= 87 q=26.0 size= 3576kB time=00:00:06.03 bitrate=4854.4kbits/s speed=2.97x
frame= 225 fps= 88 q=25.0 size= 4910kB time=00:00:07.96 bitrate=5047.8kbits/s speed=3.13x
frame= 272 fps= 89 q=27.0 size= 6189kB time=00:00:09.84 bitrate=5147.9kbits/s speed=3.22x
frame= 320 fps= 90 q=27.0 size= 7058kB time=00:00:11.78 bitrate=4907.5kbits/s speed=3.31x
frame= 372 fps= 91 q=26.0 size= 8098kB time=00:00:13.84 bitrate=4791.0kbits/s speed=3.4x
And that's the end of it. It should continue to do the processing until 00:04:02 as that's my audio's length but it stops here every time (approximately this is my video length).
The relevant code which works correctly:
ffmpeg_cmd = '/opt/bin/ffmpeg -stream_loop -1 -i "' + '/tmp/' + s3_source_key + '" -i /opt/bin/audio.mp3 -i /opt/bin/watermark.png -shortest -y -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 30 -g 60 -b:v 4500k -c:a copy -map 0:v:0 -map 1:a:0 -filter_complex scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,overlay=(W-w)/2:(H-h)/2,format=yuv420p -loglevel verbose -f flv -'
command1 = shlex.split(ffmpeg_cmd)
p1 = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p1.communicate()
print(p1.returncode) #prints 0
With this code it repeats the video as many times as it has to do to be as long as the audio.
Both versions work correctly on my computer.
This question is almost the same but in my case FFmpeg is able to access the signed URL.
I have video file (.avi) that contain video of 10 minutes.
I also have audio file (.wav) that contain 1 minute of sound.
I need to add the audio to the exist video but the audio need to start at after one minute of the video
How to do it ?
( prefer using ffmpeg if its possible )
try already this query ( 30 seconds delay )
-i video.avi -i audio.wav -filter_complex \"[1]adelay=30000|30000[aud];[0][aud]amix\" - c:v copy out.avi"
Attached the log of ffmpeg when trying to merge more then one wav:
ffmpeg started on 2018-01-10 at 11:14:57
Report written to "ffmpeg-20180110-111457.log"
Command line:
ffmpeg.exe -report -i "..\\merged.avi" -i "Storage\\1.wav" -i "Storage\\2.wav" -i "Storage\\3.wav" -filter_complex "adelay=30000|30000" "adelay=91000|91000" "adelay=151000|151000" -c:v copy "Storage\\ALL.AVI"
ffmpeg version 3.4.1 Copyright (c) 2000-2017 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-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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input url with argument '..\mergedVideoOnly.avi'.
Reading option '-i' ... matched as input url with argument '\Storage\0030_0130.wav'.
Reading option '-i' ... matched as input url with argument '\Storage\0130_0230.wav'.
Reading option '-i' ... matched as input url with argument '\Storage\0230_0330.wav'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument 'adelay=30000|30000'.
Reading option 'adelay=91000|91000' ... matched as output url.
Reading option 'adelay=151000|151000' ... matched as output url.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'ALL.AVI' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option filter_complex (create a complex filtergraph) with argument adelay=30000|30000.
Successfully parsed a group of options.
Parsing a group of options: input url ..\mergedVideoOnly.avi.
Successfully parsed a group of options.
Opening an input file: ..\mergedVideoOnly.avi.
[NULL # 042ed360] Opening '..\mergedVideoOnly.avi' for reading
[file # 042ee300] Setting default whitelist 'file,crypto'
[avi # 042ed360] Format avi probed with size=2048 and score=100
[avi # 042ee500] use odml:1
[avi # 042ed360] Before avformat_find_stream_info() pos: 5690 bytes read:100744 seeks:4 nb_streams:1
[avi # 042ed360] parser not found for codec scpr, packets or times may be invalid.
[avi # 042ed360] parser not found for codec scpr, packets or times may be invalid.
[avi # 042ed360] max_analyze_duration 5000000 reached at 5000000 microseconds st:0
[avi # 042ed360] rfps: 2.916667 0.012539
[avi # 042ed360] rfps: 2.916667 0.012539
[avi # 042ed360] rfps: 3.000000 0.000000
[avi # 042ed360] rfps: 3.083333 0.012539
[avi # 042ed360] rfps: 3.083333 0.012539
[avi # 042ed360] rfps: 5.916667 0.012539
[avi # 042ed360] rfps: 5.916667 0.012539
[avi # 042ed360] rfps: 6.000000 0.000000
[avi # 042ed360] rfps: 6.000000 0.000000
[avi # 042ed360] rfps: 6.083333 0.012539
[avi # 042ed360] rfps: 6.083333 0.012539
[avi # 042ed360] rfps: 8.916667 0.012539
[avi # 042ed360] rfps: 8.916667 0.012539
[avi # 042ed360] rfps: 9.000000 0.000000
[avi # 042ed360] rfps: 9.083333 0.012539
[avi # 042ed360] rfps: 9.083333 0.012539
[avi # 042ed360] rfps: 11.916667 0.012539
[avi # 042ed360] rfps: 11.916667 0.012539
[avi # 042ed360] rfps: 12.000000 0.000000
[avi # 042ed360] rfps: 12.000000 0.000000
[avi # 042ed360] rfps: 12.083333 0.012539
[avi # 042ed360] rfps: 12.083333 0.012539
[avi # 042ed360] rfps: 14.916667 0.012539
[avi # 042ed360] rfps: 14.916667 0.012539
[avi # 042ed360] rfps: 15.000000 0.000000
[avi # 042ed360] rfps: 15.083333 0.012539
[avi # 042ed360] rfps: 15.083333 0.012539
[avi # 042ed360] rfps: 17.916667 0.012539
[avi # 042ed360] rfps: 17.916667 0.012539
[avi # 042ed360] rfps: 18.000000 0.000000
[avi # 042ed360] rfps: 18.000000 -0.000000
[avi # 042ed360] rfps: 18.083333 0.012539
[avi # 042ed360] rfps: 18.083333 0.012539
[avi # 042ed360] rfps: 20.916667 0.012539
[avi # 042ed360] rfps: 20.916667 0.012539
[avi # 042ed360] rfps: 21.000000 0.000000
[avi # 042ed360] rfps: 21.083333 0.012539
[avi # 042ed360] rfps: 21.083333 0.012539
[avi # 042ed360] rfps: 23.916667 0.012539
[avi # 042ed360] rfps: 23.916667 0.012539
[avi # 042ed360] rfps: 24.000000 0.000000
[avi # 042ed360] rfps: 24.000000 -0.000000
[avi # 042ed360] rfps: 24.083333 0.012539
[avi # 042ed360] rfps: 24.083333 0.012539
[avi # 042ed360] rfps: 26.916667 0.012539
[avi # 042ed360] rfps: 26.916667 0.012539
[avi # 042ed360] rfps: 27.000000 0.000000
[avi # 042ed360] rfps: 27.083333 0.012539
[avi # 042ed360] rfps: 27.083333 0.012539
[avi # 042ed360] rfps: 29.916667 0.012539
[avi # 042ed360] rfps: 29.916667 0.012539
[avi # 042ed360] rfps: 30.000000 0.000000
[avi # 042ed360] rfps: 30.000000 -0.000000
[avi # 042ed360] rfps: 33.000000 0.000000
[avi # 042ed360] rfps: 36.000000 0.000000
[avi # 042ed360] rfps: 36.000000 -0.000000
[avi # 042ed360] rfps: 39.000000 0.000000
[avi # 042ed360] rfps: 42.000000 0.000000
[avi # 042ed360] rfps: 42.000000 0.000000
[avi # 042ed360] rfps: 45.000000 0.000000
[avi # 042ed360] rfps: 48.000000 0.000000
[avi # 042ed360] rfps: 48.000000 0.000000
[avi # 042ed360] rfps: 51.000000 0.000000
[avi # 042ed360] rfps: 54.000000 0.000000
[avi # 042ed360] rfps: 54.000000 -0.000000
[avi # 042ed360] rfps: 57.000000 0.000000
[avi # 042ed360] rfps: 60.000000 0.000000
[avi # 042ed360] rfps: 60.000000 0.000000
[avi # 042ed360] rfps: 120.000000 0.000000
[avi # 042ed360] rfps: 120.000000 -0.000000
[avi # 042ed360] rfps: 240.000000 0.000000
[avi # 042ed360] rfps: 240.000000 -0.000000
[avi # 042ed360] rfps: 23.976024 0.001038
[avi # 042ed360] rfps: 23.976024 0.001038
[avi # 042ed360] rfps: 29.970030 0.001622
[avi # 042ed360] rfps: 29.970030 0.001622
[avi # 042ed360] rfps: 59.940060 0.006487
[avi # 042ed360] rfps: 59.940060 0.006487
[avi # 042ed360] rfps: 11.988012 0.000259
[avi # 042ed360] rfps: 11.988012 0.000259
[avi # 042ed360] rfps: 14.985015 0.000405
[avi # 042ed360] rfps: 14.985015 0.000405
[avi # 042ed360] rfps: 47.952048 0.004152
[avi # 042ed360] rfps: 47.952048 0.004152
[avi # 042ed360] After avformat_find_stream_info() pos: 105829 bytes read:175139 seeks:4 frames:15
Input #0, avi, from '..\mergedVideoOnly.avi':
Metadata:
encoder : Lavf57.83.100
Duration: 00:00:25.33, start: 0.000000, bitrate: 113 kb/s
Stream #0:0, 15, 1/3: Video: scpr (SCPR / 0x52504353), rgb0, 1920x1200, 112 kb/s, 3 fps, 3 tbr, 3 tbn, 3 tbc
Successfully opened the file.
Parsing a group of options: input url " "\Storage\0030_0130.wav.
Successfully parsed a group of options.
Opening an input file: " "\Storage\1.wav.
[NULL # 03be0180] Opening '" "\Storage\1.wav' for reading
[file # 03be0820] Setting default whitelist 'file,crypto'
[wav # 03be0180] Format wav probed with size=2048 and score=99
[wav # 03be0180] Before avformat_find_stream_info() pos: 44 bytes read:65580 seeks:1 nb_streams:1
[wav # 03be0180] probing stream 0 pp:32
[wav # 03be0180] probing stream 0 pp:31
[wav # 03be0180] probing stream 0 pp:30
[wav # 03be0180] probing stream 0 pp:29
[wav # 03be0180] probing stream 0 pp:28
[wav # 03be0180] probing stream 0 pp:27
[wav # 03be0180] probing stream 0 pp:26
[wav # 03be0180] probing stream 0 pp:25
[wav # 03be0180] probing stream 0 pp:24
[wav # 03be0180] probing stream 0 pp:23
[wav # 03be0180] probing stream 0 pp:22
[wav # 03be0180] probing stream 0 pp:21
[wav # 03be0180] probing stream 0 pp:20
[wav # 03be0180] probing stream 0 pp:19
[wav # 03be0180] probing stream 0 pp:18
[wav # 03be0180] probing stream 0 pp:17
[wav # 03be0180] probing stream 0 pp:16
[wav # 03be0180] probing stream 0 pp:15
[wav # 03be0180] probing stream 0 pp:14
[wav # 03be0180] probing stream 0 pp:13
[wav # 03be0180] probing stream 0 pp:12
[wav # 03be0180] probing stream 0 pp:11
[wav # 03be0180] probing stream 0 pp:10
[wav # 03be0180] probing stream 0 pp:9
[wav # 03be0180] probing stream 0 pp:8
[wav # 03be0180] probing stream 0 pp:7
[wav # 03be0180] probing stream 0 pp:6
[wav # 03be0180] probing stream 0 pp:5
[wav # 03be0180] probing stream 0 pp:4
[wav # 03be0180] probing stream 0 pp:3
[wav # 03be0180] probing stream 0 pp:2
[wav # 03be0180] probing stream 0 pp:1
[wav # 03be0180] probed stream 0
[wav # 03be0180] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav # 03be0180] max_analyze_duration 5000000 reached at 5120000 microseconds st:0
[wav # 03be0180] After avformat_find_stream_info() pos: 131116 bytes read:196652 seeks:1 frames:22
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from '" "\Storage\0030_0130.wav':
Duration: 00:00:56.80, bitrate: 128 kb/s
Stream #1:0, 22, 1/8000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
Successfully opened the file.
Parsing a group of options: input url " "\Storage\2.wav.
Successfully parsed a group of options.
Opening an input file: " "\Storage\2.wav.
[NULL # 03bed760] Opening '" "\Storage\2.wav' for reading
[file # 03bb3100] Setting default whitelist 'file,crypto'
[wav # 03bed760] Format wav probed with size=2048 and score=99
[wav # 03bed760] Before avformat_find_stream_info() pos: 44 bytes read:65580 seeks:1 nb_streams:1
[wav # 03bed760] probing stream 0 pp:32
[wav # 03bed760] probing stream 0 pp:31
[wav # 03bed760] probing stream 0 pp:30
[wav # 03bed760] probing stream 0 pp:29
[wav # 03bed760] probing stream 0 pp:28
[wav # 03bed760] probing stream 0 pp:27
[wav # 03bed760] probing stream 0 pp:26
[wav # 03bed760] probing stream 0 pp:25
[wav # 03bed760] probing stream 0 pp:24
[wav # 03bed760] probing stream 0 pp:23
[wav # 03bed760] probing stream 0 pp:22
[wav # 03bed760] probing stream 0 pp:21
[wav # 03bed760] probing stream 0 pp:20
[wav # 03bed760] probing stream 0 pp:19
[wav # 03bed760] probing stream 0 pp:18
[wav # 03bed760] probing stream 0 pp:17
[wav # 03bed760] probing stream 0 pp:16
[wav # 03bed760] probing stream 0 pp:15
[wav # 03bed760] probing stream 0 pp:14
[wav # 03bed760] probing stream 0 pp:13
[wav # 03bed760] probing stream 0 pp:12
[wav # 03bed760] probing stream 0 pp:11
[wav # 03bed760] probing stream 0 pp:10
[wav # 03bed760] probing stream 0 pp:9
[wav # 03bed760] probing stream 0 pp:8
[wav # 03bed760] probing stream 0 pp:7
[wav # 03bed760] probing stream 0 pp:6
[wav # 03bed760] probing stream 0 pp:5
[wav # 03bed760] probing stream 0 pp:4
[wav # 03bed760] probing stream 0 pp:3
[wav # 03bed760] probing stream 0 pp:2
[wav # 03bed760] probing stream 0 pp:1
[wav # 03bed760] probed stream 0
[wav # 03bed760] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav # 03bed760] max_analyze_duration 5000000 reached at 5120000 microseconds st:0
[wav # 03bed760] After avformat_find_stream_info() pos: 131116 bytes read:196652 seeks:1 frames:22
Guessed Channel Layout for Input Stream #2.0 : mono
Input #2, wav, from '" "\Storage\0130_0230.wav':
Duration: 00:00:59.81, bitrate: 128 kb/s
Stream #2:0, 22, 1/8000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
Successfully opened the file.
Parsing a group of options: input url " "\Storage\3.wav.
Successfully parsed a group of options.
Opening an input file: " "\Storage\3.wav.
[NULL # 03bfeea0] Opening '" "\Storage\3.wav' for reading
[file # 03bfe8e0] Setting default whitelist 'file,crypto'
[wav # 03bfeea0] Format wav probed with size=2048 and score=99
[wav # 03bfeea0] Before avformat_find_stream_info() pos: 44 bytes read:65580 seeks:1 nb_streams:1
[wav # 03bfeea0] probing stream 0 pp:32
[wav # 03bfeea0] probing stream 0 pp:31
[wav # 03bfeea0] probing stream 0 pp:30
[wav # 03bfeea0] probing stream 0 pp:29
[wav # 03bfeea0] probing stream 0 pp:28
[wav # 03bfeea0] probing stream 0 pp:27
[wav # 03bfeea0] probing stream 0 pp:26
[wav # 03bfeea0] probing stream 0 pp:25
[wav # 03bfeea0] probing stream 0 pp:24
[wav # 03bfeea0] probing stream 0 pp:23
[wav # 03bfeea0] probing stream 0 pp:22
[wav # 03bfeea0] probing stream 0 pp:21
[wav # 03bfeea0] probing stream 0 pp:20
[wav # 03bfeea0] probing stream 0 pp:19
[wav # 03bfeea0] probing stream 0 pp:18
[wav # 03bfeea0] probing stream 0 pp:17
[wav # 03bfeea0] probing stream 0 pp:16
[wav # 03bfeea0] probing stream 0 pp:15
[wav # 03bfeea0] probing stream 0 pp:14
[wav # 03bfeea0] probing stream 0 pp:13
[wav # 03bfeea0] probing stream 0 pp:12
[wav # 03bfeea0] probing stream 0 pp:11
[wav # 03bfeea0] probing stream 0 pp:10
[wav # 03bfeea0] probing stream 0 pp:9
[wav # 03bfeea0] probing stream 0 pp:8
[wav # 03bfeea0] probing stream 0 pp:7
[wav # 03bfeea0] probing stream 0 pp:6
[wav # 03bfeea0] probing stream 0 pp:5
[wav # 03bfeea0] probing stream 0 pp:4
[wav # 03bfeea0] probing stream 0 pp:3
[wav # 03bfeea0] probing stream 0 pp:2
[wav # 03bfeea0] probing stream 0 pp:1
[wav # 03bfeea0] probed stream 0
[wav # 03bfeea0] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav # 03bfeea0] max_analyze_duration 5000000 reached at 5120000 microseconds st:0
[wav # 03bfeea0] After avformat_find_stream_info() pos: 131116 bytes read:196652 seeks:1 frames:22
Guessed Channel Layout for Input Stream #3.0 : mono
Input #3, wav, from '" "\Storage\0230_0330.wav':
Duration: 00:00:59.81, bitrate: 128 kb/s
Stream #3:0, 22, 1/8000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
Successfully opened the file.
detected 4 logical cores
[Parsed_adelay_0 # 03c0c460] Setting 'delays' to value '30000|30000'
Parsing a group of options: output url adelay=91000|91000.
Successfully parsed a group of options.
Opening an output file: adelay=91000|91000.
[NULL # 03c17640] Unable to find a suitable output format for 'adelay=91000|91000'
adelay=91000|91000: Invalid argument
[AVIOContext # 042ee400] Statistics: 175139 bytes read, 4 seeks
[AVIOContext # 03be0900] Statistics: 196652 bytes read, 1 seeks
[AVIOContext # 03bca7e0] Statistics: 196652 bytes read, 1 seeks
[AVIOContext # 03bfe9a0] Statistics: 196652 bytes read, 1 seeks
Use
ffmpeg -i in.avi -i audio.wav -filter_complex
"[1]adelay=62000|62000[aud];[0][aud]amix" -c:v copy out.avi
The adelay delays the start of the WAV by 62000 milliseconds for all channels, assuming 2 channels in the WAV and then that is mixed with the video's audio.
To mix two audio files,
ffmpeg -i in.avi -i audio1.wav -i audio2.wav -filter_complex
"[1]adelay=30000|30000[aud1];[2]adelay=90000|90000[aud2];
[0][aud1][aud2]amix=3" -c:v copy out.avi
Here's how, let's see if they change the code and don't invest in companies that pay employees that would build it all.
ffmpeg -y -i video.mp4 -i 002.ogg.mp3 -i 003.ogg.mp3 -i 004.ogg.mp3 -filter_complex "[1]adelay=1000[s1];[2]adelay=2500[s2];[3]adelay=4000[s3];[s1][s2][s3]amix=3[a]" -map 0:v -map "[a]" -preset ultrafast video_with_audio.mp4
It's easy to figure out, filter_complex accepts commands as arguments sequentially and assigns variable names that can be used later in the series with the last being the command that mixes everything.
I am using the following command to convert a mp4 on my server to webm as part of a Node.js script.
var command = execSync('ffmpeg -i '+video+' -vpre libvpx-720p -cpu-used -5 -deadline realtime -b 3900k -an -f webm -y '+saveTo);
When running the command in a regular terminal, it works fine. However, when running it as above using the execSync() node package, I get the following console output.
Error: ffmpeg version 1.0.8 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 27 2014 17:09:06 with gcc 4.7.3 (Gentoo 4.7.3-r1 p1.3, pie-0.5.5)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-
g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cxxflags
='-O2 -pipe -march=native -fomit-frame-pointer' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-avresample --disable-stripp
ing --disable-debug --disable-doc --disable-vaapi --disable-vdpau --disable-ffplay --disable-runtime-cpudetect --enable-libmp3lame --enable-libvo-aacenc --enable-libthe
ora --enable-libfdk-aac --enable-nonfree --disable-indev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss -
-disable-outdev=sdl --enable-libvorbis --enable-libvpx --disable-amd3dnow --disable-amd3dnowext --disable-altivec --disable-avx --disable-mmxext --disable-ssse3 --disab
le-vis --disabl libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/video/input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2013-08-24 21:58:35
encoder : HandBrake 0.9.9 2013051800
Duration: 00:06:31.46, start: 0.000000, bitrate: 5092 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4919 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
creation_time : 2013-08-24 21:58:35
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 168 kb/s
Metadata:
creation_time : 2013-08-24 21:58:35
Please use -b:a or -b:v, -b is ambiguous
[libvpx # 0x7f0c40] v1.3.0
Output #0, webm, to '/path/to/video/output.webm':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
encoder : Lavf54.29.104
Stream #0:0(und): Video: vp8, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=11-51, 3900 kb/s, 1k tbn, 25 tbc
encoder : Lavf54.29.104 [4009/9202]
Stream #0:0(und): Video: vp8, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=11-51, 3900 kb/s, 1k tbn, 25 tbc
Metadata:
creation_time : 2013-08-24 21:58:35
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libvpx)
Press [q] to stop, [?] for help
[h264 # 0x8f42a0] AVC: nal size 3235393
Last message repeated 1 times
[h264 # 0x8f42a0] no frame!
[h264 # 0x7be7e0] concealing 7123 DC, 7123 AC, 7123 MV errors in P frame
[h264 # 0x8f46c0] AVC: nal size 2572289
Last message repeated 1 times
[h264 # 0x8f46c0] no frame!
[h264 # 0x8f4ae0] AVC: nal size 11559745
Last message repeated 1 times
[h264 # 0x8f4ae0] no frame!
[h264 # 0x8f4f00] AVC: nal size 781975966
Last message repeated 1 times
[h264 # 0x8f4f00] no frame!
[h264 # 0x7be7e0] AVC: nal size -1537130086
Last message repeated 1 times
[h264 # 0x7be7e0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x8f42a0] AVC: nal size -1303101030
Last message repeated 1 times
[h264 # 0x8f42a0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x8f46c0] AVC: nal size 833290655
Last message repeated 1 times
[h264 # 0x8f46c0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x8f4ae0] AVC: nal size -816365157
Last message repeated 1 times
[h264 # 0x8f4ae0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x8f4f00] AVC: nal size 776798623
Last message repeated 1 times
[h264 # 0x8f4f00] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x7be7e0] AVC: nal size -824622693
Last message repeated 1 times
[h264 # 0x7be7e0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 # 0x8f42a0] AVC: nal size 1276789151
Error while decoding stream #0:0: Operation not permitted
frame= 4 fps=0.0 q=0.0 Lsize= 107kB time=00:00:00.16 bitrate=5476.5kbits/s
video:106kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.473334%
Received signal 2: terminating.
The 'no frame' bits repeat several thousand times before it reaches the final section.
Could someone tell me what's wrong?
Thanks for any help
I am trying to capture webcam output in linux/ubuntu. I have a chicony webcam (lenovo laptop). I am running inside a VMWARE virtual machine. The capture is not proceeding beyond 10 seconds. can you please help.
The command I used is:
$ ffmpeg -y -f video4linux2 -r 20 -s 160x120 -i /dev/video0 -acodec libfaac -ab 128k /tmp/web.avi
The most important message I am getting is:
[video4linux2,v4l2 # 0x9e43fa0] The v4l2 frame is 46448 bytes, but 153600 bytes are expected
Complete message from ffmpeg:
ffmpeg version N-55159-gf118b41 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 18 2013 09:09:13 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-libass --prefix=/opt/ffmpeg --enable-debug --enable-libfreetype
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 82.100 / 3. 82.100
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
[video4linux2,v4l2 # 0x9e43fa0] The V4L2 driver changed the video from 160x120 to 320x240
[video4linux2,v4l2 # 0x9e43fa0] The driver changed the time per frame from 1/20 to 1/15
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 6424.338678, bitrate: 18432 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 18432 kb/s, 15 fps, 15 tbr, 1000k tbn, 1000k tbc
Codec AVOption ab (set bitrate (in bits/s)) specified for output file #0 (/tmp/web.avi) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Output #0, avi, to '/tmp/web.avi':
Metadata:
ISFT : Lavf55.12.102
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 320x240, q=2-31, 200 kb/s, 20 tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> mpeg4)
Press [q] to stop, [?] for help
[video4linux2,v4l2 # 0x9e43fa0] The v4l2 frame is 46448 bytes, but 153600 bytes are expected
/dev/video0: Invalid data found when processing input
frame= 29 fps= 14 q=3.5 Lsize= 87kB time=00:00:01.45 bitrate= 490.0kbits/s
video:80kB audio:0kB subtitle:0 global headers:0kB muxing overhead 7.760075%
[video4linux2,v4l2 # 0x9e43fa0] Some buffers are still owned by the caller on close.