FFmpeg: Image sequence with ffv1 codec? - ffmpeg

Is it possible to output an image sequence in ffmpeg using the ffv1 codec?
If so, in what container, how would I reimport these back into ffmpeg?
movie containers seem not possible for seq output
i can force output -f image2 to any container, but import is not possible even with -c:v ffv1 as an input option.
Encode of "intermediate.ffv1"
ffmpeg -y -ss 250 -i "/media/pool/vrender_input/movie.mov" -vframes 1 -c:v ffv1 -compression_level none -map 0:0 -an -f image2 -threads 0 "/media/scratch/intermediate.ffv1"
Decode of "intermediate.ffv1"
ffmpeg -y -c:v ffv1 -f image2 -i "/media/scratch/intermediate.ffv1" -c:v tiff -an -f image2 "/media/scratch/final.tif"
Error:
[image2 # 0x2f85c80] Failed to open codec in av_find_stream_info
[image2 # 0x2f85c80] Could not find codec parameters for stream 0 (Video: ffv1, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
/media/scratch2/vrender_tmp/intermediate.ffv1: could not find codec parameters
Input #0, image2, from '/media/scratch2/vrender_tmp/intermediate.ffv1':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: ffv1, none, 25 tbr, 25 tbn, 25 tbc
[buffer # 0x2f7ce20] Unable to parse option value "0x0" as image size
[buffer # 0x2f7ce20] Unable to parse option value "-1" as pixel format
[buffer # 0x2f7ce20] Unable to parse option value "0x0" as image size
[buffer # 0x2f7ce20] Error setting option video_size to value 0x0.
[graph 0 input from stream 0:0 # 0x2f6cfc0] Error applying options to the filter.
Error opening filters!
Whats wrong?
Thank you!

Related

Making a ffmpeg screen capture on Mac OS X using YUV 4:2:0 Planar color model

I make screen recordings with ffmpeg, using avfoundation on Mac OS X, x11grab on Linux and gdigrab on Windows.
The resulting files should be compatible with modern web browsers (<video/>), so I use H.264 codec and request YUV 4:2:0 Planar pixel format.
On Mac OS X, however (unlike Linux and Windows), I receive the following logging:
/usr/local/bin/ffmpeg -y -v error -f avfoundation -threads 0 -hide_banner -i 1:none -f mp4 -vcodec h264 -pix_fmt yuv420p -r 25/1 -qscale:v 1 -vf scale=-1:1080 target.mp4
[avfoundation # 0x7fdba2003a00] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation # 0x7fdba2003a00] Supported pixel formats:
[avfoundation # 0x7fdba2003a00] uyvy422
[avfoundation # 0x7fdba2003a00] yuyv422
[avfoundation # 0x7fdba2003a00] nv12
[avfoundation # 0x7fdba2003a00] 0rgb
[avfoundation # 0x7fdba2003a00] bgr0
Still, according to mplayer, the resulting MP4 file seems to have YUV 4:2:0 Planar color model:
[h264 # 0x1048a8ac0]Format yuv420p chosen by get_format().
[h264 # 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
[h264 # 0x1048a8ac0]Format yuv420p chosen by get_format().
[h264 # 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
[swscaler # 0x1048c3cc0]bicubic scaler, from yuv420p to yuyv422 using MMXEXT
*** [scale] Exporting mp_image_t, 1728x1080x12bpp YUV planar, 2799360 bytes
*** [vo] Allocating mp_image_t, 1728x1080x16bpp YUV packed, 3732480 bytes
the same confirmed by ffmpeg:
$ ffmpeg -i target.mp4 -hide_banner
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'target.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:04.72, start: 0.000000, bitrate: 201 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1728x1080, 197 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Questions:
Can someone explain the above ffmpeg logging?
If I still need to convert the avfoundation video stream to yuv420p, how do I make it on the fly (in a single ffmpeg pass)?
The avfoundation module has its pixel format default set to yuv420p. When not available, it will print that warning and attempt to select another format. You should see a line below that warning starting with Overriding selected pixel format to use ..
If the output's fine, this can be ignored. You don't need a second pass or any other change.

ffmpeg wont convert gif to webm

I'm trying convert a gif to a webm for files uploaded to my site, to get smaller files (gifs are so big...) and get all the advantages of videos like pausing.
The problem is ffmpeg gives this error:
Input #0, gif, from '1.gif': Duration: N/A, bitrate: N/A
Stream #0:0: Video: gif, bgra, 960x540, 16.67 fps, 16.67 tbr, 100 tbn, 100 tbc Stream mapping: Stream #0:0 -> #0:0 (gif (native) ->
vp8 (libvpx)) Press [q] to stop, [?] for help [libvpx #
0x5560ca413960] v1.6.1 [libvpx # 0x5560ca413960] Transparency encoding
with auto_alt_ref does not work 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!
Here's my ffmpeg line:
ffmpeg -r 16 -i 1.gif -c:v libvpx -crf 12 -b:v 500k test.webm
ffmpeg -y -i 1.gif -r 16 -c:v libvpx -quality good -cpu-used 0 -b:v 500K -crf 12 -pix_fmt yuv420p -movflags faststart test.webm

FFMPEG amerge fails when one audio stream is missing

I am trying to combine two video files (of size 320x240) and create a single, horizontally extended output video file (of size 640x240) but for the audio merging, the command fails when one of the input files does not contain audio stream.
Here's the command I am using:
C:\ffmpeg\bin\ffmpeg.exe -y -i "input1.flv" -i "input2.flv" -filter_complex "nullsrc=size=640x240[base];[0:v]scale=320x240[upperleft];[1:v]scale=320x240[upperright];[base][upperleft]overlay=shortest=1[tmp1];[tmp1][upperright]overlay=shortest=1:x=320:y=0;[0:a][1:a]amerge=inputs=2[aout]" -map [aout] -ac 2 "output.mp4"
This command works fine when both input1.flv and input2.flv contain audio tracks. When either one lacks an audio track, the command gives the following error:
[flv # 0000000004300660] Stream discovered after head already parsed
[flv # 0000000004300660] Could not find codec parameters for stream 1
(Audio: none, 0 channels): unspecified sample format Consider
increasing the value for the 'analyzeduration' and 'probesize' options
Input #1, flv, from 'input2.flv': Metadata:
creationdate : Tue Jan 26 16:50:12 Duration: 00:25:59.10, start: 0.000000, bitrate: 212 kb/s
Stream #1:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
Stream #1:1: Audio: none, 0 channels
Stream #1:2: Data: none [abuffer # 0000000004335620] Value inf for parameter 'time_base' out of range [0 - 2.14748e+009] [abuffer #
0000000004335620] Unable to parse option value "(null)" as sample
format [abuffer # 0000000004335620] Value inf for parameter
'time_base' out of range [0 - 2.14748e+009] [abuffer #
0000000004335620] Error setting option time_base to value 1/0. [graph
0 input from stream 1:1 # 00000000042e4d60] Error applying options to
the filter. Error configuring filters.
Is there a way to make this command work even when one audio stream lacks an audio track or both of the audio streams lack audio tracks?
There's one preparatory command that needs to be executed only once,to generate a file
ffmpeg -f lavfi -t 1 -i anullsrc:r=48000 silence.mkv
For each flv,
ffmpeg -i input1.flv -analyzeduration 10M -i silence.mkv -c copy -map 0 -map 1 input1a.mkv
ffmpeg -i input2.flv -analyzeduration 10M -i silence.mkv -c copy -map 0 -map 1 input2a.mkv
And then,
ffmpeg -i input1a.mkv -i input2a.mkv -filter_complex "[0:v][1:v]hstack=shortest=1[v];[0:a][1:a]amerge[a]" -map [v] -map [a] -ac 2 "output.mp4"

FFMPEG attach file as metadata

I have a set of images which I want to convert to a video using ffmpeg. The following command works perfectly fine:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 testout.mkv
I have some meta data in a binary file which I want to attach with the video. I tried doing the following, but it gives me an error:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile -metadata:s:2 mimetype=application/octet-stream testout.mkv
This is the error:
[matroska # 0x656460] Codec for stream 1 does not use global headers but container format requires global headers
[matroska # 0x656460] Attachment stream 1 has no mimetype tag and it cannot be deduced from the codec id.
Output #0, matroska, to 'testout.mkv':
Metadata:
encoder : Lavf56.33.101
Stream #0:0: Video: huffyuv (HFYU / 0x55594648), rgb24, 640x640, q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc56.39.100 huffyuv
Stream #0:1: Attachment: none
Metadata:
filename : 2ceb-1916-56bb-3e10
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> huffyuv (native))
File 2ceb-1916-56bb-3e10 -> Stream #0:1
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
It would be wonderful if somebody can explain to me what am I doing wrong :)
You need to specify your stream properly
Example:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile \
-metadata:s:t mimetype=application/octet-stream testout.mkv
This command will set the metadata for all attachment (t) streams (s). If you have more than one attachment, and the metadata are different, then you will have to be more specific, such as:
-metadata:s:t:0 mimetype=text/plain \
-metadata:s:t:1 mimetype=application/gzip
This will set the metadata for the first attachment as mimetype=text/plain, and the second as mimetype=application/gzip. Remember that the stream index starts at 0, so the first steam is labeled 0.
What was wrong with your command
Using -metadata:s:2 (which appears to have been copied verbatim from the documentation) sets the metadata for the third stream, regardless of stream type (because no specifier is present), but your output only contained two streams.
Attachment: None
You may see something like this:
Output #0, matroska, to 'output.mkv':
...
Stream #0:1: Attachment: none
Metadata:
filename : 2ceb-1916-56bb-3e10
mimetype : application/octet-stream
Attachment: none does not mean that there is no attachment, but that there is no format associated with it, so it can be ignored.
Also see
Stream specifiers and the ffmpeg documentation on -attach, -metadata, and -map_metadata for more details.

Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

I am using this command to convert an avi,mov,m4v video files to flv format via FFMPEG
/usr/local/bin/ffmpeg -i '/home/public_html/files/video_1355440448.m4v' -s '640x360' -sameq -ab '64k' -ar '44100' -f 'flv' -y /home/public_html/files/video_1355440448.flv
[flv # 0x68b1a80] requested bitrate is too low
Output #0, flv, to '/home/files/1355472099-50cadce349290.flv':
Stream #0.0: Video: flv, yuv420p, 640x360, q=2-31, pass 2, 200 kb/s, 90k tbn, 25 tbc
Stream #0.1: Audio: adpcm_swf, 44100 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
-------------------------------
RESULT
-------------------------------
Execute error. Output for file "/home/public_html/files/video_1355472099.avi" was found, but the file contained no data. Please check the available codecs compiled with FFmpeg can support this type of conversion. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().
But if I manually used this command then its working
/usr/local/bin/ffmpeg -i '/home/public_html/files/video_1355440448.m4v' -s '640x360' -sameq -ab '64k' -ar '44100' -f 'flv' -y /home/public_html/files/video_1355440448.flv
This is because you have two streams and output will be encoding then resizing, see your output messages:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
... you use adpcm_swf audio and yuv420p video
The answer is very simple, you need to put copy as your audio codec ...
See my example with video mpeg4,yuv420p and audio ac3 ...
ffmpeg -i input.mkv -vf scale=720:-1 -acodec copy -threads 12 output.mkv
this will change first size = 720 with aspect ratio = -1 (unknown). Also you need to use:
-acodec copy -threads 12
If don't use this you will have one error.
For example: When I used it, the output encoding messages show me this and it works well:
[h624 # 0x874e4a0] missing picture in access unit93 bitrate=1034.4kbits/s
Last message repeated 1163 times5974kB time=53.47 bitrate= 915.3kbits/s
You need to use for flv format file, something like this:
ffmpeg -i input.mp4 -c:v libx264 -crf 19 output.flv
You are given an error message
[flv # 0x68b1a80] requested bitrate is too low
You need to change bitrate to a valid. It is better if you use a different codec
-acodec libmp3lame
And remove the option -sameq. This option does NOT mean 'same quality'. Actually means 'same quantizers'!
I had a similar problem due to size constraints. The original image size was strange (width=1343), meaning that when I tried to specify a new size with -s, any rounding error caused problems. Make sure that the new image size can have the exact same aspect ratio!
I have got the same issue
- requested bitrate is too low
and just resolved this issue by lowering down the bit rate
by adding -b:a 32k

Resources