how to add audio to existing video using FFMPEG at specific time? - audio

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.

Related

More precision from ffmpeg silencedetect

I am trying to split a very large (70 hours) mp3 file into smaller files. My first step is the get the timestamps using the silencedetect command in ffmpeg. It works fine for the first few timestamps, but unfortunately, the results are rounded to six significant digits.
The code I am executing is:
ffmpeg -i input.mp3 -af silencedetect=d=3 -hide_banner -nostats -f null -
My results are:
Input #0, mp3, from 'input.mp3':
Duration: 70:46:05.32, start: 0.050113, bitrate: 64 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, stereo, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Audio: pcm_s16le, 22050 Hz, stereo, s16, 705 kb/s
Metadata:
encoder : Lavc58.54.100 pcm_s16le
[silencedetect # 0x5590d08bd700] silence_start: 10.6895
[silencedetect # 0x5590d08bd700] silence_end: 15.0054 | silence_duration: 4.31587
[silencedetect # 0x5590d08bd700] silence_start: 446.958
[silencedetect # 0x5590d08bd700] silence_end: 450.959 | silence_duration: 4.00168
[silencedetect # 0x5590d08bd700] silence_start: 1168.17
[silencedetect # 0x5590d08bd700] silence_end: 1172.17 | silence_duration: 4.00694
[silencedetect # 0x5590d08bd700] silence_start: 1880.8
[silencedetect # 0x5590d08bd700] silence_end: 1884.8 | silence_duration: 3.99265
...
[silencedetect # 0x5590d08bd700] silence_start: 123108
[silencedetect # 0x5590d08bd700] silence_end: 123111 | silence_duration: 3.61946
[silencedetect # 0x5590d08bd700] silence_start: 123286
[silencedetect # 0x5590d08bd700] silence_end: 123290 | silence_duration: 4.01646
[silencedetect # 0x5590d08bd700] silence_start: 124229
[silencedetect # 0x5590d08bd700] silence_end: 124233 | silence_duration: 4.01846
[silencedetect # 0x5590d08bd700] silence_start: 124442
[silencedetect # 0x5590d08bd700] silence_end: 124446 | silence_duration: 4.0298
...
Rounding to the nearest second is not sufficient for my purposes. Ideally, I would like each timestamp to be accurate to the hundredth of a second or something similar. Does anybody know a way to achieve this?
Append ametadata=print:file=- to the filterchain and parse stdout in your program. It provides the frame time in seconds, frames, and pts. Grab the time_base from ffprobe and you can compute accurate time.
If you're using Python, you can try the following with my ffmpegio package:
from ffmpegio import analyze as ffa, probe as ffp
from pprint import pprint
input = "BigBuckBunny.mp4"
tb = next(info for info in ffp.streams_basic(input)
if info["codec_type"] == "audio")["time_base"]
print(f'time_base = {tb} s')
# analyze first 5 minutes and return silent intervals in the first 5 minutes
(logger,) = ffa.run(input, ffa.SilenceDetect(d=1), time_units="pts", to=60 * 5)
pprint([(pts0 * tb, pts1 * tb) for pts0, pts1 in logger.output.interval])
returns the silent intervals in fractions
time_base = 1/44100 s
[(Fraction(947456, 11025), Fraction(958976, 11025)),
(Fraction(976384, 11025), Fraction(39680, 441)),
(Fraction(1018624, 11025), Fraction(146176, 1575))]
Unfortunately, this is hardcoded in FFmpeg:
static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
{
if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
return buf;
}
The relevant part is the %.6g... this is setting the formatting.
You'll have to submit a patch to get it changed.

Create HLS streamable audio file from mp3

I am using following command to create a hls aac audio file for web streaming
ffmpeg -y -i song.mp3 -c:a aac -b:a 128k -f hls -hls_time 7 -hls_list_size 0 -hls_segment_filename file%d.m4a playlist.m3u8
This command works only with some audio files. With many mp3 files I receive following output:
C:\ffmpeg>ffmpeg -y -i song.mp3 -c:a aac -b:a 128k -f hls -hls_time 7 -hls_list_size 0 -hls_segment_filename file%d.m4a playlist.m3u8
ffmpeg version git-2020-01-31-62d92a8 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --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-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --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. 67.100 / 58. 67.100
libavformat 58. 37.100 / 58. 37.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 72.100 / 7. 72.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[mp3 # 0000027d800babc0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'song.mp3':
Metadata:
TSS : Logic Pro 8.0.2
iTunNORM : 000000EE 000000ED 00000C34 00001135 000088F0 0000B505 000080FA 00007577 00009B82 00018F49
iTunSMPB : 00000000 00000210 00000A07 00000000008783E9 00000000 007AD4E6 00000000 00000000 00000000 00000000 00000000 00000000
genre : Rock
TCM : Kevin MacLeod
album : Funk and Blues
TKE : C
TBP : 101
title : Funkorama
artist : Kevin MacLeod
date : 2008-06-16 18:35
Duration: 00:03:21.46, start: 0.000000, bitrate: 325 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 400x400 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
comment : Other
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[hls # 0000027d80100c40] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 # 0000027d800c1280] using SAR=1/1
[libx264 # 0000027d800c1280] MB rate (56250000) > level limit (16711680)
[libx264 # 0000027d800c1280] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000027d800c1280] profile High 4:4:4 Predictive, level 6.2, 4:4:4, 8-bit
[libx264 # 0000027d800c1280] 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_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 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=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 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, hls, to 'playlist.m3u8':
Metadata:
TSS : Logic Pro 8.0.2
iTunNORM : 000000EE 000000ED 00000C34 00001135 000088F0 0000B505 000080FA 00007577 00009B82 00018F49
iTunSMPB : 00000000 00000210 00000A07 00000000008783E9 00000000 007AD4E6 00000000 00000000 00000000 00000000 00000000 00000000
genre : Rock
TCM : Kevin MacLeod
album : Funk and Blues
TKE : C
TBP : 101
title : Funkorama
artist : Kevin MacLeod
date : 2008-06-16 18:35
encoder : Lavf58.37.100
Stream #0:0: Video: h264 (libx264), yuvj444p(pc, progressive), 400x400 [SAR 72:72 DAR 1:1], q=-1--1, 90k fps, 90k tbn, 90k tbc (attached pic)
Metadata:
comment : Other
encoder : Lavc58.67.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.67.100 aac
[mp3float # 0000027d80146580] overread, skip -7 enddists: -6 -6 speed=68.6x
[mp3float # 0000027d80146580] overread, skip -6 enddists: -5 -5
[mp3float # 0000027d80146580] overread, skip -6 enddists: -4 -4
Last message repeated 2 times
[mp3float # 0000027d80146580] overread, skip -7 enddists: -6 -6
Last message repeated 2 times
[mp3float # 0000027d80146580] overread, skip -5 enddists: -2 -2
[mp3float # 0000027d80146580] overread, skip -7 enddists: -6 -6
[mp3float # 0000027d80146580] overread, skip -6 enddists: -4 -4
Last message repeated 1 times
[mp3float # 0000027d80146580] overread, skip -7 enddists: -6 -6
Last message repeated 1 times
[mp3float # 0000027d80146580] overread, skip -6 enddists: -4 -4
[mp3float # 0000027d80146580] overread, skip -5 enddists: -3 -3
[mp3float # 0000027d80146580] overread, skip -6 enddists: -4 -4
[mp3float # 0000027d80146580] overread, skip -7 enddists: -6 -6
Last message repeated 2 times
[mp3float # 0000027d80146580] overread, skip -5 enddists: -4 -4
[hls # 0000027d80100c40] Opening 'file0.m4a' for writingate=N/A speed=64.1x
[hls # 0000027d80100c40] Opening 'playlist.m3u8.tmp' for writing
frame= 1 fps=0.3 q=33.0 Lsize=N/A time=00:03:21.45 bitrate=N/A speed=63.7x
video:7kB audio:3209kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 # 0000027d800c1280] frame I:1 Avg QP:34.64 size: 6567
[libx264 # 0000027d800c1280] mb I I16..4: 19.5% 53.0% 27.5%
[libx264 # 0000027d800c1280] 8x8 transform intra:53.0%
[libx264 # 0000027d800c1280] coded y,u,v intra: 46.8% 26.1% 15.3%
[libx264 # 0000027d800c1280] i16 v,h,dc,p: 38% 39% 9% 14%
[libx264 # 0000027d800c1280] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 14% 26% 8% 5% 6% 5% 7% 7%
[libx264 # 0000027d800c1280] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 16% 14% 7% 4% 5% 3% 4% 4%
[libx264 # 0000027d800c1280] kb/s:4728240.00
[aac # 0000027d800bcc40] Qavg: 2138.508
Notice the "mp3float overread" message.
It results in a single file0.m4a file without splitting it up after every 7 seconds as specified.
This is an example audio file I am trying to convert to a aac hls stream that results the mentioned problem: https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100474
How can I convert an audio file to a web friendly hls stream with ffmpeg?
You are using the option -hls_list_size 0 which makes 1 container file.
I use -muxdelay 0 -f segment -sc_threshold 0 -segment_time 15 -segment_list "playlist.m3u8" -segment_format mpegts "file%d.ts" in all my HLS video encode commands.
To put this in a working command for you that would be:
ffmpeg -y -i "song.mp3" -c:a aac -b:a 128k -muxdelay 0 -f segment -sc_threshold 0 -segment_time 7 -segment_list "playlist.m3u8" -segment_format mpegts "file%d.m4a"

ffmpeg streaming video not in sync

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.
(...)

FFMPEG error while receiving rtsp stream

I got error with receiving rtsp stream from IPCam Edimax IC-3030 and I don't know what to do. Can anyone help me or show me a way to solution ?
/home/prog12# ffplay "rtsp://192.168.1.7/ipcam_h264.sdp"
ffplay version 2.1.4 Copyright (c) 2003-2014 the FFmpeg developers
built on Mar 22 2014 18:16:53 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable- libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable- libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied
[rtsp # 0xb0c006c0] UDP timeout, retrying with TCPsq= 0B f=0/0
[rtsp # 0xb0c006c0] method PAUSE failed: 501 Not Implemented
[rtsp # 0xb0c006c0] Could not find codec parameters for stream 0 (Video: h264): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://192.168.1.7/ipcam_h264.sdp':
Metadata:
title : IPCam
Duration: N/A, bitrate: 64 kb/s
Stream #0:0: Video: h264, 90k tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
SDL_OpenAudio (1 channels):
No more channel combinations to try, audio open failed
[rtsp # 0xb0c006c0] UDP timeout, retrying with TCPsq= 0B f=0/0
[rtsp # 0xb0c006c0] method PAUSE failed: 501 Not Implemented
[rtsp # 0xb0c006c0] UDP timeout, retrying with TCPsq= 0B f=0/0
[rtsp # 0xb0c006c0] method PAUSE failed: 501 Not Implementedf=0/0
[rtsp # 0xb0c006c0] UDP timeout, retrying with TCPsq= 0B f=0/0
[rtsp # 0xb0c006c0] method PAUSE failed: 501 Not Implemented
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
Thats the output.
EDIT
ps ax| grep -i pulse
8904 ? S<l 0:01 /usr/bin/pulseaudio --start --log-target=syslog
10369 pts/1 S+ 0:00 grep --color=auto -i pulse
And for new command :
sudo ffplay -video_size 640x480 "rtsp://192.168.1.7/ipcam_h264.sdp"
ffplay version 2.1.4 Copyright (c) 2003-2014 the FFmpeg developers
built on Mar 22 2014 18:16:53 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame
Option video_size not found.aq= 0KB vq= 0KB sq= 0B f=0/0
When you meet such error You should try to force ffmpeg to use only TCP connection - I believe that when switching from UDP to TCP ffmpeg tried to pause stream what may not be supported by IPCam like Edimax IC 3030 .
Here is pice of code:
AVDictionary *opts = 0;
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
avformat_open_input( &FormatContext, path.c_str(), NULL, &opts )

ffmpeg failing to convert

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

Resources