Create HLS streamable audio file from mp3 - audio

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"

Related

Using FFmpeg with URL input causes SIGSEGV in AWS Lambda (Python runtime)

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.

ffmpeg audio conversion: encoder pcm_u8 working pcm_s8 not

I need to convert audio inside video to 8 Bit signed PCM. I try it like this:
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -i minions.mp4 -vcodec mjpeg -s 800x480 -acodec pcm_s8 -ac 1 out.avi
output:
ffmpeg version N-81192-g04da20e Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.100 / 57. 51.100
libavformat 57. 44.100 / 57. 44.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 49.100 / 6. 49.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'minions.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-03-17 10:06:57
Duration: 00:03:18.72, start: 0.000000, bitrate: 1869 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1675 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default
)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
[swscaler # 04821880] deprecated pixel format used, make sure you did set range correctly
[avi # 048c0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'out.avi':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf57.44.100
Stream #0:0(und): Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 800x480 [SAR 16:15 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.51.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: pcm_s8, 44100 Hz, mono, u8, 352 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
encoder : Lavc57.51.100 pcm_s8
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Stream #0:1 -> #0:1 (aac (native) -> pcm_s8 (native))
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
ffmpeg can not write a header for output file. I want to mention that if audio encoder is selected to pcm_u8 everything works fine.
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -i minions.mp4 -vcodec mjpeg -s 800x480 -acodec pcm_u8 -ac 1 out.avi
output:
ffmpeg version N-81192-g04da20e Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.100 / 57. 51.100
libavformat 57. 44.100 / 57. 44.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 49.100 / 6. 49.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'minions.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-03-17 10:06:57
Duration: 00:03:18.72, start: 0.000000, bitrate: 1869 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1675 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default
)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
File 'out.avi' already exists. Overwrite ? [y/N] y
[swscaler # 030a1880] deprecated pixel format used, make sure you did set range correctly
[avi # 04a10460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'out.avi':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
ISFT : Lavf57.44.100
Stream #0:0(und): Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 800x480 [SAR 16:15 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.51.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: pcm_u8 ([1][0][0][0] / 0x0001), 44100 Hz, mono, u8, 352 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
encoder : Lavc57.51.100 pcm_u8
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Stream #0:1 -> #0:1 (aac (native) -> pcm_u8 (native))
Press [q] to stop, [?] for help
frame= 4764 fps=250 q=24.8 Lsize= 74247kB time=00:03:18.71 bitrate=3060.8kbits/s speed=10.4x
video:65364kB audio:8558kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.438745%
What is the problem ? Why conversion does not work for signed pcm ?
Encoders for both unsigned and signed pcm are avaible:
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -encoders
.
.
A..... pcm_f32be PCM 32-bit floating point big-endian
A..... pcm_f32le PCM 32-bit floating point little-endian
A..... pcm_f64be PCM 64-bit floating point big-endian
A..... pcm_f64le PCM 64-bit floating point little-endian
A..... pcm_mulaw PCM mu-law / G.711 mu-law
A..... pcm_s16be PCM signed 16-bit big-endian
A..... pcm_s16be_planar PCM signed 16-bit big-endian planar
A..... pcm_s16le PCM signed 16-bit little-endian
A..... pcm_s16le_planar PCM signed 16-bit little-endian planar
A..... pcm_s24be PCM signed 24-bit big-endian
A..... pcm_s24daud PCM D-Cinema audio signed 24-bit
A..... pcm_s24le PCM signed 24-bit little-endian
A..... pcm_s24le_planar PCM signed 24-bit little-endian planar
A..... pcm_s32be PCM signed 32-bit big-endian
A..... pcm_s32le PCM signed 32-bit little-endian
A..... pcm_s32le_planar PCM signed 32-bit little-endian planar
A..... pcm_s8 PCM signed 8-bit
A..... pcm_s8_planar PCM signed 8-bit planar
A..... pcm_u16be PCM unsigned 16-bit big-endian
A..... pcm_u16le PCM unsigned 16-bit little-endian
A..... pcm_u24be PCM unsigned 24-bit big-endian
A..... pcm_u24le PCM unsigned 24-bit little-endian
A..... pcm_u32be PCM unsigned 32-bit big-endian
A..... pcm_u32le PCM unsigned 32-bit little-endian
A..... pcm_u8 PCM unsigned 8-bit
.
.
Your error not about audio, it's about video:
[swscaler # 04821880] deprecated pixel format used, make sure you did set range correctly
[avi # 048c0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
I think you can try to set pixel format as it asking. it could solve it.
I want to mention that if audio encoder is selected to pcm_u8 everything works fine.
Please, place the command for this convertion and the output (averything before 'stream mapping' including it) in your qustion by editing it.
The RIFF function called by the AVI muxer does not support writing a tag for PCM_S8 streams, so apparently that's why you can't write it to AVIs or WAVs.
You can use MOV or NUT formats.
If you need to use AVI, you are left with S16LE, S24LE, S32LE, F32LE, F64LE and U8 variants of LPCM.
To encode using IMA ADPCM, use
ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a adpcm_ima_wav -ac 1 out.avi
To encode using mu-law PCM, use
ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a pcm_mulaw -ac 1 out.avi
My company is building a device using the FT810 and this is the conversion script I have come up with:
AUDIO_SAMPLE_RATE=8000
VIDEO_FRAME_RATE=8
VIDEO_Y_POS=266 # Place video in 2/3rds up from bottom of screen
ffmpeg -i source/audio.mp3 -r 65535/2733 -vn -c:a libmp3lame -ar $AUDIO_SAMPLE_RATE -ac 1 -ab 128k -y /tmp/resampled.mp3
ffmpeg -i source/video.gif \
-i /tmp/resampled.mp3 \
-filter:v scale=420:-2,pad=420:270+ih/2:0:270-ih/2:black \
-pix_fmt yuvj420p -vcodec mjpeg -acodec pcm_s16le -r:v $VIDEO_FRAME_RATE -b:v 0.1M -ac 1 -shortest -y output/startup.avi
Notice that I am using pcm_s16le, because the documentation says "16 Bit PCM is partially supported by dropping off less significant 8 bits in each
audio sample."

Make UDP-RTMP bridge with FFMPEG

I need to make this chain, using computer 2 as a "bridge" between Computer 1 and the streming server.
Computer 1 ----> Computer 2 ----> Streaming server (Wowza).
So I'm trying to set this:
Computer 1 --(via UDP)--> Computer 2 --(Via RTMP)--> Wowza
What I've tried:
1. At Computer 1
Entry:
ffmpeg -i sample.mp4 -c:v copy -c:a copy -f mpegts udp://192.168.0.109:5010
Result: Worked. Computer 1 sends the data correctly.
2. At Computer 2
Entry:
ffmpeg -i upd://192.168.0.109:5010 output.mp4
Result: Worked. Computer 2 gets data correctly. Output.mp4 is generated well.
Entry:
ffmpeg -i sample.mp4 -c:v copy -c:a copy -f flv rtmp://wowzaServerAddress
Result: Worked. Wowza shows online the video from sample.mp4
Entry:
ffmpeg -re -i udp://#:5010 -f flv rtmp://wowzaServerAddress
Result:
stuck at:
ffmpeg version N-77234-g906c0b7 Copyright (c) 2000-2015 the FFmpeg
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 10.100 / 55. 10.100
libavcodec 57. 17.100 / 57. 17.100
libavformat 57. 20.100 / 57. 20.100
libavdevice 57.0.100 / 57. 0.100
libavfilter 6.21.100 / 6. 21.100
libswscale 4.0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
**Entry:**
ffmpeg -i udp://192.168.0.109:5010 -c:v copy -c:a copy -f flv rtmp://wowzaServerAddress
**Result:**
*... repeated a lot ...*
Last message repeated 1 times
[h264 # 000001cef0462200] decode_slice_header error
[h264 # 000001cef0462200] no frame!
*... repeated a lot ...*
Input #0, mpegts, from 'udp://192.168.0.109:5010':
Duration: N/A, start: 128.032333, bitrate: N/A
Program 1
Metadata:
service_name: RARBG.COM - Spotlight.2015.1080p.WEB-DL.DD5.1.H264-RARBG
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(tv, bt709), 1916x1032 [SAR 1:1 DAR 479:258], 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 200 kb/s
[flv # 000001cef132a1c0] Codec for stream 0 does not use global headers but container format requires global headers
[flv # 000001cef132a1c0] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, flv, to '**rtmp://wowzaServerAddress**':
Metadata:
encoder: Lavf57.20.100
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1916x1032 [SAR
1:1 DAR 479:258], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 90k tbc
Stream #0:1(eng): Audio: aac ([10][0][0][0] / 0x000A), 48000 Hz, stereo,
200 kb/s
Stream mapping:
Stream #0:0 - #0:0 (copy)
Stream #0:1 - #0:1 (copy)
Press [q] to stop, [?] for help
[flv # 000001cef132a1c0] Malformed AAC bitstream detected: use the audio
bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[flv # 000001cef132a1c0] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
[flv # 000001cef132a1c0] Failed to update header with correct duration.
[flv # 000001cef132a1c0] Failed to update header with correct filesize.
Error writing trailer of rtmp://**wowzaServerAddress**: Invalid data found when processing inputframe= 1 fps=0.0 q=-1.0 Lsize= 0kB time= 00:00:02.13 bitrate= 1.6kbits/s
video:33kB audio:59kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

ffmpeg 1 image (JPG) + 1 audio file (MP3) = 1 video (WEBM) using real encode (-re)

I'd like to make video streaming to distribute it in a streaming.
The mp3 file is being extracted from a video file (which is being recorded live) and, while audio being extracted (MP3), I want to take this audio file and a image it and spread it in a real time streaming. But -re is not working for this.
To extract audio file i use:
ffmpeg.exe -re -i file(LIVE).AVI -vn -ar 22050 -ab 16k -r 1 -ac 1 -f mp3 C:\Users\" & wshNetwork.Username & "\Documents\audio.mp3"
This work very well to make the MP3 file. Using -re.
After that, I'm using this command to marge the auvio file with the jpg image:
ffmpeg.exe -loop 1 -f image2 -i c:\picture.jpg -re -i c:\Users\" & wshNetwork.Username & "\Documents\audio.mp3 -vb 10k -ar 22050 -ab 16k -ac 1 -r 1 -bufsize 300k -f webm www.adress.com
This second command is not working because the -re is not working, and produce a video with the picture and a choppy audio.
the output is:
ffmpeg version N-63113-g72dcd48 Copyright (c) 2000-2014 the FFmpeg developers
built on May 12 2014 22:10:08 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-decklink --enable-zlib
libavutil 52. 83.100 / 52. 83.100
libavcodec 55. 61.100 / 55. 61.100
libavformat 55. 37.102 / 55. 37.102
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 5.100 / 4. 5.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, image2, from 'c:\imagens\radiobb.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc), 553x342 [SAR 96:96 DAR 553:342], 25
fps, 25 tbr, 25 tbn, 25 tbc
[mp3 # 0000000002b8f660] Estimating duration from bitrate, this may be inaccurat
e
Input #1, mp3, from 'C:\Users\f3548956\Documents\audio.mp3':
Metadata:
encoder : Lavf55.37.102
Duration: 00:00:09.34, start: 0.050113, bitrate: 16 kb/s
Stream #1:0: Audio: mp3, 22050 Hz, mono, s16p, 16 kb/s
[swscaler # 0000000002ae1640] deprecated pixel format used, make sure you did se
t range correctly
[libvpx # 0000000002a8da40] v1.3.0
Output #0, webm, to 'http://172.17.146.***:8080/publish/tvbb100?password=****'
:
Metadata:
encoder : Lavf55.37.102
Stream #0:0: Video: vp8 (libvpx), yuv420p, 553x342 [SAR 1:1 DAR 553:342], q=
-1--1, 10 kb/s, 1k tbn, 25 tbc
Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp, 16 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libvpx)
Stream #1:0 -> #0:1 (mp3 -> libvorbis)
Press [q] to stop, [?] for help
frame= 33 fps=0.0 q=0.0 size= 4kB time=00:00:01.32 bitrate= 23.3kbits/s
frame= 67 fps= 66 q=0.0 size= 4kB time=00:00:02.68 bitrate= 11.5kbits/s
frame= 101 fps= 66 q=0.0 size= 11kB time=00:00:04.04 bitrate= 22.4kbits/s
frame= 133 fps= 66 q=0.0 size= 11kB time=00:00:05.32 bitrate= 17.0kbits/s
Can anybody help me?

FFMPEG preset is not found? Linux Cent OS 6

I ran this command
ffmpeg -i v-16418145218d8d7abdaabec46beb22ecffd2f5d1625.flv -y -acodec aac -ac 2 -ab 160k -vcodec libx264 -vpre iPod640 -vpre slow -f mp4 -threads 0 OUTPUT.mp4
Got this response:
[flv # 0x10ff670]Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, flv, from 'v-16418145218d8d7abdaabec46beb22ecffd2f5d1625.flv':
Metadata:
duration : 14
width : 320
height : 240
videodatarate : 500
framerate : 25
videocodecid : 2
audiodatarate : 0
audiosamplerate : 22050
audiosamplesize : 16
stereo : true
audiocodecid : 2
filesize : 912970
Duration: 00:00:13.92, start: 0.000000, bitrate: 576 kb/s
Stream #0.0: Video: flv, yuv420p, 320x240, 512 kb/s, 25 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: mp3, 22050 Hz, 2 channels, s16, 64 kb/s
File for preset 'iPod640' not found
But after doing a find, this is what I found.
/usr/share/ffmpeg/libx264-ipod320.ffpreset
/usr/share/ffmpeg/libx264-ipod640.ffpreset **** ITS HERE ******
/usr/share/ffmpeg/libx264-lossless_fast.ffpreset
/usr/share/ffmpeg/libx264-lossless_max.ffpreset
/usr/share/ffmpeg/libx264-lossless_medium.ffpreset
/usr/share/ffmpeg/libx264-lossless_slow.ffpreset
/usr/share/ffmpeg/libx264-lossless_slower.ffpreset
/usr/share/ffmpeg/libx264-lossless_ultrafast.ffpreset
/usr/share/ffmpeg/libx264-main.ffpreset
/usr/share/ffmpeg/libx264-max.ffpreset
/usr/share/ffmpeg/libx264-medium.ffpreset
/usr/share/ffmpeg/libx264-medium_firstpass.ffpreset
/usr/share/ffmpeg/libx264-normal.ffpreset
/usr/share/ffmpeg/libx264-placebo.ffpreset
/usr/share/ffmpeg/libx264-placebo_firstpass.ffpreset
/usr/share/ffmpeg/libx264-slow.ffpreset
/usr/share/ffmpeg/libx264-slow_firstpass.ffpreset
/usr/share/ffmpeg/libx264-slower.ffpreset
I alos tried with -vpre libx264-ipod640 and still no luck. I get preset libx264-ipod640 is not found.... Do i have to enable presets somehow? ffmpeg -- enable presets ? or something?
** EDIT: My ffmpeg version info **
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
FFmpeg 0.6.5
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
Found the solution while experimenting. I had the wrong order of presets. It has to be the -vcodec then -vpre (speed) -vpre (presetprofile [aka ipod640])

Resources