FFMPEG [h264_nvenc # 0x56151389fe00] Cannot get the preset configuration: invalid version (15) - ffmpeg

i have issue with ffmpeg as usual :D. I have FFMPEG compiled (version N-90807-g00099ef0d0) with NVIDIA support (latest CUDA and latest NV Headers):
ffmpeg version N-90807-g00099ef0d0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-libnpp --enable-cuda --enable-cuvid --enable-nvenc --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --enable-gpl --enable-libx264 --disable-x86asm --enable-libx265 --enable-libfdk-aac --enable-nonfree --enable-x86asm
libavutil 56. 15.100 / 56. 15.100
libavcodec 58. 19.100 / 58. 19.100
libavformat 58. 13.100 / 58. 13.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 19.100 / 7. 19.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
When I try to run basic transcoding on GPU using command:
ffmpeg -i 'udp://#239.100.0.1:331?fifo_size=‎100000000' -map i:0x100 -g 20 -vcodec h264_nvenc -map i:0x101 -ab 128k -ar 48k -acodec aac -f mpegts udp://#239.0.0.1:1234?overrun_nonfatal_optin=
I got this error:
Input #0, mpegts, from 'udp://#239.100.0.1:331?fifo_size=‎100000000':
Duration: N/A, start: 106.414400, bitrate: N/A
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 # 0x55a5edc45880] co located POCs unavailable
[h264_nvenc # 0x55a5edc45380] Cannot get the preset configuration: invalid version (15)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[aac # 0x55a5edc46d40] Qavg: 227.785
[aac # 0x55a5edc46d40] 2 frames left in the queue on closing
I have same version of FFMPEG compiled by the same way on another testing machine and there it is working. I tried to recompile/reinstall ffmpeg with the latest version, but result is the same.
Does someone know what could be wrong on my instance?
Thanks.

Fixed. The issue was in nvidia headers. Used version was extremely new. If you'll get this issue, just use the headers with tag n8.0.14.1 and then compile ffmpeg.
FFmpeg version of headers required to interface with Nvidias codec APIs:
git clone https://github.com/FFmpeg/nv-codec-headers.git
git checkout n8.0.14.1
make && make install

Related

How to compile ffmpeg to get only mp3 and mp4 support

I'm building Electron app and I use ffmpeg to convert m4a or webm files to mp3, and also to merge video only mp4 with m4a audio file to mp4.
I am able to achieve this using [media-autobuild-suite] (https://github.com/jb-alvarado/media-autobuild_suite), using light build option, but the size of static files is arround 20mb and I'would like to shrink it a little bit more. I've compiled ffmpeg and ffprobe with this configuration.
--disable-libaom
--disable-version3
# Full
--disable-chromaprint
--disable-cuda-sdk
--disable-decklink
--disable-frei0r
--disable-libbs2b
--disable-libcaca
--disable-libcdio
--disable-libfdk-aac
--disable-libflite
--disable-libfribidi
--disable-libgme
--disable-libgsm
--disable-libilbc
--disable-libkvazaar
--disable-libmodplug
--disable-libnpp
--disable-libopenh264
--disable-libopenmpt
--disable-librtmp
--disable-librubberband
--disable-libssh
--disable-libtesseract
--disable-libxavs
--disable-libzmq
--disable-libzvbi
--disable-opencl
--disable-opengl
--disable-libvmaf
--disable-libcodec2
--disable-libsrt
--disable-ladspa
--disable-ffplay
#--enable-vapoursynth
#--enable-liblensfun
--disable-libndi_newtek
--enable-demuxer=mp3
--enable-demuxer=mov
--enable-demuxer=opus
--enable-parser=ac3
--enable-parser=mpegaudio
--enable-parser=h264
--enable-parser=opus
--enable-protocol=file
--enable-protocol=pipe
--enable-decoder=mp3
--enable-decoder=mp4
--enable-decoder=opus
--enable-encoder=mp3
--enable-encoder=mp4
--enable-encoder=opus
With this configuration I'm getting ffmpeg static file arround 2mb and ffprobe static file arround 2mb but with this error.
C:\Users\Admin\Desktop\ffmpeg compilations\2mb\local64>ffmpeg -i simple.m4a simple.mp3
ffmpeg version N-93147-g9326117bf6 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8.2.1 (Rev1, Built by MSYS2 project) 20181214
configuration: .... //here comes configuration as described above
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.102 / 58. 47.102
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'simple.m4a':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6mp41
creation_time : 2018-10-31T19:47:32.000000Z
Duration: 00:02:38.92, start: 0.000000, bitrate: 127 kb/s
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 7 kb/s (default)
Metadata:
creation_time : 2018-10-31T19:47:32.000000Z
handler_name : SoundHandler
[NULL # 0000000000486200] Unable to find a suitable output format for 'simple.mp3'
simple.mp3: Invalid argument
Any ideas what else should I include into this static file?
No need to disable things piecemeal: just use --disable-everything then enable what you need.
Here's an example you can start out with:
./configure
--disable-everything
--disable-network
--disable-autodetect
--enable-small
--enable-decoder=aac*,ac3*,opus,vorbis
--enable-demuxer=mov,m4v,matroska
--enable-muxer=mp3,mp4
--enable-protocol=file
--enable-libshine
--enable-encoder=libshine
--enable-filter=aresample
Final binary size will be around 2-3 MB.
No need to enable any parsers: the selected decoders will automatically select whichever are required.
FFmpeg does not have a native MP3 encoder, so you'll need to use an external library such as libmp3lame or libshine. Since you mentioned Android I assumed you'll want libshine instead of libmp3lame to encode MP3.
Test thoroughly. I probably forgot something.
If you really want to go nuts then use --disable-all instead of --disable-everything and you'll additionally have to manually include the FFmpeg libraries that you want, but that's more work and more headache for not much return.
This will allow you to encode MP3 audio from most M4A and Webm inputs:
ffmpeg -i input.webm output.mp3
And will also let you re-mux MP4/M4V + M4A into MP4:
ffmpeg -i video.m4v -i audio.m4a -map 0:v -map 0:a -c copy output.mp4

ffmpeg recoded mp4 files error on mobiles in Video JS

We are converting seriously old .flv files to MP4 with FFMPEG. These are at least 10 years old.
Back then all were rendered with early versions of Adobe Premiere.
On desktop browsers all the files work and stream (...watching them feels like going back a century!)
But when requesting the videos on the same pages on mobile devices (android and ios) Video JS doesn't even show up.
Perhaps the codec is just too old, but I was wondering if there could be another reason when converting them with this line:
for i in *.flv; do ffmpeg -i "$i" "${i%.*}.mp4"; done
If not, is it possible to detect this in Video JS, so we can show an announcement that the video is only visible on desktops?
I hope someone here has this knowledge!
added on request of llogan
ffmpeg version N-78967-gbaec6d8 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/root/ffmpeg_build
--extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 19.100 / 55. 19.100 libavcodec 57. 28.100 / 57. 28.100 libavformat 57. 28.100 / 57. 28.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 39.102 /
6. 39.102 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a_4293_06.mp4': Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.28.100 Duration: 00:01:40.10, start: 0.023220, bitrate: 492 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240, 376 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 123 kb/s (default)
Metadata:
handler_name : SoundHandler At least one output file must be specified
Thanks to #llogan's comments I can answer this one myself.
First, I upgraded ffmpeg to the latest version, and then did some research on the -movflags and +faststart.
I found a 2015 article with great info on how to convert .flv to .mp4 (https://addpipe.com/blog/flv-to-mp4/)
So, in order to make the new .mp4 files compatible with mobile devices, you need to add a profile and a level, like this:
in a batch convert:
for i in *.flv; do ffmpeg -y -i "$i" -movflags +faststart -profile:v baseline -level 3.0 "${i%.*}.mp4"; done
and for a single file:
ffmpeg -i filename.flv -movflags +faststart -profile:v baseline -level 3.0 filename.mp4
And then the terminal shows this line when converting:
Starting second pass: moving the moov atom to the beginning of the
file
That is needed, but the addition of the -profile and -level actually made the videos work on the mobile devices.

how to use ffmpeg with mjpeg_vaapi encoder (with hardware acceleration)?

When I use ffmpeg with mjpeg encoder without hardware acceleration, everything works fine. I use following command:
ffmpeg -nostdin -rtsp_transport udp_multicast -allowed_media_types 'video' -i 'rtsp://MYIP' -ss 00:00:0.00 -f image2pipe -q:v 24 -vf scale=-2:480,format=yuv420p -c:v mjpeg -vframes 1 pipe:1
But, when I try to use mjpeg with hardware acceleration, I always get error:
ffmpeg -nostdin -rtsp_transport udp_multicast -allowed_media_types 'video' -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 'rtsp://MYIP' -ss 00:00:0.00 -f image2pipe -q:v 24 -vf scale=-2:480,format=yuv420p -c:v mjpeg_vaapi -vframes 1 pipe:1
ffmpeg version N-91514-gc51e0cd Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --pkg-config-flags=--static
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 21.106 / 58. 21.106
libavformat 58. 17.101 / 58. 17.101
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 26.100 / 7. 26.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Input #0, rtsp, from 'rtsp://MYIP':
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
Duration: N/A, start: 0.180600, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, progressive), 800x600, 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (mjpeg_vaapi))
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!
I tried with some additional options but it still keeps failing:
ffmpeg -nostdin -rtsp_transport udp_multicast -allowed_media_types 'video' -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 'rtsp://MYIP' -ss 00:00:0.00 -f image2pipe -q:v 24 -vf "scale_vaapi=w=800:h=600" -b:v 700k -r 25 -vcodec mjpeg_vaapi -vframes 1 pipe:1
ffmpeg version N-91514-gc51e0cd Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --pkg-config-flags=--static
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 21.106 / 58. 21.106
libavformat 58. 17.101 / 58. 17.101
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 26.100 / 7. 26.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Input #0, rtsp, from 'rtsp://MYIP':
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
Duration: N/A, start: 0.179933, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, progressive), 800x600, 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (mjpeg_vaapi))
[mjpeg_vaapi # 0x374cd80] Encoding entrypoint not found (12 / 7).
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Can please anyone suggest right options to make it work?
so the problem was that my Intel CPU platform was old (Broadwell) and JPEG encoding is supported starting Braswell. Please see all supported codecs by platform on the page
After running the same command on the machine with Skylake CPU on it, it work from the first try :)
When you trying to leverage Intel's hardware encoding, you need to check TWO things
rather your particular intel support the encoder you want
rather your ffmpeg binary fetched from somewhere compiled with the hardware acceleration library or not.
To find out what kind of encoder your Intel support, you simply type:
vainfo|grep -i enc
it will list the encoder which your processor support. In my case, for example, it yields the following:
libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileHEVCMain : VAEntrypointEncSlice
in my case, my intel cpu does have mjpeg encoding support.
if you can't find anything resembles mjpeg, then, you can pretty much give up the idea of using intel's hardware acceleration to accomplish what you want on that machine.
The next thing you need is to find out rather your ffmpeg binary support Intel's vaapi at the first place. First is to type:
ffmpeg -hide_banner -hwaccels
if one of those line has "vaapi," then, it means the ffmpeg compiled with Intel's hardware acceleration library. If your vainfo command has what you want but the above command doesn't display vaapi, then, you need to get another copy of ffmpeg binary. either from a different source, or compile it on your own.
Next, is to list all the ffmpeg encoder that actually uses vaapi, and hoping one of them resembles mjpeg:
ffmpeg -hide_banner -encoders|grep -i vaapi
In my case, I do have it:
V....D h264_vaapi H.264/AVC (VAAPI) (codec h264)
V....D hevc_vaapi H.265/HEVC (VAAPI) (codec hevc)
V....D mjpeg_vaapi MJPEG (VAAPI) (codec mjpeg)
V....D mpeg2_vaapi MPEG-2 (VAAPI) (codec mpeg2video)
V....D vp8_vaapi VP8 (VAAPI) (codec vp8)
V....D vp9_vaapi VP9 (VAAPI) (codec vp9)
So, in my case, the encoder is there.
if both vainfo and ffmpeg -hwaccels yield what you need but this last step doesn't, then, you need to get another ffmpeg binary from somewhere.
good luck.

FFmpeg 'Unable to parse option value "(null)" as sample format'

Im trying to process a file and run the following command
ffmpeg -i input.webm output.webm
I'm doing it with the ffmpeg library from videoconverter.js. I'm trying to understand what is wrong or how I can fix it.
I end up getting this:
Worker has received command
Received command: -i input.webm output.webm. Processing with 268435456 bits.
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Jun 9 2014 20:24:32 with emcc (Emscripten GCC-like replacement) 1.12.0 (commit 6960d2296299e96d43e694806f5d35799ef8d39c)
configuration: --cc=emcc --prefix=/Users/bgrinstead/Sites/videoconverter.js/build/ffmpeg/../dist --extra-cflags='-I/Users/bgrinstead/Sites/videoconverter.js/build/ffmpeg/../dist/include -v' --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-doc --disable-devices --disable-pthreads --disable-w32threads --disable-network --disable-hwaccels --disable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-protocol=file --enable-libvpx --enable-gpl --extra-libs='/Users/bgrinstead/Sites/videoconverter.js/build/ffmpeg/../dist/lib/libx264.a /Users/bgrinstead/Sites/videoconverter.js/build/ffmpeg/../dist/lib/libvpx.a'
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
[vp8 # 0xed8c00] Warning: not compiled with thread support, using thread emulation
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, matroska,webm, from 'input.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono (default)
Stream #0:1(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
[abuffer # 0xedd670] Unable to parse option value "(null)" as sample format
Last message repeated 1 times
Last message repeated 1 times
[abuffer # 0xedd670] Error setting option sample_fmt to value (null).
[graph 1 input from stream 0:0 # 0xedd600] Error applying options to the filter.
Error opening filters!
Finished processing (took 673ms)
The end result is stopped due to 'Unable to parse option value "(null)" as sample format'. How would I solve this?
Your ffmpeg build is using version 2.2.1 which is old and unsupported.
It is too old to natively support Opus decoding (this version requires libopus to decode Opus). Upgrade to a build derived from the development branch ("git master") or at least use the latest release.
You should also use a modern libvpx if possible as well. Note that with recent FFmpeg you will need to remove --disable-bsfs because VP9 is now the default video encoder for Webm and it requires the vp9_superframe bitstream filter (it is automatically applied). Alternatively, you can force VP8 encoding with -c:v libvpx.
Consider adding libopus (preferred) or libvorbis support for Webm; otherwise you'll be using the very crappy and experimental FFmpeg native Vorbis encoder.

ffmpeg not converting an mp3 on OSX. Homebrew installed. Encoder (codec mp3) not found for output stream #0:0

Ok, did the standard hoembrew install for ffmpeg.
All looks cool, i'm guessing that has to include the mpeg codec, yet I keep getting a 0 byte file and the error message:
Encoder (codec mp3) not found for output stream #0:0
Help most appreciated.
ffmpeg -i input.mp3 -b:a 48k -ar 16000 output.mp3
ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.3.0 (clang-703.0.29)
configuration:
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
[mp3 # 0x7ff05a010600] Skipping 0 bytes of junk at 626.
Input #0, mp3, from 'input.mp3':
Metadata:
title : Allegro from Duet in C Major
Duration: 00:00:59.56, start: 0.025057, bitrate: 192 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
Metadata:
encoder : LAME3.96r
Output #0, mp3, to 'output.mp3':
Metadata:
title : Allegro from Duet in C Major
Stream #0:0: Audio: mp3, 0 channels, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> ? (?))
Encoder (codec mp3) not found for output stream #0:0
This ended up working: brew install --use-clang --HEAD ffmpeg

Resources