Commit Graph

394 Commits

Author SHA1 Message Date
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