ffmpeg codec conversion; can't configure encoder - ffmpeg

I am simply trying to convert a vp9 webm I have into a vp8 webm. this is the command I'm using.
ffmpeg -i in.webm -c:v vp8 out.webm
the vp8 encoder returns a strange error
Input #0, matroska,webm, from 'in.webm':
Metadata:
encoder : google
Duration: 00:02:34.60, start: 0.000000, bitrate: 404 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/unknown/unknown), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> vp8 (vp8_v4l2m2m))
Press [q] to stop, [?] for help
[vp8_v4l2m2m # 0x56195db9f9f0] Could not find a valid device
[vp8_v4l2m2m # 0x56195db9f9f0] can't configure encoder
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!
In case I get any questions about whether I have the right encoders and decoders installed here is the output of ffmpeg -codecs | grep "vp[8-9]":
DEV.L. vp8 On2 VP8 (decoders: vp8 vp8_v4l2m2m vp8_cuvid ) (encoders: vp8_v4l2m2m )
D.V.L. vp9 Google VP9 (decoders: vp9 vp9_v4l2m2m vp9_cuvid )

Your ffmpeg build has a Video4Linux wrapper available for a hardware VP8 encoder, but no actual hardware VP8 encoder available.
For software encoding of VP8/VP9, you'll need libvpx enabled and linked. You can get a static git binary from https://johnvansickle.com/ffmpeg/

Related

Extract frames from video with ffmpeg - header problem?

I want to convert .AVI files coming from a camera-trap to individuals frames, ideally using ffmpeg. Up to now I am not succeeding.
The most simple thing I tried, to try to locate the problem, is this (I want all frames and my test file is test.avi):
ffmpeg -i test.avi output_%04d.png
It fails with the following console message:
[avi # 0x559fb596f8c0] unknown stream type 73647578
[avi # 0x559fb596f8c0] Something went wrong during header parsing, tag [0][0]id has size 338702712, I will ignore it and try to continue anyway.
[mjpeg # 0x559fb59709e0] No JPEG data found in image
Last message repeated 100 times
[avi # 0x559fb596f8c0] decoding for stream 0 failed
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 0 (Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 1 (Video: none (JUNK / 0x4B4E554A), none, 11025x22050): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, avi, from 'test.avi':
Duration: 00:00:10.50, start: 0.000000, bitrate: 28129 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
Decoder (codec none) not found for input stream #0:1
The actual video duration is 10s (when read using vlc for instance, and this is indeed the length of video programmed on the camera-trap. ffmpeg says the duration is 10.50s, and says there is a problem with header parsing (see above).
I have no idea how to sort this, despite having looked at more than many ffmpeg 'convert video to frames' post. Any hint would be appreciated, thanks.
If you look at the error message, you will see that the file has 2 video streams.
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
and ffmpeg is trying to read for the second one:
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
You can use -map 0:0 to select the first stream.

FFMPEG: how to wrap h264 stream into FLV container?

What I want is straightforward: wrap H.264 video stream into a FLV container. However, ffmpeg just decode the input stream and pack raw video stream into FLV. The details are described below:
The input stream is captured from a hardware-encoder video camera, and the FLV will be sent to some video server. Firstly I used following command:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -f flv "rtmp://some.website.com/receive/path"
However, the resultant stream is suspicious. The watching side don't get any H.264 thing. Then I made a test by writing output to local files.
1: Read raw stream, encode by h264_omx, write to FLV file:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video0 -codec h264_omx -f flv raw_input_h264_omx.flv
......
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 194017.870905, bitrate: 18432 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 18432 kb/s, 15 fps, 15 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_omx))
......
2: Read H264 stream, write to FLV file:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -f flv h264_input.flv
......
Input #0, video4linux2,v4l2, from '/dev/video1':
Duration: N/A, start: 194610.307096, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 320x240, 15 fps, 15 tbr, 1000k tbn, 2000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
......
Then read the two files correspondingly:
$ ffmpeg -i raw_input_h264_omx.flv
......
Stream #0:0: Video: h264 (High), yuv420p(progressive), 320x240, 200 kb/s, 15 fps, 15 tbr, 1k tbn
$ ffmpeg -i h264_input.flv
......
Stream #0:0: Video: flv1, yuv420p, 320x240, 200 kb/s, 15 fps, 15 tbr, 1k tbn
It is clear when I give a H.264 stream, ffmpeg firstly decodes it, then pack the raw video into FLV. How to avoid that happen, and have the H.264 stream packed directly?
Supplement: I will eventually pushing multiple video streams, so don't ask me to allow ffmpeg's silent decoding, and encode the stream again.
Unless told otherwise, ffmpeg will transcode streams.
Use
ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -c copy -f flv "rtmp://website/receive/path"

FFMPEG hevc_nvenc "No NVENC capable devices found" with NVidia GTX950M

I get the error "No NVENC capable devices found" when trying a simple encoding like this, even skipping audio to make sure it's not an audio problem:
ffmpeg.exe -i input.mp4 -c:v hevc_nvenc -an out.mp4
I also tried with more details, like setting the pixel format, the preset, the rate-control, the format.
On the documentation page there:
https://trac.ffmpeg.org/wiki/HWAccelIntro
it says that if we get this error we should check for the pixel format. The video has yuv420p here and even specifying the format results in the same error.
i also checked the NVidia supported cards and it says GeForce, but no details about the models:
https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder
I tried h264_nvenc and it works perfectly however, the problem is only with hevc_nvenc
Has anyone encountered this problem?
Complete console output:
[h264 # 0000000002534560] Reinit context to 1280x544, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
creation_time : 2014-05-23T13:04:15.000000Z
Duration: 01:54:03.95, start: 0.000000, bitrate: 3193 kb/s
Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1280x544 [SAR 1:1 DAR 40:17], 2750 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2014-05-23T11:25:27.000000Z
Stream #0:1(spa): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 439 kb/s (default)
Metadata:
creation_time : 2014-05-23T12:56:43.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
[h264 # 000000000260ea40] Reinit context to 1280x544, pix_fmt: yuv420p
[graph 0 input from stream 0:0 # 0000000003857ec0] w:1280 h:544 pixfmt:yuv420p tb:1/24000 fr:24000/1001 sar:1/1 sws_param:flags=2
[hevc_nvenc # 00000000038574e0] Loaded Nvenc version 8.0
[hevc_nvenc # 00000000038574e0] Nvenc initialized successfully
[hevc_nvenc # 00000000038574e0] 1 CUDA capable devices found
[hevc_nvenc # 00000000038574e0] [ GPU #0 - < GeForce GTX 950M > has Compute SM 5.0 ]
[hevc_nvenc # 00000000038574e0] Codec not supported
[hevc_nvenc # 00000000038574e0] No NVENC capable devices found
[hevc_nvenc # 00000000038574e0] Nvenc unloaded
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!
950M doesn't support h265 codec indeed.
From nvidia nvenc page or the detailed support matrix, we can learn that h265/hevc is supported only from 2nd generation maxwell GPU.
Also check the maxwell wiki page and list of NVIDIA GPU. You can see that 950M's code name is GM107 which is a 1st generation maxwell architecture, that means no h265 support. Sorry, you have to fall back to h264.

Ffmpeg didn't burn srt subtitle on mkv properly

`ffmpeg version:git-fc6de70 (2013-07-18) with libass and fontconfig support.
command line:ffmpeg.exe -i test.mkv -vf subtitles=test.srt out.mkv
and i got this error.:
Metadata:
encoder : Lavf55.12.102
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x5
76 [SAR 1:1 DAR 20:9], q=-1--1, 1k tbn, 23.98 tbc (default)
Stream #0:1: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo
, fltp (default)
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libvorbis)
Press [q] to stop, [?] for help
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. A
ssuming 384x288
http://tinypic.com/r/2ag52so/5
The message you get:
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. Assuming 384x288
means that your ssa or srt file doesn't specify the PlayResX and Y values. So the VFilter assume a display resolution of 384x288, thats why your subtitles looks so small on a 1280x576 video.
A workaround for your issue is:
convert SRT to SSA/ASS
ffmpeg -i file.srt file.ass
edit your SSA/ASS file to set the correct value. For SSA the format is describe here and it's easy to set PlayRes X and Y.
[Script Info]
; This is a Sub Station Alpha v4 script.
....
ScriptType: v4.00
Collisions: Normal
PlayResX: 1280
PlayResY: 576
PlayDepth: 0
....
And finally, launch your command again using the ass file.
Burning subntitles with FFmpeg is tricky due to canvas size with pictured-based subtitles and charset encoding with text files (srt or ssa).
I guess I managed to handle it for almost all cases in DVDx 4.1 Free Encoder version (Beta 1.0):
http://www.labdv.com/dvdx/4.1/docs/burn-subtitles-in-video.php

Increase the bitrate tolerance of ffmpeg for creating screenshots of a movie

I'm getting the error bitrate tolerance too small for bitrate so far no problem. I know that there are several switches to increase that but nothing works.
ffmpeg -y -r 1/30 -b:v 999999k -bt 999999k -maxrate 999999k -i in.flv out%03d.jpg
The source of that commandline is directly from ffmpeg. But that crashes:
ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 2 2012 20:23:29 with gcc 4.7.1 (GCC)
[...]
Input #0, flv, from 'in.flv':
Duration: 00:05:00.13, start: 0.000000, bitrate: 259 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 22050 Hz, mono, s16
[mjpeg # 04356860] bitrate tolerance too small for bitrate
[mjpeg # 04317540] ff_frame_thread_encoder_init failed
Output #0, image2, to 'out%03d.jpg':
Stream #0:0: Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 0.03 tbc
Stream mapping:
Stream #0:0 -> #0:0 (flv -> mjpeg)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Some ideas what I'm doing wrong?

Resources