Commit Graph

602 Commits

Author SHA1 Message Date
James Almer
ee3d6a20f6 ffmpeg: Allocate (In|Out)putStream.filter_frame early
Based on a commit by Andreas Rheinhardt.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-19 11:21:04 -03:00
Chad Fraleigh
a185b526a9 fftools: Constify values from av_dict_get()
Treat values returned from av_dict_get() as const, since they are
internal to AVDictionary.

Signed-off-by: Chad Fraleigh <chadf@triularity.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 19:43:32 +01:00
Paul B Mahol
e5367b481b ffmpeg: fix loosing gaps between audio frame timestamps when filtering 2021-11-18 12:54:17 +01:00
Anton Khirnov
bd55552d69 ffmpeg: rewrite setting the stream disposition
Currently, the code doing this is spread over several places and may
behave in unexpected ways. E.g. automatic 'default' marking is only done
for streams fed by complex filtergraphs. It is also applied in the order
in which the output streams are initialized, which is effectively
random.

Move processing the dispositions at the end of open_output_file(), when
we already have all the necessary information.

Apply the automatic default marking only if no explicit -disposition
options were supplied by the user, and apply it to the first stream of
each type (excluding attached pics) when there is more than one stream
of that type and no default markings were copied from the input streams.

Explicitly document the new behavior.

Changes the results of some tests, where the output file gets a default
disposition, while it previously did not.
2021-11-16 10:51:32 +01:00
Anton Khirnov
d4ae2a20e8 cmdutils: add an option for listing stream dispositions 2021-11-16 10:51:32 +01:00
Anton Khirnov
a4c5d241ec lavf: add "disposition" AVOption to AVStream AVClass
Use it to remove custom disposition parsing code from ffmpeg.c
2021-11-16 10:51:32 +01:00
Soft Works
f3b6e3e81a fftools/cmdutils: Print bit depths when executing 'ffmpeg -pix_fmts'
New output looks like this:

Pixel formats:
I.... = Supported Input  format for conversion
.O... = Supported Output format for conversion
..H.. = Hardware accelerated format
...P. = Paletted format
....B = Bitstream format
FLAGS NAME            NB_COMPONENTS BITS_PER_PIXEL BIT_DEPTHS
-----
IO... yuv420p                3             12      8-8-8
IO... yuyv422                3             16      8-8-8
IO... rgb24                  3             24      8-8-8
IO... bgr24                  3             24      8-8-8
IO... yuv422p                3             16      8-8-8
IO... yuv444p                3             24      8-8-8

[..]

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-13 19:55:32 +01:00
Soft Works
ce47ce079a fftools/ffmpeg: Output log message when interactive q command is received
When viewing logs, it's sometimes useful to be able to see whether
execution was ended via q command.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-13 19:55:32 +01:00
Soft Works
bcbedd2749 fftools/ffmpeg: Fix indentation after change
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-13 19:55:32 +01:00
Soft Works
0a99c8322a fftools/ffmpeg: Remove redundant loop
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-13 19:55:32 +01:00
Andreas Rheinhardt
44c65c6cc0 fftools/ffmpeg_opt: Fix copyinkf option name in warning message
Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-10 15:20:12 +01:00
Zane van Iperen
783935de18
fftools/ffplay: don't disable x11 compositing
Prevents desktop stutters caused by the change (specifically on KDE).
We're not a game, we don't actually need it disabled.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-10-29 12:17:41 +10:00
Andreas Rheinhardt
21914e7a4e fftools/ffmpeg, ffmpeg_opt: Allocate (In|Out)putStream.pkt early
Avoids checks lateron in the hot path.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-08 16:03:21 +02:00
Andreas Rheinhardt
f1df856fb6 fftools/ffmpeg: Remove unnecessary av_packet_unref()
avcodec_receive_packet() already unreferences the packet on its own.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-08 15:51:17 +02:00
Andreas Rheinhardt
fb215798c7 fftools/ffmpeg: Fix crash when flushing non-fully setup output stream
The output stream's packet may not have been allocated
at that point. This happens when quitting in the following command line:
$ ./ffmpeg -lavfi abuffer=sample_fmt=u8:sample_rate=48000:channel_layout=stereo -f null -

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-08 12:06:00 +02:00
Andreas Rheinhardt
8a23159797 fftools/ffmpeg, doc/examples: Remove redundant av_packet_unref
av_interleaved_write_frame() already returns blank packets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-03 20:50:49 +02:00
Andreas Rheinhardt
d15efbdd5e fftools/ffmpeg_opt: Remove write-only variable
Unused since 6b35a83214 (the removal of
ffserver).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 18:34:35 +02:00
James Almer
ed1a70469e ffmpeg_filter: don't try to autorotate frames with hwaccel pixel formats
The transpose, rotate, hflip, and vflip filters don't support them.
Fixes ticket #9432.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-21 10:41:16 -03:00
Andreas Rheinhardt
01f106000b fftools/ffmpeg_opt: Add missing AV_OPT_SEARCH_FAKE_OBJ
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 02:19:56 +02:00
Andreas Rheinhardt
1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
Andreas Rheinhardt
3b6c25c925 avfilter/vf_subtitles, fftools/ffmpeg: Don't set sub_text_format
Unnecessary since 1f63665ca5, because
the value the option is set to coincides with the default value.

Found-by: Soft Works <softworkz@hotmail.com>
Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 00:27:47 +02:00
Andreas Rheinhardt
c5c6871a22 fftools/cmdutils: Don't report AV_CODEC_CAP_TRUNCATED
It is deprecated.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 00:21:57 +02:00
James Almer
42fce6fffe ffmpeg: take into account image flipping in the display matrix
This covers only standard rotations.
Fixes part of ticket #6945.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-16 12:57:06 -03:00
James Almer
535a835e51 ffmpeg: use display matrix frame side data for autorotation
And give it priority over stream side data when present.
Fixes part of ticket #6945.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-16 12:46:07 -03:00
James Almer
a8bd8d46f9 cmdutils: round rotation value to nearest integer
As recommended by the doxy for av_display_rotation_get().

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-16 12:46:07 -03:00
Andreas Rheinhardt
6b08ed9f95 fftools/ffprobe: Don't access AVProgram.(start|end)_time
These are internal fields.

Reviewed-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-14 19:17:19 +02:00
Haihao Xiang
6803d8b440 ffmpeg_hw: make hardware selection for filters more user friendly
When a device is derived from a source device, there are at least 2
devices, and usually the derived device is the expected device, so let's
pick the last device if user doesn't specify the filter device with
filter_hw_device option

After applying this patch, the command below can work:

$> ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device
qsv=hw@va -f lavfi -i yuvtestsrc  -vf
format=nv12,hwupload=extra_hw_frames=64 -c:v h264_qsv -y out.h264

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-12 13:33:50 -03:00
Andreas Rheinhardt
b36b703c29 fftools/cmdutils: Use %c, not %s to write a single char
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-05 11:55:01 +02:00
Andreas Rheinhardt
5312208f12 Revert "ffmpeg: force 128k default audio bitrate if nothing is specified and there is no specific default"
This reverts commit 628a73f8f3.

At the time of said commit there was talk of removing the audio bitrate
"ab" option to bring FFmpeg in line with what Libav has done in 2012 in
commit 041cd5a0c5. By having different
option flags for the "ab" and the ordinay bitrate "b" option is is
possible to have different default bitrates for audio and video. In
order to maintain this behaviour and not break user scripts the commit
to be reverted added code to ffmpeg.c that set the bitrate value to the
audio default for audio codecs, but only if AVCodec.defaults didn't
exist (as in this case the default would be codec-default and not
affected by the "ab" removal).

This had the downside of being an API violation, because
AVCodec.defaults is not a public field. Given that the "ab" option
and its audio-specific default value have never been removed,
said API violation can be simply fixed by reverting said commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-05 11:55:01 +02:00
James Almer
7453d3482a ffmpeg: let AVFilterGraph parse the filter_threads option
This way the CLI accepts for "filter_threads" the same values as for the
libavcodec specific option "threads".

Fixes FATE with THREADS=auto which was broken in bdc1bdf3f5.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-04 10:35:07 -03:00
Andreas Rheinhardt
70f06dd63c fftools/cmdutils: Use %c, not %s, to write single char
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-04 08:12:56 +02:00
Andreas Rheinhardt
23b83adb6d fftools/cmdutils: Don't access AV(In|Out)putformat.get_device_list
It is not part of the public API.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-04 08:12:56 +02:00
Andreas Rheinhardt
bc046b715e fftools/ffmpeg: Remove unused fields
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-03 19:43:53 +02:00
Andreas Rheinhardt
f3f9041302 fftools: Remove remnants of resample_opts
These were intended to pass options to auto-inserted avresample
resampling filters. Yet FFmpeg uses swresample for this purpose
(with its own AVDictionary swr_opts similar to resample_opts).
Therefore said options were not forwarded any more since commit
911417f0b34e611bf084319c5b5a4e4e630da940; moreover since commit
420cedd497 avresample options are
not even recognized and ignored any more. Yet there are still
remnants of all of this. This commit gets rid of them.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-03 16:08:19 +02:00
Limin Wang
c500dc7cca fftools/cmdutils: Fix warning for initialization makes integer from pointer without a cast
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-09-01 09:32:24 +08:00
Linjie Fu
7352c370fa Revert "fftools/ffmpeg_filter: fix the flags parsing for scaler"
This reverts commit b3a0548a98.

This breaks the usage of swscale options, scale_sws_opts should be
passed to auto-inserted scale-filters.

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-08-30 21:27:50 +08:00
Anton Khirnov
834b8ad8a3 ffmpeg_filter: do not override -filter_threads with -threads
When both -filter_threads and -threads are specified, the latter takes
effect. Since -threads is an encoder option and -filter_threads is a
filter option, it makes sense for the -filter_threads to take
precedence.
2021-08-29 18:44:09 +02:00
Anton Khirnov
4a0d918c9e ffmpeg: reset the dict iterator before use 2021-08-29 18:43:01 +02:00
Paul B Mahol
8cbed82b2a fftools/ffmpeg_filter: silence valgrind warning 2021-08-25 22:51:32 +02:00
James Almer
590a7e02f0 avcodec: add a Film Grain codec property flag
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:06 -03:00
Andreas Rheinhardt
8f72bb866e fftools/cmdutils: Switch to avfilter_filter_pad_count()
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-20 14:29:15 +02:00
Andreas Rheinhardt
d53d48c799 fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads
Besides being nicer code this also has the advantage of not making
assumptions about the internal implementation: While it is documented
that the AVFilter.inputs and AVFilter.outputs arrays are terminated
by a zeroed sentinel, one is not allowed to infer that one can just
check avfilter_pad_get_name(padarray, i) to see whether one has reached
the sentinel:
It could be that the pointer to the string is contained
in a different structure than AVFilterPad that needs to be accessed
first: return pad->struct->string.
It could be that for small strings an internal buffer in
AVFilterPad is used (to avoid a relocation) whereas for longer strings
an external string is used; this is useful to avoid relocations:
return pad->string_ptr ? pad->string_ptr : pad->interal_string
Or it could be that the name has a default value:
return pad->name ? pad->name : "default"
(This actually made sense for us because the name of most of our
AVFilterPads is just "default"; doing so would save lots of relocations.)

The only thing one is allowed to infer from the existence of the
sentinel is that one is allowed to use avfilter_pad_count() to get
the number of pads. Therefore it is used.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-20 12:52:33 +02:00
Haihao Xiang
51a80aacce ffmpeg_hw: Don't ignore key parameters when initializing a hw device
Currently user may use '-init_hw_device type=name' to initialize a hw
device, however the key parameter is ignored when use '-init_hw_device
type=name,key=value'. After applying this patch, user may set key
parameter if needed.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-17 10:10:07 -03:00
Haihao Xiang
ecee3b07cd qsvdec: add support for HW_DEVICE_CTX method
This allows user set hw_device_ctx instead of hw_frames_ctx for QSV
decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg.

"-hwaccel_output_format format" is applied to QSV decoders after
removing the ad-hoc libmfx code. In order to keep compatibility with old
commandlines, the default format is set to AV_PIX_FMT_QSV, but this
behavior will be removed in the future. Please set "-hwaccel_output_format qsv"
explicitly if AV_PIX_FMT_QSV is expected.

The normal device stuff works for QSV decoders now, user may use
"-init_hw_device args" to initialise device and "-hwaccel_device
devicename" to select a device for QSV decoders.

"-qsv_device device" which was added for workarounding device selection
in the ad-hoc libmfx code still works

For example:

$> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0
-hwaccel qsv -c:v h264_qsv -i input.h264  -f null -

/dev/dri/renderD128 is actually open for h264_qsv decoder in the above
command without this patch. After applying this patch, /dev/dri/card0
is used.

$> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device
qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264
-f null -

device hw of type qsv is not usable in the above command without this
patch. After applying this patch, this command works as expected.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-11 13:45:36 -03:00
Andreas Rheinhardt
c66bb56d9a fftools/cmdutils: Use av_strstart() instead of strncmp()
This also avoids hardcoding lengths.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-11 16:24:36 +02:00
Andreas Rheinhardt
7f660035fe fftools/cmdutils: Remove unused cpu_count
Added in cf12a478b2, but not used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 18:40:46 +02:00
James Almer
44d5e12c8f ffprobe: remove references to frame->pkt_pts
The field was removed during the last major bump.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-07 10:16:07 -03:00
James Almer
d708add98c fftools/ffmpeg_filter: add a return at the end of non-void functions
Fixes compilation with GCC 11 when configured with --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-06 21:22:49 -03:00
Derek Buitenhuis
e6754d2ad2 ffprobe: Rename Audio Service Type 'type' field to 'service_type'
677a030b26 introduced more printable
side data types in ffprobe, however the Audio Service Type side data
'type' field that was introduced aliases an existing field of the same
name within the side data array, which can lead to JSON output like:

    "side_data_list": [
        {
            "side_data_type": "Audio Service Type",
            "type": 0
        },
        {
            "side_data_type": "Stereo 3D",
            "type": "side by side",
            "inverted": 1
        }
    ]

This, while technically valid JSON, is considered bad practice, since it
forces all downstream users to manually parse it and check all types;
it makes simple deserialization impossible. Worse, in som loosely
type languages, it can lead to silent bugs if exising code assumed
it was a different type.

As such, rename this second "type" field to "service_type".

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-08-06 15:48:31 +01:00
Linjie Fu
b3a0548a98 fftools/ffmpeg_filter: fix the flags parsing for scaler
Scaler relys on "-sws_flags" option to pass the flags to swscale
and scale filter. Currently passing "sws_flags=xxx" as a filter
option to scaler leads to an incorrect option parsing.

Check and change the string to "flags=xxx" and dumped flags information.
(Refer to parse_sws_flags())

CMD:
$ffmpeg -v verbose -i input.mp4 -sws_flags lanczos+bitexact+accurate_rnd \
        -vf format=yuv420p,scale=800x600 -an -vframes 10 -f md5 -

Before:
[auto_scaler_0 @ 0x7f96c3808680] w:iw h:ih flags:'' interl:0
[auto_scaler_0 @ 0x7f96c3808680] w:1920 h:1080 fmt:yuvj420p sar:0/1 -> w:1920 h:1080 fmt:yuv420p sar:0/1 flags:0x0
[Parsed_scale_1 @ 0x7f96c3806e40] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:800 h:600 fmt:yuv420p sar:0/1 flags:0x0
MD5=ff1d6091690c6fcd36d458d2a9f648ce

After:
[auto_scaler_0 @ 0x7fe94563b4c0] w:iw h:ih flags:'lanczos+bitexact+accurate_rnd' interl:0
[auto_scaler_0 @ 0x7fe94563b4c0] w:1920 h:1080 fmt:yuvj420p sar:0/1 -> w:1920 h:1080 fmt:yuv420p sar:0/1 flags:0xc0200
[Parsed_scale_1 @ 0x7fe945639d00] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:800 h:600 fmt:yuv420p sar:0/1 flags:0xc0200
MD5=ff1d6091690c6fcd36d458d2a9f648ce

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-08-05 22:23:49 +08:00
Linjie Fu
5b0e6b0d82 fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-08-05 22:23:49 +08:00
Gyan Doshi
c50f5460d2 ffmpeg_opt: restore documented stream selection behaviour
11d3b03fcb added consideration of default stream disposition for audio
and video when choosing the 'best' stream among all the inputs. This can
lead to video streams with lower resolution or audio streams with fewer
channels being selected.

Stream disposition, however, only sets a priority for a stream
among all other streams in the *same input*. It cannot set a priority
for a stream across all inputs.

This patch sets a middle-way and selects the best stream from each file
with default disposition considered. Then it discards disposition weight
and selects best stream as per the original criteria of highest
resolution for video and most channels for audio.
2021-08-01 09:51:07 +05:30
Jan Ekström
4c694093be ffmpeg: fix order between field order autodetection and override
Having the override before autodetection meant that the overridden
value got overwritten by the autodetected result each time,
effectively disabling the ability to utilize the `-top` option
for override purposes.

Somehow I missed this in fbb44bc51a ,
even though the lines were within the context. Probably the code
originally being after this logic had something to do with it,
but previously it only touched the avformat context's codecpar,
which did not affect the encoder codec context whatsoever.

Fixes #9320
Fixes #9339
2021-07-25 22:40:49 +03:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Andreas Rheinhardt
4608f7cc6a Remove unnecessary mem.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:47:57 +02:00
Andreas Rheinhardt
1be3d8a0cb avcodec/avcodec: Stop including channel_layout.h in avcodec.h
Also include channel_layout.h directly wherever used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:31 +02:00
Andreas Rheinhardt
57b5ec6ba7 avcodec/avcodec: Stop including bsf.h in avcodec.h
Also include bsf.h directly wherever it is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:16 +02:00
Thilo Borgmann
c1bf56a526 lavu/cpu: Use av_cpu_ prefix 2021-07-20 10:31:41 +02:00
Thilo Borgmann
05c9f6f4ef fftools/ffmpeg: Fix runlength for strncmp() 2021-07-19 21:23:02 +02:00
Gyan Doshi
6f20685228 ffmpeg: delay readrate enforcement for decoded streams
Read rate enforcement delayed till first decoded frame is obtained, to
speed up init of output streams.

Thanks to Linjie Fu <linjie.justin.fu@gmail.com> for the initial patch.
2021-07-19 12:54:55 +05:30
Andreas Rheinhardt
3ccfd27f1d fftools/ffmpeg: Fix declaration-after-statement warning
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-18 21:09:02 +02:00
Shiwang.Xie
694545b6d5 fftools/ffmpeg: fix -t inaccurate recording time
if input start time is not 0 -t is inaccurate doing stream copy,
will record extra duration according to input start time.
it should base on following cases:

input video start time from 60s, duration is 300s,
1. stream copy:
       ffmpeg -ss 40 -t 60 -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 100 and set ts_offset to -100,
   process_input() will offset pkt->pts with ts_offset to make it 0,
   so when do_streamcopy() with -t, exits when ist->pts >= recording_time.

2. stream copy with -copyts:
       ffmpeg -ss 40 -t 60 -copyts -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 100 and set ts_offset to 0,
   process_input() will keep raw pkt->pts as ts_offset is 0,
   so when do_streamcopy() with -t, exits when
   ist->pts >= (recording_time+f->start_time+f->ctx->start_time).

3. stream copy with -copyts -start_at_zero:
       ffmpeg -ss 40 -t 60 -copyts -start_at_zero -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 120 and set ts_offset to -60 as start_to_zero option,
   process_input() will offset pkt->pts with input file start time,
   so when do_streamcopy() with -t, exits when ist->pts >= (recording_time+f->start_time).

0      60     40      60                     360
|_______|_____|_______|_______________________|
      start   -ss     -t

This fixes ticket #9141.

Signed-off-by: Shiwang.Xie <shiwang.xie666@outlook.com>
2021-07-18 09:59:02 +05:30
Gyan Doshi
c320b78e95 ffmpeg: add option readrate
Allows to read inputs at arbitrary rates.
-re is equivalent to -readrate 1

Tested with -copyts {+ start_at_zero}, -ss, streamcopied & decoded streams.
2021-07-17 20:34:21 +05:30
Thilo Borgmann
cf12a478b2 fftools/cmdutils.c: Add cmd line option to override detection of cpu count. 2021-07-16 10:06:23 +02:00
Keyun Tong
b7266302a4 fftools/ffmpeg: Add new variant source_no_drop to the force_key_frames option
Suggested-By: ffmpeg@fb.com
2021-07-16 09:50:19 +02:00
James Almer
022e50c002 ffprobe: use quotation marks in the xml header output
xmllint (silently) replaces the ' with " when fixing and validating the output
of ffprobe in fate-ffprobe_xsd.

Reviewed-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-15 23:46:40 -03:00
Gyan Doshi
79ebdbb9b9 ffmpeg: add option recast_media
Allows forcing decoders of different media type.
Needed to decode media data muxed as data streams.
2021-07-11 11:54:20 +05:30
James Almer
94af6414ab ffmpeg: silence a thread_safe_callbacks deprecation warning
Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-10 21:57:44 -03:00
zhilizhao
cf1746d779 ffmpeg_videotoolbox: skip memory copy if hwaccel_output_format match
Simple test results:

Command:
./ffmpeg -y -hwaccel videotoolbox -hwaccel_output_format videotoolbox_vld \
  -i test.mp4 -an -c:v h264_videotoolbox -benchmark out.mp4

Before:
frame= 1221 fps= 66 q=-0.0 Lsize=    3144kB time=00:00:20.33 bitrate=1266.6kbits/s dup=4 drop=0 speed= 1.1x
bench: utime=2.714s stime=1.218s rtime=18.574s

After:
frame= 1221 fps=137 q=-0.0 Lsize=    3144kB time=00:00:20.33 bitrate=1266.4kbits/s dup=4 drop=0 speed=2.28x
bench: utime=1.450s stime=1.440s rtime=8.924s

It has limited usecase since there is no video filter support, so
a log message is added to notify the user.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
2021-06-10 19:54:03 +08:00
Valerii Zapodovnikov
3249b96342 fftools/ffplay: 240M matrix is not the same as BT.601
Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-06-08 21:55:14 +02:00
Andreas Rheinhardt
d29541c90a fftools/ffprobe: Remove redundant check before avcodec_free_context()
Besides being unnecessary it is also safer: If the error for an
unrecognized option were triggered (which seems to be impossible right
now), it might be that the stream whose codecpar is accessed is NULL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
James Almer
ab4f299e23 fftools/ffmpeg: remove usage of internal timestamp AVStream fields
They should not be accessed outside of libavformat.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-04 22:36:39 -03:00
Jan Ekström
ec20b81302 ffmpeg: return no chosen output if an uninitialized stream is unavailable
Otherwise the rate emulation logic in `transcode_step` never gets
hit, and the unavailability flag never gets reset, leading to an
eternal loop with some rate emulation use cases.

This change was missed during the rework of ffmpeg.c, in which
encoder initialization was moved further down the time line in
commit 67be1ce0c6 . Previously,
as the encoder initialization had happened earlier, this state was
not possible (flow getting as far as hitting the rate emulation logic,
yet not having the encoder initialized yet).

Fixes #9160
2021-05-13 17:59:35 +03:00
Anton Khirnov
677a030b26 ffprobe: support printing more packet side data types
Specifically WebVTT subtitle data, CPB properties, audio service type
and mpegts stream id.
2021-05-09 10:59:21 +02:00
Anton Khirnov
544631cab1 ffprobe: only hash extradata when it is present
Passing zero-sized/NULL buffers to av_hash_update() is invalid and may
crash with certain hashes.
2021-05-09 10:59:21 +02:00
Gyan Doshi
7c451b609c ffprobe: add option to control optional fields display 2021-05-05 15:04:54 +05:30
James Almer
4d3474432f ffmpeg: stop accessing private AVStream.codec_info_nb_frames
Use AVSTREAM_EVENT_FLAG_NEW_PACKETS instead, which should provide the
same information in this case.
Finishes removing all uses of this field as started by 87f0c8280c.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-02 00:44:19 -03:00
James Almer
3749eede66 avformat: remove deprecated AVStream.codec
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:47:24 -03:00
Andreas Rheinhardt
8b3e6ce5f4 avdevice/avdevice: Constify av_*_device_next API
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:14 -03:00
Andreas Rheinhardt
d7e0d428fa avdevice/avdevice: Constify avdevice_list_input_sources/output_sinks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:14 -03:00
Andreas Rheinhardt
14fa0a4efb avformat/avformat: Constify AVFormatContext.*_codec pointers
This also allows to exclusively use pointers to const AVCodec in
fftools/ffmpeg_opt.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Andreas Rheinhardt
420cedd497 libavresample: Remove deprecated library
Deprecated in c29038f304.
The resample filter based upon this library has been removed as well.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Andreas Rheinhardt
ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Andreas Rheinhardt
56450a0ee4 avformat: Constify the API wrt AV(In|Out)putFormat
Also constify AVProbeData.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:08 -03:00
Tobias Rapp
f10da58ec3 fftools/ffprobe: Remove check on show_frames and show_packets in XML writer
The "packets_and_frames" element has been added to ffprobe.xsd in
0c9f0da0f7 but apparently removing the
check in ffprobe.c has been forgotten.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2021-04-16 08:40:09 +02:00
James Almer
67ed3cddf1 ffprobe: only print exported private decoder options
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-14 20:05:16 -03:00
Andreas Rheinhardt
4e39cd67b7 fftools/ffmpeg_filter: Fix check for mjpeg encoder
The MJPEG encoder supports some pixel format/color range combinations
only when strictness is set to unofficial or less. Before commit
059fc2d9da said encoder's pix_fmts array
only included the pixel formats supported with default strictness.
When strictness was <= unofficial, fftools/ffmpeg_filter.c used
an extended list of pixel formats instead of the encoder's including
the pixel formats only supported when strictness <= unofficial.

Said commit turned the logic around: The encoder's pix_fmts array now
included all pixel formats and fftools/ffmpeg_filter.c instead used
a small list of all pixel formats supported when strictness is >
unofficial and the encoder's pixel formats instead. In particular,
the codec's pix_fmt is not used when strictness is normal.

This works for the mjpeg encoder; yet it did not work for other
(hardware-based) mjpeg encoders, because the check for whether one is
using the MJPEG encoder is wrong: It just checks the codec id.
So if one used strict unofficial with a hardware-accelerated MJPEG
encoder before commit 059fc2d9da, the unofficial (non-hardware)
pixel formats of the MJPEG encoder would be used; since said commit
the codec's pixel formats are overridden at ordinary strictness
by the ordinary MJPEG pixel formats. This leads to format conversion
errors lateron which were reported in #9186.

The solution to this is to check AVCodec.name instead of its id.

Fixes ticket #9186.

Tested-by: Eoff, Ullysses A <ullysses.a.eoff@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-13 21:58:25 +02:00
Andreas Rheinhardt
4782124b90 fftools/ffmpeg_filter: Don't needlessly copy string
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:53:40 +02:00
Andreas Rheinhardt
6b72410e01 fftools/ffmpeg_filter: Don't write string that is never used
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:53:33 +02:00
Andreas Rheinhardt
80399c7910 fftools/ffmpeg_filter: Avoid allocations when configuring output filters
Use an AVBPrint to handle the (typically short) strings involved here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:51:50 +02:00
Andreas Rheinhardt
059fc2d9da avcodec/mjpegenc: Include all supported pix_fmts in mpegenc pix_fmts
Currently said list contains only the pixel formats that are always
supported irrespective of the range and the value of
strict_std_compliance. This makes the MJPEG encoder an outlier as all
other codecs put all potentially supported pixel formats into said list
and error out if the chosen pixel format is unsupported. This commit
brings it therefore in line with the other encoders.

The behaviour of fftools/ffmpeg_filter.c has been preserved. A more
informed decision would be possible if colour range were available
at this point, but it isn't.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:48:41 +02:00
Anton Khirnov
f6ea2ee005 fftools/ffmpeg: copy average framerate for streamcopy, when known 2021-04-08 11:03:15 +02:00
Anton Khirnov
0214da22ca fftools/ffmpeg: when framerate is set, prefer its inverse as output timebase
Codec timebase is not well-defined for streamcopy, so it should only be
used as the last resort.
2021-04-08 11:03:15 +02:00
Andreas Rheinhardt
461d04d956 fftools/ffprobe: Add missing dispositions
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-03-31 11:51:58 +02:00
James Almer
82bd02a2c7 fftools/ffmpeg: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:38 -03:00
James Almer
4aa586944e fftools/ffprobe: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:38 -03:00
Anton Khirnov
b334fd39c9 cmdutils: replace strncpy() with direct assignment
Only one character is actually rewritten.

Fixes truncation warnings, such as
warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
in gcc 10.2.0
2021-03-16 10:41:01 +01:00
Anton Khirnov
7d09579190 lavc: rename AV_CODEC_CAP_AUTO_THREADS->AV_CODEC_CAP_OTHER_THREADS
This cap is currently used to mark multithreading-capable codecs that
wrap external libraries with their own multithreading code. The name is
highly confusing for our API users, since libavcodec ALWAYS handles
thread_count=0 (see commit message in previous commit). Therefore rename
the cap and update its documentation to make its meaning clear.

The old name is kept deprecated until next+1 major bump.
2021-03-16 10:38:41 +01:00
Marton Balint
573f05a753 fftools/ffplay: do not write out of rdft visualization texture
If the window is resized it was possible that xpos pointed outside the
visualization texture. By rearranging the overflow check we make sure this (and
a crash) does not happen.

We also don't have to use xleft for start position, as that is 0 anyways, and
if we ever want to take into account xleft then the texture should be
positioned accordingly when rendering.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-10 20:01:03 +01:00
Jan Ekström
c8c6c9f5d9 ffprobe: switch to av_bprint_escape for XML escaping
Additionally update the result of the ffprobe XML writing test.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-03-05 19:45:00 +02:00
Andreas Rheinhardt
988deae6da fftools: Switch to const AVCodec * where possible
The obstacle to do so was in filter_codec_opts: It uses searches
the AVCodec for options via the AV_OPT_SEARCH_FAKE_OBJ method, which
requires using a void * that points to a pointer to a const AVClass.
When using const AVCodec *, one can not simply use a pointer that points
to the AVCodec's pointer to its AVClass, as said pointer is const, too.
This is fixed by using a temporary pointer to the AVClass.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-02 08:20:10 +01:00
Andreas Rheinhardt
bd85c63d1d fftools/cmdutils: Use av_strstart instead of strncmp
It makes the intent clearer and avoids searching for a delimiter
in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:14:21 +01:00
Andreas Rheinhardt
cb5a223a7e fftools/ffmpeg, ffplay: Don't set refcounted_frames
It only affects the old and deprecated avcodec_decode_(video2|audio4)
API which is no longer used here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:14:21 +01:00
Andreas Rheinhardt
5ad0eb936c fftools/ffmpeg_filter: Don't use deprecated function
avcodec_find_best_pix_fmt_of_2 has been moved to libavutil in
617e866e25.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-26 18:28:26 +01:00
Anton Khirnov
82a2cbf820 ffprobe: stop setting AVCodecContext.framerate
That field is supposed to be exported by decoders, it makes no sense for
a user to set it.
2021-02-22 11:14:40 +01:00
Anton Khirnov
313c91beb8 ffprobe: stop printing deprecated fields
The FF_API macros are private and must not be used by external callers.
As the fields in question are to be removed without replacement, just
drop them.
The fields are:
AVPacket.convergence_duration
AVCodecContext.time_base
AVCodecContext.timecode_frame_start
AV_PIX_FMT_FLAG_PSEUDOPAL pixel descriptor flag
2021-02-22 11:14:29 +01:00
Anton Khirnov
04f49645a5 ffprobe: drop code accessing deprecated AVStream.codec 2021-02-22 11:14:17 +01:00
Anton Khirnov
cb789fd2b3 ffprobe: do not use deprecated AVStream.codec for max bitrate
Use the decoder context instead.
2021-02-22 11:13:50 +01:00
Anton Khirnov
65b08aa19c ffprobe: remove an unnecessary deprecation guard
The code it is guarding is not accessing anything deprecated
(disregarding the fact that a library caller must not use FF_API
deprecation guards).
2021-02-22 11:13:40 +01:00
Marton Balint
9edec9206a fftools/ffplay: reindent and some minor cosmetics
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-02-19 21:30:13 +01:00
Marton Balint
36d671438a fftools/ffplay: use av_packet_alloc() to allocate packets
Heavily based on a patch by James Almer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-02-19 21:30:13 +01:00
Marton Balint
44fb1f845d fftools/ffplay: use context AVPacket in decoder_decode_frame()
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-02-19 21:30:13 +01:00
Marton Balint
a29928e646 fftools/ffplay: get rid of flush_pkt
The packet serial can be used instead to detect when a flush is needed.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-02-19 21:30:13 +01:00
Gyan Doshi
d99cc17825 ffmpeg: add -fpsmax to clamp output framerate
Useful when encoding in batch or with aberrant inputs.
2021-02-05 22:54:18 +05:30
Limin Wang
81c462ad95 avformat/mxfenc: prefer to use the configured metadata
The metadata company_name, product_name, product_version from input
file will be deleted to avoid overwriting information
Please to test with below commands:
./ffmpeg -i ../fate-suite/mxf/Sony-00001.mxf -c:v copy -c:a copy out.mxf
and
./ffmpeg -i ../fate-suite/mxf/Sony-00001.mxf -c:v copy -c:a copy \
        -metadata company_name="xxx" \
        -metadata product_name="xxx" \
        -metadata product_version="xxx" \
        out.mxf

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-02-05 09:27:06 +08:00
Andreas Rheinhardt
2367affc2c fftools/ffmpeg_filter: Make functions only used locally static
Also remove some declarations of inexistent functions while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-02 23:53:30 +01:00
Andreas Rheinhardt
2166d8d6b2 fftools/ffmpeg_filter: Remove ist_in_filtergraph
Unused since af1761f7b5.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-02 23:53:30 +01:00
Andreas Rheinhardt
a40c158eda fftools/ffmpeg_filter: Remove choose_sample_fmt
Unused since 6b35a83214.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-02 23:53:30 +01:00
Gyan Doshi
d16b0a4bf0 ffmpeg: remove dead code for -vol
It is applied via configure_input_audio_filter()
2021-01-31 17:21:32 +05:30
James Almer
c3f3b562c9 avcodec: remove long dead debug_mv code
FF_API_DEBUG_MV has been zero since ffmpeg 4.0

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-25 19:03:22 -03:00
James Almer
a423bc9dc2 ffmpeg_opts: remove lowres check
The st->codec values are updated based on the lowres factor by
avformat_find_stream_info() when it runs an instance of the decoder internally,
and the same thing happens in ffmpeg.c when we open ist->dec_ctx with
avcodec_open2(), so these assignments are redundant.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-21 10:22:41 -03:00
Andriy Gelman
35eb5eeca8 ffmpeg: use sigaction() instead of signal() on linux
As per signal() help (man 2 signal) the semantics of using signal may
vary across platforms. It is suggested to use sigaction() instead.

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-01-16 16:21:09 -05:00
Gyan Doshi
0fff6c039c doc/ffmpeg: document max_error_rate 2021-01-10 19:14:37 +05:30
Andreas Rheinhardt
2c6f532e0a Mark some pointers as const
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-01 15:25:48 +01:00
Gyan Doshi
9a0f5e412a ffmpeg: delay first stats
Wait for all output files to be initialized before printing first stats.

Avoids breaking output file dump report.
2020-12-24 10:04:38 +05:30
Gyan Doshi
3e47bbad56 ffmpeg: don't delay printing initial stats
The first stats is printed after the initial stats_period has elapsed. With a large period,
it may appear that ffmpeg has frozen at startup.

The initial stats is now printed after the first transcode_step.
2020-12-23 00:41:20 +05:30
Gyan Doshi
842714b5cb ffmpeg: add option stats_period
At present, progress stats are updated at a hardcoded interval of
half a second. For long processes, this can lead to bloated
logs and progress reports.

Users can now set a custom period using option -stats_period
Default is kept at 0.5 seconds.
2020-12-23 00:41:07 +05:30
Anton Khirnov
50b49f833a ffmpeg: stop accessing deprecated stream-embedded codec context 2020-12-10 09:53:35 +01:00
Mohammad Izadi
6e6d4c75fc fftools/ffprobe: add support for HDR10+ metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2020-12-05 19:20:11 -03:00
Marton Balint
87c1b74233 fftools/cmdutils: also print warnings when using -sinks and -sources
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-12-03 18:32:57 +01:00
Anton Khirnov
a83098ab03 avcodec: deprecate thread_safe_callbacks
They add considerable complexity to frame-threading implementation,
which includes an unavoidably leaking error path, while the advantages
of this option to the users are highly dubious.

It should be always possible and desirable for the callers to make their
get_buffer2() implementation thread-safe, so deprecate this option.
2020-11-27 15:46:50 +01:00
Limin Wang
3da35b7cc7 fftools/ffmpeg: fix the wrong bitrate and speed stats
The bitrate and speed stats are wrong if the copyts is enabled.
Please test with below command:
wget http://samples.mplayerhq.hu/MPEG2/foxksaz.ts
./ffmpeg -y -copyts -i ./foxksaz.ts -c:v libx264 -x264opts \
    nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \
    1000k  -c:a mp2 -muxrate 4500k  -vframes 1000 test.ts

before:
frame= 1000 fps=112 q=-1.0 Lsize=    9063kB time=09:10:12.41 bitrate=   2.2kbits/s speed=3.7e+03x
after:
frame= 1000 fps=112 q=-1.0 Lsize=    9062kB time=00:00:15.78 bitrate=4703.4kbits/s speed=1.77x

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-31 09:49:10 +08:00
Jan Ekström
fbb44bc51a ffmpeg: move field order decision making to encoder initialization
We now have the possibility of getting AVFrames here, and we should
not touch the muxer's codecpar after writing the header.

Results of FATE tests change as the MXF and Matroska muxers actually
write down the field/frame coding type of a stream in their
respective headers. Before this change, these values in codecpar
would only be set after the muxer was initialized. Now, the
information is also available for encoder and muxer initialization.
2020-10-29 16:59:49 +02:00
Jan Ekström
7369595c55 ffmpeg: pass decoded or filtered AVFrame to output stream initialization
Additionally, reap the first rewards by being able to set the
color related encoding values based on the passed AVFrame.

The only tests that seem to have changed their results with this
change seem to be the MXF tests. There, the muxer writes the
limited/full range flag to the output container if the encoder
is not set to "unspecified".
2020-10-29 16:59:49 +02:00
Jan Ekström
67be1ce0c6 ffmpeg: move A/V non-streamcopy initialization to a later point
- For video, this means a single initialization point in do_video_out.
- For audio we unfortunately need to do it in two places just
  before the buffer sink is utilized (if av_buffersink_get_samples
  would still work according to its specification after a call to
  avfilter_graph_request_oldest was made, we could at least remove
  the one in transcode_step).

Other adjustments to make things work:
- As the AVFrame PTS adjustment to encoder time base needs the encoder
  to be initialized, so it is now moved to do_{video,audio}_out,
  right after the encoder has been initialized. Due to this,
  the additional parameter in do_video_out is removed as it is no
  longer necessary.
2020-10-29 16:59:49 +02:00
Jan Ekström
3360c9a567 ffmpeg: move AVFrame time base adjustment into a function
This will have to be called later for video down the line.
2020-10-29 16:59:48 +02:00
Jan Ekström
453b2f3c15 ffmpeg: add a data size threshold for muxing queue size
This way the old max queue size limit based behavior for streams
where each individual packet is large is kept, while for smaller
streams more packets can be buffered (current default is at 50
megabytes per stream).

For some explanation, by default ffmpeg copies packets from before
the appointed seek point/start time and puts them into the local
muxing queue. Before, it getting utilized was much less likely
since as soon as the filter chain was initialized, the encoder
(and thus output stream) was also initialized.

Now, since we will be pushing the encoder initialization to when the
first AVFrame is decoded and filtered - which only happens after
the exact seek point is hit as packets are ignored until then -
this queue will be seeing much more usage.

In more layman's terms, this attempts to fix cases such as where:
- seek point ends up being 5 seconds before requested time.
- audio is set to copy, and thus immediately begins filling the
  muxing queue.
- video is being encoded, and thus all received packets are skipped
  until the requested time is hit.
2020-10-29 16:59:48 +02:00
Anton Khirnov
87f0c8280c ffmpeg.c: stop accessing private AVStream.codec_info_nb_frames
Use AVSTREAM_EVENT_FLAG_NEW_PACKETS instead, which should provide the
same information in this case.
2020-10-28 13:58:32 +01:00
Anton Khirnov
201b1246e2 ffmpeg.c: rename 'area' to 'score'
Other factors besides area are used to pick the best video stream, so
the name 'area' is misleading.
2020-10-28 13:57:38 +01:00
Jan Ekström
86228ebdb2 ffmpeg: deduplicate init_output_stream usage logic
Adds a wrapper function, which handles any errors depending on how
fatal a failure would be.
2020-10-17 11:55:55 +03:00
Marton Balint
babbb5a4ba fftools/ffprobe: use av_timecode_make_smpte_tc_string2
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Andreas Rheinhardt
0086432fc7 fftools, libavcodec, libavfilter: Add const to some AVCodec *
The user has no business modifying the underlying AVCodec.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-11 14:42:36 +02:00
Zhao Zhili
99e12b5736 ffplay: fix autoexit doesn't work in the case of pb->error
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-08 19:59:17 +02:00
Nicolas George
697fb09e3d ffmpeg: add auto_conversion_filters option. 2020-09-08 14:16:08 +02:00
Andreas Rheinhardt
426c16d61a fftools/ffmpeg: Fix leak of AVFilterInOut in case of error
The AVFilterInOuts normally get freed in init_output_filter() when
the corresponding streams get created; yet if an error happens before
one reaches said point, they leak. Therefore this commit makes
ffmpeg_cleanup free them, too.

Fixes ticket #8267.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-23 19:57:42 +02:00
Nicolas George
973540118a ffplay: do not set redundant channel count on abuffersink. 2020-08-20 12:49:08 +02:00
Marton Balint
53a4620fba fftools/ffmpeg: make specifying thread_queue_size turn on threaded input
Threaded input can increase smoothness of e.g. x11grab significantly. Before
this patch, in order to activate threaded input the user had to specify a
"dummy" additional input, with this change it is no longer required.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-07-29 23:10:12 +02:00
Derek Buitenhuis
f43a8112dd ffprobe: Allow unknown format private AVOptions
This useful, because by ffprobe's very nature, you use it to probe
a file and find out what it is. Requiring every format private option
to be known to the demuxer forces one to run ffprobe twice, if one
wants to use ffprobe in a generic way.

For example, say one wants to probe all user-uploaded files, while
also ignoring edit lists for any MP4s that are uploaded. Currently,
you'd have to run ffprobe twice: once to identify the format, and
once again to actually probe the metadata you want. After this
patch, you could set -ignore_editlist 1 on every call and only
probe once.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-07-02 19:24:56 +01:00
Linjie Fu
0b511bd9a5 fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale
Currently, ffmpeg inserts scale filter by default in the filter graph
to force the whole decoded stream to scale into the same size with the
first frame. It's not quite make sense in resolution changing cases if
user wants the rawvideo without any scale.

Using autoscale/noautoscale as an output option to indicate whether auto
inserting the scale filter in the filter graph:
    -noautoscale or -autoscale 0:
    disable the default auto scale filter inserting.

ffmpeg -y -i input.mp4 out1.yuv -noautoscale out2.yuv -autoscale 0 out3.yuv

Update docs.

Suggested-by:  Mark Thompson <sw@jkqxz.net>
Reviewed-by:   Nicolas George <george@nsup.org>
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-06-18 16:31:09 +08:00
Anton Khirnov
e0fbb6cf2b fftools: switch to the new child class iteration API 2020-06-10 12:36:44 +02:00
Andriy Gelman
6cd198860d fftools/ffmpeg: update text requesting samples
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
2020-06-01 14:39:52 -04:00
Marton Balint
efe7a59364 fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-26 21:50:50 +02:00
Anton Khirnov
f30a41a608 Stop hardcoding align=32 in av_frame_get_buffer() calls.
Use 0, which selects the alignment automatically.
2020-05-22 14:38:57 +02:00
Anton Khirnov
8cfab9fa8c cmdutils: drop libavformat/network.h include
It is not a public header and has not been used since
10173c0e58
2020-05-22 14:38:57 +02:00
James Almer
cbb1760afa fftools/cmdutils: remove lossless and intra only capability entries from print_codec()
They are codec properties, not encoder capabilities.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-21 12:32:15 -03:00
James Almer
0a3ba58b44 fftools/ffmpeg_filter: check the codec's descriptor to see if it's lossless
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-21 12:32:15 -03:00
Limin Wang
683e421bcf fftools/ffmpeg: use local variable with same contents directly
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-06 23:02:00 +08:00
Mark Thompson
706ed34ce7 ffmpeg: Don't require a known device to pass a frames context to an encoder
The previous code here did not handle passing a frames context when
ffmpeg itself did not know about the device it came from (for example,
because it was created by device derivation inside a filter graph), which
would break encoders requiring that input.  Fix that by checking for HW
frames and device context methods independently, and prefer to use a
frames context method if possible.  At the same time, revert the encoding
additions to the device matching function because the additional
complexity was not relevant to decoding.

Also fixes #8637, which is the same case but with the device creation
hidden in the ad-hoc libmfx setup code.
2020-05-03 16:04:27 +01:00
Marton Balint
f821ae8591 fftools/ffmpeg: use a bsf list instead of individual bsfs
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-02 19:14:08 +02:00
vectronic
a75924ec88 fftools/ffprobe: show closed caption info in the stream dump
Signed-off-by: vectronic <hello.vectronic@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-02 19:14:08 +02:00
Mark Thompson
79c173cc19 ffmpeg: Remove the hw_device_ctx global
The ad-hoc libmfx setup code is the only place its still used, so move it
into that file.
2020-04-26 18:38:25 +01:00
Mark Thompson
8abd3b2028 ffmpeg: Use hardware config metadata with encoders
This can support encoders which want frames and/or device contexts.  For
the device case, it currently picks the first initialised device of the
desired type to give to the encoder - a new option would be needed if it
were necessary to choose between multiple devices of the same type.
2020-04-26 18:38:25 +01:00
Mark Thompson
e254212405 ffmpeg: Make filter hardware device selection clearer
Also move it into a dedicated function in the hardware file.
2020-04-26 18:38:25 +01:00
Peter Ross
6cfb33f976 ffplay: set stream_index to -1 earlier to prevent segfault
Signed-off-by: Peter Ross <pross@xvid.org>
Reviewed-by: Marton Balint <cus@passwd.hu>
2020-04-25 12:11:11 +10:00
Jun Zhao
e689a759c6 fftools/ffprobe: support DOVI sidedata
support DOVI sidedata.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-04-23 08:06:07 +08:00
Anton Khirnov
4cde83c780 cmdutils: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 14:50:03 +00:00
Andreas Rheinhardt
889ad93c88 fftools/ffmpeg_opt: Check attachment filesize
The data of an attachment file is put into an AVCodecParameter's
extradata. The corresponding size field has type int, yet there was no
check for the size to fit into an int. As a consequence, it was possible
to create extradata with negative size (by using a big enough max_alloc).

Other errors were also possible: If SIZE_MAX < INT64_MAX (e.g. on 32bit
systems) then the file size might be truncated before the allocation;
and avio_read() takes an int, too, so one would not have read as much
as one desired.

Furthermore, the extradata is now padded as is required.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-17 01:34:07 +02:00
Carl Eugen Hoyos
d5bf704f50 ffmpeg: Do not clip timestamps at LONG_MAX.
Fixes ticket #8612.
2020-04-15 19:59:13 +02:00
Jun Zhao
5633f9a8a2 fftools: fix hwaccels option dump redundancy
When QSV is enabled in FFmpeg, the command "ffmpeg -hwaccels" shows a
duplicate entry in acceleration methods for QSV:

Hardware acceleration methods:
vaapi
qsv
drm
opencl
qsv

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-04-14 11:42:29 +08:00
Marton Balint
4e0cf81b49 fftools/ffmpeg: also flush encoders which have a variable frame size
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-13 00:31:24 +02:00
Michael Niedermayer
64c59b626f fftools/ffmpeg: Disable copy_ts on timestamp wraparound
This allows handling more than 26.5h of mpeg* input

Fixes: Ticket 7876

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-04 22:09:46 +02:00
Gyan Doshi
b195b5f2ba ffplay: flush correct stream after stats update
Stats and logs are written to stderr, not stdout.
2020-04-04 16:01:57 +05:30
Gyan Doshi
2d6a89872e ffplay: always show stats at all log levels if requested by user
Since 3b491c5a50, stats would be hidden if loglevel was lower than
info, even if -stats was set.

Fixes #6962
2020-04-04 15:17:24 +05:30
Carl Eugen Hoyos
b5a8ad5623 ffmpeg: Print an error instead of a debug message on exit.
Reported-by: Forum user NewPlaza
2020-03-31 00:41:13 +02:00
Andreas Rheinhardt
3362330741 ffplay, avcodec, avformat: Don't initialize before av_packet_ref()
It already initializes the packet.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-28 04:17:20 +01:00
Andreas Rheinhardt
d9f38b99dd fftools/ffmpeg_opt: Fix [u]int64_t specifier string
PRId64 and PRIu64 already expand to the complete specifier; adding
another 'd' at the end is wrong and just leads to warnings that say
that only an option like '-frames:v 2d' will be used, although said
option won't be accepted at all ('Expected int64 for frames:v but found
2d').

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-19 20:06:12 +01:00
Paul B Mahol
d64cbd4fda remove CHAR_MIN/CHAR_MAX usage
It is not needed at all.
2020-03-17 22:46:36 +01:00
Jan Ekström
7ba3ea212f ffmpeg: explicitly handle sub2video subpicture initialization
Each time the sub2video structure is initialized, the sub2video
subpicture is initialized together with the first received heartbeat.
The heartbeat's PTS is utilized as the subpicture start time.

Additionally, add some documentation on the stages.
2020-03-16 19:35:17 +02:00
Marton Balint
60e2634662 fftools/ffmpeg_opt: remove bogus warning of multiple -af and -vf usage
This is redundant after the last patch and also fixes ticket #7712.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-08 18:38:31 +01:00
Marton Balint
5d7788f9e8 fftools/ffmpeg_opt: warn about overwritten parsed options
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-08 18:38:31 +01:00
Marton Balint
af7ec793d4 fftools/ffplay: fix possible memory leak in decoder
Fixes ticket #8549.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-08 12:56:08 +01:00
Timo Rothenpieler
cb3c77cfee ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid
This ensures old commandlines using -hwaccel cuvid don't break due to
the recent removal of the the cuvid-specific hwaccel bringup.
2020-03-07 13:13:55 +01:00
James Almer
60b1f85b67 ffmpeg: remove superfluous custom cuvid hwaccel
It's a duplicate of the properly implemented nvdec libavcodec hwaccel

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-03-03 18:11:28 -03:00
Andreas Rheinhardt
21265f42ec fftools/ffmpeg_opt: Fix leak of options when parsing options fails
Fixes #8094.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-29 22:31:01 +01:00
Michael Niedermayer
4f4ad33d96 fftools/ffmpeg: Fix integer overflow in duration computation in seek_to_start()
Fixes: signed integer overflow: -9223372036854775808 - 9223372036854775807 cannot be represented in type 'long'
Fixes: Ticket8142

Found-by: Suhwan
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-16 15:13:20 +01:00
Andreas Rheinhardt
c2c65d1d1f fftools/ffprobe: Remove unneeded casts
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-14 16:26:57 +01:00
Andreas Rheinhardt
13dc90396d fftools/ffmpeg: Integrate two checks
For audio packets with dts != AV_NOPTS_VALUEs the dts was converted
twice to the muxer's timebase during streamcopy, once as a normal
packet and once specifically as an audio packet. This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-13 00:40:47 +01:00
Jun Zhao
b99ed6e428 cmdutils: fix crash if no name for "ffmpeg -h protocol"
fix crash when used the command like:
- ffmpeg -h protocol
- ffmpeg -h protocol=

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-30 12:50:22 -03:00
Steven Liu
6087692a60 cmdutils: add show_help_protocol for get protocol options
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-01-30 17:10:21 +08:00
Carl Eugen Hoyos
26c7f91e66 ffmpeg: Do not print "SDP:" on top of sdp files.
Fixes ticket #7068.
2020-01-27 22:45:06 +01:00
Martin Storsjö
2dc2b11fba cmdutils: Fix compilation on cygwin wrt SetDllDirectory and GetModuleHandle
After 06ec9c4746 we check for these
functions in configure (which will succeed in cygwin), but cmdutils.c
only includes windows.h if _WIN32 is defined (which it isn't in cygwin).

Retain the old intent from before 06ec9c4746,
that these functions only would be used when _WIN32 is defined, while
only using them if configure has agreed that they do exist.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-01-08 13:53:31 +02:00
Gyan Doshi
5d82c078ea ffmpeg: don't force source-tracked keyframes for duplicates
Prevents a run of consecutive duplicate frames from all being encoded
as keyframes, when force_key_frames is set to source.
2020-01-05 12:01:46 +05:30
Gyan Doshi
fa3ad7bbc6 ffmpeg: remove premature rescaling of forced_keyframe times
The user-set forced KF times are parsed *after* this deleted
loop and rescaled right after parsing.
2020-01-05 10:55:36 +05:30
Zhao Zhili
609285af51 fftools/ffmpeg_filter: remove sws_param option from buffersrc
The option is deprecated and ignored by buffersrc.
2019-12-31 14:24:34 +01:00
Carl Eugen Hoyos
2e700ec3a7 fftools/ffmpeg_opt: Add a missing closing brackets.
Fixes ticket #8447.
2019-12-28 20:11:01 +01:00
Jun Zhao
c1e215041b fftools/cmdutils: Fix break command dump for -map option
Before this fix, ffmpeg -h full | grep map get the command dump
like:

-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_s  set input stream mapping
                                                               ^
                                                               |
							    truncated
after this fix, we can get full option dump.

Found-by: vacingfang <vacingfang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-12-23 09:46:51 +08:00
Nicolas Gaullier
1fcbaa37e6 fftools/ffmpeg: Reindent after last commit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-21 15:02:06 +01:00
Nicolas Gaullier
f40fb7963e fftools/ffmpeg: Fix forward CPB props in to out
CPB side_data is copied when stream-copying (see init_output_stream_streamcopy()),
but it shall not be copied when the stream is decoded.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-21 14:46:12 +01:00
Martin Storsjö
e10654de2b ffprobe: Fix fate tests for ffprobe in cases where TARGET_PATH differs from the current path
In these cases, we must pass the full path of the file to ffprobe
(as the current working dir on the remote system, e.g. when invoked
with "ssh remote ffprobe ..." isn't the wanted one).

The input filename passed to ffprobe is also included in the output,
which is part of the reference test data. Add a new option to
ffprobe to allow overriding what path is printed, to keep the
original relative path in the tests.

An alternative approach could be an option to allow requesting omitting
the file name from the dumped data, and updating the test references
accordingly.

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-12-18 15:15:12 +02:00
Martin Storsjö
06ec9c4746 configure: Check for the SetDllDirectory and GetModuleHandle functions
These functions aren't available when building for the restricted
UWP/WinRT/WinStore API subsets.

Normally when building in this mode, one is probably only building
the libraries, but being able to build ffmpeg.exe still is useful
(and a ffmpeg.exe targeting these API subsets still can be run
e.g. in wine, for testing).

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-12-13 10:53:05 +02:00
Andreas Rheinhardt
fc7b6d5574 fftools/ffmpeg_opt: Fix mixed declarations and code
Introduced in ed3c317d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-06 20:38:03 +01:00
Andreas Rheinhardt
6f2a3958cf fftools/ffmpeg: Free swresample dictionary during cleanup
Freeing this was forgotten in ad899522.

Fixes #8315 and #8316.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-25 00:22:33 +02:00
Jun Zhao
ed3c317dea fftools/ffmpeg_opt: add error handle if av_asprintf return null
add error handle if av_asprintf return null.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-10-18 09:56:51 +08:00
James Almer
2e4f86e04c ffprobe: fix output of packets_and_frames section in JSON format
The "type" entry was hardcoded with an trailing comma, even if it was
the only entry in the section.

Fixes ticket #8228.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-14 21:06:56 -03:00
Andreas Rheinhardt
223a2c2a60 fftools/ffmpeg: Improve streamcopy
do_streamcopy() has a packet that gets zero-initialized first, then gets
initialized via av_init_packet() after which some of its fields are
oerwritten again with the actually desired values (unless it's EOF): The
side data is copied into the packet with av_copy_packet_side_data() and
if the source packet is refcounted, the packet will get a new reference
to the source packet's data. Furthermore, the flags are copied and the
timestamp related fields are overwritten with new values.

This commit replaces this by using av_packet_ref() to both initialize
the packet as well as populate its fields with the right values (unless
it's EOF again in which case the packet will still be initialized). The
differences to the current approach are as follows:
a) There is no call to a deprecated function (av_copy_packet_side_data())
any more.
b) Several fields that weren't copied before are now copied from the source
packet to the new packet (e.g. pos). Some of them (the timestamp related
fields) may be immediately overwritten again and some don't seem to be
used at all (e.g. pos), but in return using av_packet_ref() allows to forgo
the initializations.
c) There was no check for whether copying side data fails or not. This
has been changed: Now the program is exited in this case.

Using av_packet_ref() does not lead to unnecessary copying of data,
because the source packets are already always refcounted (they originate
from av_read_frame()).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-12 13:39:45 +02:00
Lou Logan
61b7676bd5 cmdutils: trailing options may be ignored
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: mypopy <mypopy@gmail.com>
2019-10-01 10:43:37 -08:00
Lou Logan
04858650b1 ffmpeg_opt: remove errant space
Signed-off-by: Lou Logan <lou@lrcd.com>
2019-09-27 15:17:15 -08:00
Lou Logan
419e5e7942 doc/ffmpeg: -timelimit is in user time
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-27 12:11:39 -08:00
Andreas Rheinhardt
2b1fcba8dd fftools/ffmpeg_opt: Fix signed integer overflow
Fixes ticket #8154.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-17 14:41:07 +02:00
Gyan Doshi
0993327939 cmdutils: promote report level if loglevel is higher 2019-09-13 11:53:54 +05:30
Gyan Doshi
fa697aa92f ffmpeg: switch to avformat_seek_file for stream_loop
Fixes stream_loop with very short files where seeking is generic index
search
2019-09-05 23:23:11 +05:30
Akemi
2a9d461abc avcodec/videotoolbox: add support for full range pixel formats
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-04 10:51:20 -07:00
Andreas Rheinhardt
f2d522f2a8 fftools: Use right function signature and pointers
The option tables of the various fftools (in particular ffprobe) are
arrays of OptionDef; said type contains a union of a pointer to void and
a function pointer of type int (*)(void *, const char *, const char *)
as well as a size_t. Some entries (namely the common entry for writing a
report as well as several more of ffprobe's entries) used the pointer to
void to store a pointer to functions of type int (*)(const char *) or
type int (*)(const char *, const char *); nevertheless, when the functions
are actually called in write_option (in cmdutils.c), it is done via a
pointer of the first type.

There are two things wrong here:
1. Pointer to void can be converted to any pointer to incomplete or
object type and back; but they are nevertheless not completely generic
pointers: There is no provision in the C standard that guarantees their
convertibility with function pointers. C90 lacks a generic function
pointer, C99 made every function pointer a generic function pointer and
still disallows the convertibility with void *.
2. The signature of the called function differs from the signature
of the pointed-to type. This is undefined behaviour in C99 (given that
C90 lacks a way to convert function pointers at all, it doesn't say
anything about such a situation). It only works because none of the
functions this patch is about make any use of their parameters at all.

Therefore this commit changes the type of the relevant functions
to match the type used for the call and uses the union's function
pointer to store it. This is legal even in C90.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-08-15 01:26:21 +02:00
Marton Balint
a1c7014847 ffplay: properly detect all window size changes
SDL_WINDOWEVENT_SIZE_CHANGED should be used instead of SDL_WINDOWEVENT_RESIZED
because SDL_WINDOWEVENT_RESIZED is only emitted if the resize happened due to
an external event.

Fixes ticket #8072.

Additional references:
https://bugzilla.libsdl.org/show_bug.cgi?id=4760
https://wiki.libsdl.org/SDL_WindowEventID

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-14 21:57:46 +02:00
Jun Zhao
11d3b03fcb ffmpeg_opt: Respect default disposition when select audio/video
Respect default disposition when select audio/video

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-07-03 10:33:44 +08:00
Derek Buitenhuis
d5a6b390ce ffprobe: Fix memory leak
This packet was not necessarily unreferenced.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2019-06-21 15:40:58 +01:00
Mark Thompson
a444863738 ffmpeg_hw: Treat empty device string as no device setting
The implementation will use some default in this case.  The empty string
is not a meaningful device for any existing hardware type, and indeed
OpenCL treats it identically to no device already to work around the lack
of this setting on the command line.
2019-06-02 22:58:22 +01:00
Mark Thompson
1f8b36329f ffmpeg_hw: Mark some strings as const 2019-06-02 22:58:22 +01:00
Antonin Gouzer
3da8d04c18 fftools/ffprobe: Add S12M Timecode output as side data (such as SEI TC)
Slightly modified by Marton Balint to produce valid json as well.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-05-27 00:28:34 +02:00
Daniel Kucera
8d9910a23a ffplay: added option always on top for video window
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Daniel Kucera <github@danman.eu>
2019-05-20 17:51:43 -03:00
Andreas Hakon
e750dc9de6 libavformat: improve logs with cur_dts
This patch improves the logs when the message "cur_dts is invalid" appears.
If helps to identify which stream generates the trouble,
and the status of the stream.
A lot of users suffers with the message, and the origin varies.
The improved message can help to discover the cause.

Signed-off-by: Andreas Hakon <andreas.hakon@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-19 17:14:44 +02:00
fumoboy007
036b4b0f85 avcodec/videotoolbox: add support for 10bit pixel format
this patch was originally posted on issue #7704 and was slightly
adjusted to check for the availability of the pixel format.
2019-04-16 03:43:06 +03:00
Thierry Foucu
0ac3befd47 fftools/ffmpeg: Check if we do have also a filter_complex filter.
Right now, the code check for no filter description, but if we use a
filter_complex, the code will use the AVFrame.duration which could be
wrong in case of using fps filter.

How to reproduce the problem:
ffmpeg -f lavfi -i testsrc=duration=1 -vf fps=fps=50 -vsync 1 -f null -
output 50 frames

ffmpeg -f lavfi -i testsrc=duration=1 -filter_complex fps=fps=50 -vsync 1 -f null -
output 51 frames

With this commit, the same command will always output 50 frames.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-28 21:29:20 +01:00
James Almer
06476249cd Merge commit '7e5bde93a1e7641e1622814dafac0be3f413d79b'
* commit '7e5bde93a1e7641e1622814dafac0be3f413d79b':
  build: Rename OBJDIRS variable to OUTDIRS

Merged-by: James Almer <jamrial@gmail.com>
2019-03-10 19:31:13 -03:00
Jan Ekström
8cf757ee8d ffmpeg_filter: initialize sub2video.end_pts together with last_pts
This way re-initializations properly update end_pts, enabling
sub2video_heartbeat to call sub2video_update as expected to re-init
the sub2video AVFrame's contents and to feed a frame into the filter
chain.

This then fixes memory usage ballooning due to framesync waiting
for secondary input in case of no actual subtitle samples being present
for a while in source after a re-init occurs.
2019-02-21 20:13:21 +02:00
Marton Balint
7cab5471b2 ffplay: add support for setting the number of filter threads
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-02-07 23:38:53 +01:00
Marton Balint
fe99a51c40 ffplay: add missing avfilter_graph_alloc result check
Also do not allocate a graph at start, we will reallocate it anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-02-07 23:38:53 +01:00
Marton Balint
28dd73a443 ffplay: use different decoder names for each media type
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-02-07 23:38:53 +01:00
Carl Eugen Hoyos
301cee61fa ffmpeg_opt: Print a warning if more than one -vf/-af option was specified.
Fixes ticket #4184.
2019-01-15 00:27:05 +01:00
Gyan Doshi
3ba5eef2c7 ffmpeg: allow disabling streams by type for inputs
-vn/-an/-sn/-dn now works for input. Streams are still registered in
input_streams but they can't be automatically selected or mapped or
filtered.
2019-01-03 16:13:51 +05:30
Gyan Doshi
54109b1d14 ffmpeg: skip disabled streams
Fully discarded streams can't be selected for output or mapped or filtered.
Previously, a few packets from such streams, probably buffered for
stream probing, would get smuggled into output files.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-02 22:29:11 +01:00
Jan Ekström
3a36b0c4b8 ffmpeg: improve the intra stream discontinuity message
Now it actually tells which stream from which input and of
which type had an absolute DTS discontinuity larger than
dts_delta_threshold.
2018-12-18 21:04:57 +02:00
Marton Balint
418c90faac ffplay: fix -x and -y options when only one of them is used
Previously if only -y was used then nothing happened, if only -x then zero
window height was set which is undefined in SDL and caused a black window.

From now on if only one dimension is set we calculate the other based on
size/aspect of the shown content.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-12-02 00:57:10 +01:00
Marton Balint
9a39c5449f ffplay: convert float math to int math in calculate_display_rect
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-12-02 00:57:09 +01:00
Carl Eugen Hoyos
698574ac5d ffmpeg: Avoid duplicating Closed Captions when increasing frame rate.
Fixes ticket #7506.
2018-11-27 18:38:09 +01:00
Jun Zhao
1ffac23885 fftools/ffmpeg: delete the unused code.
There are come from 2012 ago and have never been used from this
time.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-27 10:45:25 +08:00
Jun Zhao
7608809ae4 fftools/ffprobe: Indent the code.
commit 196765a7cc missed the reindet.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-27 10:45:25 +08:00
Michael Niedermayer
3504004879 fftools/ffmpeg: Repair reinit_filter feature
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-16 10:13:42 +01:00
Jun Zhao
e24a754916 fftools/ffmpeg: Indent the code
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:50 +08:00
Jun Zhao
3eccf5be92 fftools/ffmpeg: Put the variable declaration at uppper for block.
move the variable declaration at start of upper for block and
remove the redundant brace.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:39 +08:00
Jun Zhao
81f2a9f136 fftools/ffmpeg: Remove the micor like "#if 1"
They are come from 2003 and delete them.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:26 +08:00
Marton Balint
f099946faf ffmpeg: log corrupted packets and frames
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-14 23:52:41 +02:00
Marton Balint
6e6ecdf44d ffmpeg: check return value of avcodec_parameters_from_context
Fixes Coverity CID 1427273.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-09 21:46:28 +02:00
Dave Rice
1431ff2d37 ffplay: add options to specify window position
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-07 20:44:22 +02:00
xiaofeng
e78016b04a ffmpeg: break loop when dts_heuristic check done
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-30 22:23:02 +02:00
Gyan Doshi
acc9684dcd ffmpeg: block output == input for files
Fixes #4655
2018-09-17 13:48:28 +05:30
Gyan Doshi
1a4a8df249 ffplay: add option to allow custom seek interval
At present, left and right keys are hardcoded to seek by 10 seconds.
2018-09-05 23:52:56 +05:30
Marton Balint
9fee22dbdd ffplay: do not drain existing filters when seeking
After a seek we drop all frames from the filter anyway. Audio filters already
had a similar approach.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-09-01 21:53:58 +02:00
Gyan Doshi
26dc763245 ffmpeg: add correct field for raw pts in -progress report
PTS is in microseconds, so correct field name is out_time_us.

Old field out_time_ms kept for now - will be removed after a suitable transition
period.

Fixes #7345
2018-08-28 10:11:01 +05:30
James Almer
b955a33314 ffmpeg: simplify refcounting packets for the muxing queue
Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-07 18:42:35 -03:00
Zhong Li
6434b84460 fftools/qsv: add extra_hw_frames support
Currently extra_hw_frames can't be applied to qsv since it
doesn't call function avcodec_get_hw_frames_parameters().

Give an option to fix ticket #7261 though it is not a perfect soultion
(allocate the minimum pool size internally and automatically).

Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-08-07 11:26:40 +08:00
James Almer
d228df6ff3 cmdutils: print a more descriptive error message in show_help_bsf() when no bsf is specified
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-07-28 11:14:45 -03:00
Marton Balint
85bfcc46d1 ffplay: add support for various YUV conversion modes
SDL from version 2.0.8 has support for full range YUV and specifying
BT601/BT709 color space for YUV->RGB conversion.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-13 22:24:33 +02:00
Marton Balint
da36bcbeb7 ffmpeg: fix -stream_loop with multiple inputs
The input thread needs to be properly cleaned up and re-initalized before we
can start reading again in threaded mode. (Threaded input reading is used when
there is mode than one input file).

Fixes ticket #6121 and #7043.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-02 11:58:08 +02:00
Marton Balint
b181cd359b ffmpeg: factorize input thread creation and destruction
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-02 11:58:08 +02:00
Gyan Doshi
07987404a8 ffmpeg: make loglevel verbose for frame duration warning 2018-06-28 14:08:51 +05:30
Gyan Doshi
4ac88ba548 fftools/ffmpeg: check sseof value and clash with ss
Prioritize -ss
2018-06-26 09:47:32 +05:30
Hans Carlson
a790813739 ffmpeg: Treat subtitles like audio and video for non-monotonic dts.
Fixes ticket #4450.
Fixes ticket #6248.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-23 01:06:29 +02:00
Marton Balint
e8050aa791 ffplay: ignore keypress events before a window is created
Current ffplay code assumes that the read thread is in its main loop before any
key events are captured, but apparently on IOS even keypresses without a window
are forwared.

Fixes ticket #7252.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-20 22:26:41 +02:00
Jun Zhao
bd47cca6a7 fftools/cmdutils: Replace the number by macro for bprint init
Replace the number by macro for bprint init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-17 10:00:23 +08:00
Jun Zhao
df9fe79b3c fftools/ffmpeg_filter: Replace the number by macro for bprint init
Replace the number by macro for bprint init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-17 09:59:33 +08:00
Jun Zhao
24be912827 fftools/ffmpeg: Replace the number by macro for bprint init
Replace the number by macro for bprint init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-17 09:59:33 +08:00
Michael Niedermayer
28d33c252e ffmpeg: assert that audio packet duration in process_input_packet() is non negative
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-14 18:55:45 +02:00
Michael Niedermayer
16d8b13b3b fftools/ffmpeg: Fallback to duration if sample rate is unavailable
Regression since: af1761f7
Fixes: Division by 0
Fixes: ffmpeg_crash_1

Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-14 18:55:45 +02:00
Carl Eugen Hoyos
5686c4489a ffmpeg: Fail if the user requested impossible subtitle encoding.
Fixes ticket #7239.
2018-06-09 21:34:27 +02:00
Gyan Doshi
9c12938ec5 ffmpeg: mark sseof as an input-only option 2018-06-09 00:37:03 +05:30
Vishwanath Dixit
146cdf7e4b fftools/ffmpeg: fix for all forced key frames when 'copyts' is enabled
Forced key frames generation functionality was assuming the first PTS
value as zero, but, when 'copyts' is enabled, the first PTS can be any
big number. This was eventually forcing all the frames as key frames.
To resolve this issue, update has been made to use first input pts as
reference pts.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-04 22:26:55 +02:00
Carl Eugen Hoyos
53d6d4f266 ffplay: Print codec_name if decoder for codec_id could not be found.
Reviewed-by: Marton Balint
2018-05-30 01:09:49 +02:00
Jun Zhao
81b77e7bf1 cmdutils: dump supported hardware devices in print_codec()
dump the supported hardware devices for codec when use the command
like ./ffmpeg -h decoder=h264.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-05-28 18:21:48 +08:00
Jun Zhao
90acf168a6 cmdutils: print missing caps in print_codec().
print full caps type in print_codec().

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-05-28 18:21:35 +08:00
Aman Gupta
12ceaf0fba ffprobe: fix SEGV when new streams are added
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-09 12:30:17 -07:00
Tobias Rapp
a150b2e3a0 fftools/ffmpeg: properly initialize output stream field order
Fixes stream field order written by avformat_write_header when "top"
option is specified on the command-line.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-05-02 08:35:08 +02:00
James Almer
e3866ea20d fftools/ffmpeg: fix mixed code and declarations
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-04-30 18:22:51 -03:00
Marton Balint
7033654f7f Use AV_PIX_FMT_FLAG_ALPHA for detecting transparency where nb_components was used
Temporarily keep the old method for ffmpeg_filters.c choose_pix_fmt and
avfiltergraph.c pick_format() until a paletted pixel format without alpha is
introduced.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-04-30 21:51:31 +02:00
André Camargo
1322b00060 fftools/ffmpeg: change fps progress log message to show two decimal digits
Useful when transcoding videos at 29.97 fps because delivers a more accurate result for monitoring.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-28 18:08:52 +02:00
Mark Wachsler
9d75354963 fftools/ffmpeg: Add system time and real time to benchmarking.
The -benchmark and -benchmark_all options now show user, system, and real time,
instead of just user time.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-28 18:08:52 +02:00
Paul B Mahol
0b360cae1c make swresample optional for ffmpeg
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-25 12:38:03 +02:00
Matt Oliver
6be690685a ffplay: Fix realloc_texture when input texture is NULL.
SDL_QueryTexture and SDL_DestroyTexture require that the input texture
pointer be non-null. Debug builds of SDL will correctly check for this
and break program execution. This patch fixes this by checking the
status of the texture pointer.

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2018-04-18 18:57:07 +10:00
Timo Teräs
c663dce031 ffprobe: report unavailable SAR correctly in stream info
av_guess_sample_aspect_ratio() will return undefined or missing
value as {0,1}. This fixes show_stream() to check numerator to
display 'N/A' when appropriate. show_frame() does this already
correctly.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2018-04-17 20:11:31 +01:00
Timo Teräs
94d831f388 ffmpeg: allow setting attached_pic disposition
This is used to signal that image should be stored in metadata
as cover image.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-04 19:09:28 +02:00
wm4
d6fc031caf avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPAL
PSEUDOPAL pixel formats are not paletted, but carried a palette with the
intention of allowing code to treat unpaletted formats as paletted. The
palette simply mapped the byte values to the resulting RGB values,
making it some sort of LUT for RGB conversion.

It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8,
GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap
formats. The last one, GRAY8, is more common, but its treatment is
grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming
from typical Y video planes was not mapped to the correct RGB values.
This cannot be fixed, because AVFrame.color_range can be freely changed
at runtime, and there is nothing to ensure the pseudo palette is
updated.

Also, nothing actually used the PSEUDOPAL palette data, except xwdenc
(trivially changed in the previous commit). All other code had to treat
it as a special case, just to ignore or to propagate palette data.

In conclusion, this was just a very strange old mechnaism that has no
real justification to exist anymore (although it may have been nice and
useful in the past). Now it's an artifact that makes the API harder to
use: API users who allocate their own pixel data have to be aware that
they need to allocate the palette, or FFmpeg will crash on them in
_some_ situations. On top of this, there was no API to allocate the
pseuo palette outside of av_frame_get_buffer().

This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes
the pseudo palette optional. Nothing accesses it anymore, though if it's
set, it's propagated. It's still allocated and initialized for
compatibility with API users that rely on this feature. But new API
users do not need to allocate it. This was an explicit goal of this
patch.

Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I
first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL
macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0.

Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition,
FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation
functions manually changed to not allocating a palette.
2018-04-03 17:53:00 +02:00
Tobias Rapp
4b736bc921 fftools/cmdutils: add support for level flag in loglevel option parser
Allows to manage the AV_LOG_PRINT_LEVEL flag as a prefix to the loglevel
option value, similar to the existing AV_LOG_SKIP_REPEATE flag. Adds
support for setting flags relative to the existing value by using a +/-
prefix.

Previous version reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-04-03 10:17:38 +02:00
Josh de Kock
89029bd2c7 lav*,tests: remove several register_all calls
avdevice_register_all() is still required to register devices into
lavf (this is required due to lavd being somewhat of a hack).

Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-04-02 03:26:22 +01:00
Jun Zhao
9b125826ed cmdutils: fix new API break the "ffmpeg -muxers/demuxers"
fix commit 2238190 break the "ffmpeg -muxers/demuxers".

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-04-02 02:19:26 +01:00
Jan Ekström
e760c12aee ffmpeg: prevent premature EOF in sub2video with nullptr AVSubtitles
With certain types of input and the filter chain getting re-initialized
or re-configured, multiple nullptr AVSubtitles can get pushed into
sub2video_update() in a row from sub2video_heartbeat.

This causes end_pts, and on the next round pts, to become INT64_MAX,
latter of which signals EOF in framesync, leading to complete loss of
subtitles from that point on.

Thus, check that the sub2video.end_pts is smaller than INT64_MAX
in a similar fashion to sub2video_flush before sending out the
nullptr AVSubtitle. This keeps premature EOFs from happening in
framesync and the subtitle overlay is kept past the filter chain
re-initializations/configurations.
2018-04-01 13:56:31 +03:00
Josh de Kock
22381906f3 cmdutils: use new APIs
Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-03-31 23:26:31 +01:00
Carl Eugen Hoyos
11f8f9547d fftools/ffmpeg: Remove an unused variable.
Fixes a warning:
fftools/ffmpeg.c:2201:22: warning: unused variable 'fg'
2018-03-30 12:01:58 +02:00
Marton Balint
0031eab61c ffmpeg: do not finish output streams manually on eof even if no input is provided
The generic code should be able to finish the streams just fine initializing
and flushing the filters and codecs properly.

Fixes the following command:

ffmpeg -f lavfi -i "testsrc=d=0.1[out0];aevalsrc=0:d=0[out1]" -af apad -shortest -f framecrc -

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-29 00:07:39 +02:00
Marton Balint
60c9a25530 ffmpeg: fallback to codecpar parameters on input filter eof
Fixes ticket #6854 and the following simpler case:

ffmpeg -f lavfi -i testsrc=d=1 -f lavfi -i testsrc=d=0 -filter_complex overlay -f null none

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-29 00:07:39 +02:00
James Almer
231a73308f ffmpeg: pass reference counted packet on codec copy when possible
Should prevent unnecessary copy of data in cases where new references
to the packet are created within the muxer or a bitstream filter.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-23 22:05:25 -03:00
James Almer
f5ceb15bb6 ffmpeg: remove dead call to av_parser_change()
It's been a noop for years, and it's been argued that in-band headers
should not be forcedly removed without the user's explicit request.

Also, as the FIXME line stated, this is a job for a bitstream filter
like extract_extradata, remove_extradata, dump_extradata, and
filter_units.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-23 22:03:22 -03:00
James Almer
ead257db56 cmdutils: print supported codecs in show_help_bsf()
Tested-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-22 00:15:05 -03:00
Gyan Doshi
8ad83044b4 ffmpeg.c - drain all decoded frames during stream_loop flush
When a decoded stream is being looped, after each post-EOF rewind,
decoders are flushed in seek_to_start(). This only drains 1 frame, and
thus the output has a few frames missing at the tail of each iteration
except the last.

With this patch, process_input is looped till process_input_packet
reaches EOF.

Fixes #7081

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-03-20 22:59:40 +01:00
James Almer
055f60e874 cmdutils: remove a superfluous line break
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-17 12:12:37 -03:00
Jun Zhao
a675eed175 ffmpeg: support dump bit stream filter options.
Support dump bit stream filter option in ffmpeg -h full and
ffmpeg -h bsf=FooBar.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-03-16 02:09:59 +01:00
Marton Balint
68f5384804 ffprobe: fix infinite loop in subtitle decoding
Fixes a regression since 2a88ebd096 which caused
an infinite loop in the subtitle decoding.

Fixes ticket #6796.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-12 21:11:06 +01:00
Tobias Rapp
69995a94d8 fftools/ffmpeg: update print_report to use AVBPrint API
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-03-05 09:24:55 +01:00
Tobias Rapp
a194e9c415 fftools/ffmpeg: fix progress log message in case pts is not available
Also fixes sign prefix for progress report.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-03-05 09:24:40 +01:00
Tobias Rapp
fa0c9d69d3 fftools/ffmpeg: replace call to av_strerror with av_err2str
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-02-27 08:34:35 +01:00
Tomas Härdin
5caae27979 Don't complain about codec2's 700 bit/s modes in ffmpeg.c 2018-02-24 17:06:31 +01:00