Commit Graph

285 Commits

Author SHA1 Message Date
Jan Ekström 9a820ec8b1 ffmpeg: add video heartbeat capability to fix_sub_duration
Splits the currently handled subtitle at random access point
packets that can be configured to follow a specific output stream.
Currently only subtitle streams which are directly mapped into the
same output in which the heartbeat stream resides are affected.

This way the subtitle - which is known to be shown at this time
can be split and passed to muxer before its full duration is
yet known. This is also a drawback, as this essentially outputs
multiple subtitles from a single input subtitle that continues
over multiple random access points. Thus this feature should not
be utilized in cases where subtitle output latency does not matter.

Co-authored-by: Andrzej Nadachowski <andrzej.nadachowski@24i.com>
Co-authored-by: Bernard Boulay <bernard.boulay@24i.com>

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2023-02-03 16:17:29 +02:00
Anton Khirnov 806ecace91 fftools/ffmpeg: support input frame params in encoding stats 2023-01-31 09:09:23 +01:00
Anton Khirnov 935964bd41 doc/ffmpeg: drop non-existent -dc option 2023-01-29 09:12:40 +01:00
Anton Khirnov 425b2c4a56 fftools/ffmpeg: add options for writing encoding stats
Similar to -vstats, but more flexible:
- works for audio as well as video
- frame and/or packet information
- user-specifiable format
2023-01-29 09:09:59 +01:00
Anton Khirnov e884360e91 doc/ffmpeg: improve -r documentation
Explain different behavior for encoding and streamcopy.
2023-01-10 11:49:28 +01:00
Anton Khirnov 1a6ba73ff7 doc/ffmpeg.texi: drop a non-existent option
-ilme has not existed for 17 years, since
637b5326f3
2023-01-10 11:49:28 +01:00
Jan Ekström c889248647 ffmpeg: Add display_{rotation, hflip, vflip} options
This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on the input side.

Additionally, switch the singular test that was utilizing the rotation
metadata to instead override the input display rotation, thus leading
to the same result.
2022-10-19 11:53:52 +02:00
Anton Khirnov 3d86a13b47 fftools/ffmpeg: drop the -async option
It has been deprecated in favor of the aresample filter for almost 10
years.

Another thing this option can do is drop audio timestamps and have them
generated by the encoding code or the muxer, but
- for encoding, this can already be done with the setpts filter
- for muxing this should almost never be done as timestamp generation by
  the muxer is deprecated, but people who really want to do this can use
  the setts bitstream filter
2022-10-04 11:55:03 +02:00
Anton Khirnov 889b4b2f60 doc/ffmpeg: update -map documentation
Make it match reality (current text was not updated for stream
specifiers), extend and clarify the text.
2022-08-08 16:20:58 +02:00
Anton Khirnov fee249b30a fftools/ffmpeg: deprecate specifying a sync stream with -map
It has not had any effect whatsoever for over 10 years.
2022-08-08 16:20:58 +02:00
Anton Khirnov 98ece428e3 fftools/ffmpeg: deprecate the -map_channel option
It is now entirely redundant with audio filters, and is in fact
implemented by setting up a 'pan' filter instance.
2022-07-28 16:37:16 +02:00
Anton Khirnov 1a378b8274 fftools/ffmpeg: deprecate -psnr
It is entirely redundant with -flags +psnr.
2022-07-28 16:37:16 +02:00
Anton Khirnov 2d924b3a63 fftools/ffmpeg: move each muxer to a separate thread 2022-07-23 11:53:19 +02:00
Anton Khirnov 4740fea7dd fftools/ffmpeg: rework -shortest implementation
The -shortest option (which finishes the output file at the time the
shortest stream ends) is currently implemented by faking the -t option
when an output stream ends. This approach is fragile, since it depends
on the frames/packets being processed in a specific order. E.g. there
are currently some situations in which the output file length will
depend unpredictably on unrelated factors like encoder delay. More
importantly, the present work aiming at splitting various ffmpeg
components into different threads will make this approach completely
unworkable, since the frames/packets will arrive in effectively random
order.

This commit introduces a "sync queue", which is essentially a collection
of FIFOs, one per stream. Frames/packets are submitted to these FIFOs
and are then released for further processing (encoding or muxing) when
it is ensured that the frame in question will not cause its stream to
get ahead of the other streams (the logic is similar to libavformat's
interleaving queue).

These sync queues are then used for encoding and/or muxing when the
-shortest option is specified.

A new option – -shortest_buf_duration – controls the maximum number of
queued packets, to avoid runaway memory usage.

This commit changes the results of the following tests:
- copy-shortest[12]: the last audio frame is now gone. This is
  correct, since it actually outlasts the last video frame.
- shortest-sub: the video packets following the last subtitle packet are
  now gone. This is also correct.
2022-07-23 11:53:19 +02:00
Gyan Doshi 882aac99d2 ffmpeg: add option -isync
This is a per-file input option that adjusts an input's timestamps
with reference to another input, so that emitted packet timestamps
account for the difference between the start times of the two inputs.

Typical use case is to sync two or more live inputs such as from capture
devices. Both the target and reference input source timestamps should be
based on the same clock source.

If either input lacks starting timestamps, then no sync adjustment is made.
2022-07-14 15:48:24 +05:30
Gyan Doshi dba7376d59 doc/ffmpeg: correct description of -shortest
-shortest stops 'recording' when the shortest output stream ends. The
native or even seek-adjusted duration of the source input stream isn't
considered.
2022-07-04 14:43:48 +05:30
Marton Balint 843c4346b1 doc/ffmpeg: fix typo in VCD creation example
Fixes ticket #9753.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-12 09:35:50 +05:30
Gyan Doshi 09c53a04c5 ffmpeg: add option fps_mode
fps_mode sets video sync per output stream. Overrides vsync for matching
streams.

vsync is deprecated.
2022-06-11 09:47:27 +05:30
NetSysFire cd78d5bba9 doc/ffmpeg: fix typo in ffmpeg.texi 2022-05-10 22:02:58 +02:00
Anton Khirnov 6ce9546428 ffmpeg: deprecate passing numbers to -vsync
There is never a reason to do this, using symbolic names is always
preferred.
2021-12-07 11:23:45 +01:00
Anton Khirnov 4258893961 ffmpeg: make -bits_per_raw_sample a per-output-stream option
Also, document it and make it apply to audio in addition to video.
2021-12-04 14:07:36 +01:00
Timo Rothenpieler b1f1de0844 avutil/hwcontext_cuda: add option to use primary device context 2021-11-22 23:03:21 +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
Artem Galin f1cd1dc6ce libavutil/hwcontext_qsv: add usage child_device_type argument to explicitly select d3d11va/DX11 device type
UPD: Rebase of last patch set over current master and use DX9 as default device type.

Makes selection of dxva2/DX9 device type by default as before with explicit d3d11va/DX11 usage to cover more HW configurations.
Added warning message to expect changing default device type in the future.

Fixes TGL / AV1 decode as requires DX11 with explicit DX11 type
selection.

Add headless/multi adapter support and fixes:
    https://trac.ffmpeg.org/ticket/7511
    https://trac.ffmpeg.org/ticket/6827
    http://ffmpeg.org/pipermail/ffmpeg-trac/2017-November/041901.html
    https://trac.ffmpeg.org/ticket/7933
    338fbcd5bb
    https://github.com/jellyfin/jellyfin/issues/2626#issuecomment-602153952

Any other fixes are welcome including OpenCL interop patch since I don't have proper setup to validate this use case

Decoding, encoding, transcoding have been validated.

child_device_type option is responsible for d3d11va/dxva2 device selection

Usage examples:

DirectX 11:
    -init_hw_device qsv:hw,child_device_type=d3d11va
    -init_hw_device qsv:hw,child_device_type=d3d11va,child_device=0
OR
    -init_hw_device d3d11va=dx -init_hw_device qsv@dx

DirectX 9 is still supported but requires explicit selection:
    -init_hw_device qsv:hw,child_device_type=dxva2
OR
    -init_hw_device dxva2=dx -init_hw_device qsv@dx

Signed-off-by: Artem Galin <artem.galin@intel.com>
2021-09-08 17:42:53 -03:00
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
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
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
Gyan Doshi 99bbf4a5be doc/ffmpeg: document reinit_filter 2021-06-10 09:57:18 +05:30
Gyan Doshi 090dc381a1 doc/ffmpeg: clarify what -hwaccels list indicates
Fixes #8204
2021-04-03 10:58:07 +05:30
Gyan Doshi 3a79ab8317 doc/ffmpeg: document parameters set by -target 2021-03-19 17:00:17 +05:30
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
Gyan Doshi 6c92557756 doc/ffmpeg: document apad option 2021-01-31 10:02:18 +05:30
Gyan Doshi d8a585d4d5 doc/ffmpeg: document adrift_threshold 2021-01-23 16:43:51 +05:30
Gyan Doshi e8b46b2c73 doc/ffmpeg: restore location of stray passage
Added in 88fc1438c6, this passage was separated from its original
context over the years with unrelated entries sandwiched in between.
2021-01-23 15:41:52 +05:30
Gyan Doshi 0fff6c039c doc/ffmpeg: document max_error_rate 2021-01-10 19:14:37 +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
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
Nicolas George e6d625d008 doc: include general in *-all pages. 2020-09-08 14:29:19 +02:00
Nicolas George 697fb09e3d ffmpeg: add auto_conversion_filters option. 2020-09-08 14:16: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
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
Moritz Barsnick aab0885c19 doc/ffmpeg: remove reference to deprecated option
The "-deinterlace" was deprecated since d7edd35, over eight years
ago.

Refer to deinterlacing filters instead.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
2020-06-09 17:53:41 +05:30
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
Lynne 3c5e5a5095
hwcontext_vulkan: let users enable device and instance extensions using options
Also documents all options supported by the hwdevice.
This lets users enable all extensions they need without writing their own
instance initialization code.
2020-05-10 23:20:47 +01:00
Mark Thompson 48b102c5a6 doc/ffmpeg: Document device selection for Vulkan 2020-02-09 20:36:45 +00:00
Gyan Doshi fa677750de doc/ffmpeg: document value source for -force_key_frames
Also clarify behaviour in case of specified timestamps
2020-01-05 10:53:46 +05:30
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
Jun Zhao e317c255f6 doc/ffmpeg: Document dts_error_threshold option
Document dts_error_threshold option.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-08-08 18:00:37 +08:00
Aman Gupta 9e40c97a84 doc/ffmpeg: muxdelay and muxpreload are output options
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-03-20 14:54:13 -07:00
Gyan Doshi 41ef6dd67d doc/ffmpeg: remove entry for -loop_output
Option doesn't exist .. hasn't for a few years now.
2019-03-20 02:17:19 +05:30