I want to transcode amr audio files to flac using JAVE which uses ffmpeg.
The transcoding procedure runs successfully on Windows but fails on Linux (centOS).
I checked the JAVE code and found it uses the following command:
ffmpeg -i 1.amr -vn -acodec flac -ac 1 -ar 8000 -f flac -y 1.flac
the output is:
FFmpeg version SVN-r11179, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads \
--enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora \
--enable-memalign-hack --extra-ldflags=-static -lm -lz
libavutil version: 49.5.0
libavcodec version: 51.48.0
libavformat version: 52.1.0
built on Dec 7 2007 15:35:14, gcc: 4.1.2 20070626 (Red Hat 4.1.2-14)
Input #0, amr, from '1.amr':
Duration: N/A, bitrate: N/A
Stream #0.0: Audio: samr / 0x726D6173, 8000 Hz, mono
Input #1, amr, from '1.amr':
Duration: N/A, bitrate: N/A
Stream #1.0: Audio: samr / 0x726D6173, 8000 Hz, mono
Output #0, flac, to '1.flacffmpeg':
Stream #0.0: Audio: flac, 8000 Hz, mono, 64 kb/s
Output #1, flac, to '1.flac':
Stream #1.0: Audio: flac, 8000 Hz, mono, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #1.0 -> #1.0
Unsupported codec (id=73728) for input stream #0.0
So the problem is an unsuppported codec? How can I resolve this?
If JAVE is bundling a copy of FFmpeg then there's not much you can do beyond filing a bug report.
Alternately, since you can see the FFmpeg command they're using, you could always compile it yourself, with all the necessary codecs, and run the same external command.
Related
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.
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.
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
I'm trying to use FFMPEG to transcode a video with very large frames (4096 x 4096). It's a short video - just under two minutes, but the source video file is 15.8GB. (The video is an animation designed to be projected onto planetarium domes.)
The source file is a Quicktime MOV containing uncompressed Photo-JPEG images (with audio, too). When I tell FFMPEG to transcode my MOV file into an MP4 file, it simply says:
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Not very helpful, but yes, I've verified that all of the parameters are correct and/or defaults. In fact, if I change the requested output size to 2048x2048, then everything works just fine. That's why I suspect that there's an upper bound in the encoder.
I am kerflummoxed. Any suggestions that result in a successful transcode will be greatly appreciated. (At this point I am also willing to consider alternatives to FFMPEG.)
The Facts
I run FFMPEG from a script:
set srcFile=%1
set dstFile=%srcFile:.mov=.mp4%
ffmpeg -i %srcFile% -movflags faststart -q:a 0 -q:v 0 -pix_fmt yuv420p -sws_flags gauss -s 4096x4096 %dstFile%
The Output
ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --ena
ble-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 19.100 / 52. 19.100
libavcodec 55. 0.100 / 55. 0.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 54. 4.100 / 54. 4.100
libavfilter 3. 45.103 / 3. 45.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'also-sprach-zarathustra-4k.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2013-01-11 23:41:30
Duration: 00:01:40.57, start: 0.000000, bitrate: 1357694 kb/s
Stream #0:0(eng): Audio: pcm_s16be (twos / 0x736F7774), 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
creation_time : 2013-01-11 23:41:30
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Video: mjpeg (jpeg / 0x6765706A), yuvj420p, 4096x4096 [SAR 1:1 DAR 1:1], 1356281 kb/s, 30 fps, 30
tbr, 3k tbn, 3k tbc
Metadata:
creation_time : 2013-01-11 23:41:30
handler_name : Apple Alias Data Handler
File 'also-sprach-zarathustra-4k.mp4' already exists. Overwrite ? [y/N] y
using SAR=1/1
[libx264 # 003b9c80] frame MB size (256x256) > level limit (36864)
[libx264 # 003b9c80] DPB size (4 frames, 262144 mbs) > level limit (2 frames, 184320 mbs)
[libx264 # 003b9c80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI1 BMI2
x264 [error]: malloc of size 17305600 failed
Output #0, mp4, to 'also-sprach-zarathustra-4k.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
Stream #0:0(eng): Video: h264, yuv420p, 4096x4096 [SAR 1:1 DAR 1:1], q=-1--1, 90k tbn, 30 tbc
Metadata:
creation_time : 2013-01-11 23:41:30
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: none, 44100 Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 2013-01-11 23:41:30
handler_name : Apple Alias Data Handler
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg -> libx264)
Stream #0:0 -> #0:1 (pcm_s16be -> libvo_aacenc)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
PS: Yes, for those playing at home, it is the theme to 2001 - A Space Odyssey. You can see a 1K YouTube version here: 2001 - A Fulldome Space Odyssey And yes, in a planetarium with a good sound system, it is absolutely EPIC.
I think you're actually running into the limitation of of x264's codec complexity levels.
Brief description of the levels from http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC
As the term is used in the standard, a "level" is a specified set of constraints that indicate a degree of required decoder performance for a profile. For example, a level of support within a profile specifies the maximum picture resolution, frame rate, and bit rate that a decoder may use. A decoder that conforms to a given level must be able to decode all bitstreams encoded for that level and all lower levels.
The max resolution for the highest level (5.2) is 4,096×2,304.
I would look into using HEVC which is specifically designed for these larger format 4K / Ultra-HD resolutions.
http://en.wikipedia.org/wiki/HEVC
Max Resolution for HEVC is currently 8,192x4,320
I suspect your problem is hinted at here:
x264 [error]: malloc of size 17305600 failed
Is this a 32-bit build of ffmpeg? If so, I fear you may be out of luck. 4k video processing really requires >4 GB of memory. Better switch to a 64-bit build and try again.
Of course you actually need to have enough memory available in your computer, too. It could be a lot more than 4 GB, depending on your x264 settings.
I try to decode some video files using ffmpeg, but get errors caused by icod codec.
Here's the file's ffprobe info:
user:~$ ffprobe input.mov
ffprobe version 1.2.3 Copyright (c) 2007-2013 the FFmpeg developers
built on Jan 15 2014 23:08:14 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --enable-zlib --enable-libmp3lame --enable-libx264 --enable-gpl --enable-nonfree --enable-pic
...
Stream #0:0(eng): Video: none (icod / 0x646F6369), 1280x720, 52569 kb/s, SAR 1:1 DAR 16:9, 59.94 fps, 59.94 tbr, 5994 tbn, 5994 tbc
Metadata:
creation_time : 2014-01-27 05:09:24
handler_name : Apple Alias Data Handler
timecode : 21:03:24:08
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
creation_time : 2014-01-27 05:09:24
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
Metadata:
creation_time : 2014-01-27 05:09:24
handler_name : Apple Alias Data Handler
timecode : 21:03:24:08
Unsupported codec with id 0 for input stream 0
Unsupported codec with id 0 for input stream 2
The first step is to always try a recent build. The 1.2 branch release can be considered to be old. FFmpeg development is very active, and using a recent build will ensure that you're not missing a feature or that you're not experiencing a bug that has already been fixed; such as your case with Apple Intermediate Codec (ICOD) decoding.
See the links to Linux builds of ffmpeg on the FFmpeg Download page or see one of the many FFmpeg compile guides.