summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAge
* fftools/ffmpeg: Restore DTS correction for VP9 copiesDanny Wu2022-02-13
| | | | | | | | | | | | | | | | | | Fixes ticket 9086. Since early 2021, some of YouTube's VP9 encodes have non-monotonous DTS. This makes ffmpeg fatally fail when trying to copy or encode the V9 video. ffmpeg already includes functionality to correct this, however it was disabled without explanation for VP9 stream copies in 2e6636aa87303d37b112e79f093ca39500f92364 This patch restores the DTS correction logic, and allows ffmpeg to correctly encode (invalid) videos produced by youtube.com. I have verified that frames are NOT being cut (so it does not re-introduce 4313). Reviwed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: switch to new FIFO APIAnton Khirnov2022-02-07
|
* ffmpeg: remove a redundant assignment of interrupt_callbackAnton Khirnov2022-01-10
| | | | It is already set in open_output_file().
* fftools/ffmpeg: close output files before cleanupMarton Balint2021-12-12
| | | | | | This allows us to check the return value of avio_closep(). Signed-off-by: Marton Balint <cus@passwd.hu>
* ffmpeg: handle errors in print_sdp()Anton Khirnov2021-12-07
| | | | Do not continue as if nothing happened.
* ffmpeg: move setting video sync method to new_video_stream()Anton Khirnov2021-12-07
| | | | | | do_video_out() is the wrong place for it, since the necessary information is already known when creating the stream and its value should never change.
* ffmpeg: change vsync value to an enumAnton Khirnov2021-12-07
| | | | | Stop explicitly defining VSCFR and DROP values, which were never documented.
* ffmpeg: drop useless framerate assignmentsAnton Khirnov2021-12-07
| | | | | | If the input stream framerate is known, it will be configured on the relevant filtergraph input and get propagated to the output stream in the above line. That makes these assignments redundant.
* fftools/ffmpeg: Avoid creating unnecessary referenceAndreas Rheinhardt2021-12-05
| | | | | | | The only caller of do_video_out() doesn't need the frame afterwards, ergo one can replace an av_frame_ref() by av_frame_move_ref(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg: Avoid allocating+freeing frame, check allocationsAndreas Rheinhardt2021-12-05
| | | | | | Fixes a potential crash upon av_frame_alloc() failure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ffmpeg: only copy bits_per_sample from decoder when it remains validAnton Khirnov2021-12-04
| | | | | I.e. when the only filters that are applied do not modify the frame data.
* ffmpeg: make -bits_per_raw_sample a per-output-stream optionAnton Khirnov2021-12-04
| | | | Also, document it and make it apply to audio in addition to video.
* ffmpeg: fix usage of -shortest in codec copy scenariosJames Almer2021-12-01
| | | | | | | | | Don't mark all streams as finished, instead make sync_opts keep track of the stream's duration, and set recording_time to it, same as in transcoding paths. Fixes tickets #9512 and #9513. Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg_opt: Don't duplicate array unnecessarilyAndreas Rheinhardt2021-11-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ffmpeg: remove ffmpeg_videotoolboxrcombs2021-11-28
| | | | | | This was almost completely redundant. The only functionality that's no longer available after this removal is the videotoolbox_pixfmt arg, which has been obsolete for several years.
* fftools/ffmpeg: Take type limitations of AVFifo API into accountAndreas Rheinhardt2021-11-26
| | | | | | | | | | | | The types used by the AVFifo API are inconsistent: av_fifo_(space|size)() returns an int; av_fifo_alloc() takes an unsigned, other parts use size_t. This commit therefore ensures that the size of the muxing_queue FIFO never exceeds INT_MAX. While just at it, also make sure not to call av_fifo_size() unnecessarily often. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ffmpeg: drop obsolete rotation API remnantsAnton Khirnov2021-11-23
| | | | No demuxers export the "rotate" metadata tag anymore.
* ffmpeg: do not copy chroma_sample_location from the input streamAnton Khirnov2021-11-23
| | | | It will be set from the supplied AVFrame later on.
* fftools/ffmpeg: Avoid temporary frameAndreas Rheinhardt2021-11-20
| | | | | | | | | | | | | | | send_frame_to_filters() sends a frame to all the filters that need said frame; for every filter except the last one this involves creating a reference to the frame, because av_buffersrc_add_frame_flags() by default takes ownership of the supplied references. Yet said function has a flag which changes its behaviour to create a reference itself. This commit uses this flag and stops creating the references itself; this allows to remove the spare AVFrame holding the temporary references; it also avoids unreferencing said frame. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ffmpeg: remove unused hw_frames_ctx AVBufferRef from InputStreamJames Almer2021-11-19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: remove unused hwaccel_get_buffer function pointerJames Almer2021-11-19
| | | | | | | As well as the custom get_buffer2() implementation which would become a redundant wrapper for avcodec_default_get_buffer2() after this Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: Allocate InputStream.decoded_frame earlyJames Almer2021-11-19
| | | | | | Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: Allocate (In|Out)putStream.filter_frame earlyJames Almer2021-11-19
| | | | | | Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <jamrial@gmail.com>
* fftools: Constify values from av_dict_get()Chad Fraleigh2021-11-18
| | | | | | | | 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>
* ffmpeg: fix loosing gaps between audio frame timestamps when filteringPaul B Mahol2021-11-18
|
* ffmpeg: rewrite setting the stream dispositionAnton Khirnov2021-11-16
| | | | | | | | | | | | | | | | | | | | | 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.
* lavf: add "disposition" AVOption to AVStream AVClassAnton Khirnov2021-11-16
| | | | Use it to remove custom disposition parsing code from ffmpeg.c
* fftools/ffmpeg: Output log message when interactive q command is receivedSoft Works2021-11-13
| | | | | | | | 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>
* fftools/ffmpeg: Fix indentation after changeSoft Works2021-11-13
| | | | | Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* fftools/ffmpeg: Remove redundant loopSoft Works2021-11-13
| | | | | Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* fftools/ffmpeg, ffmpeg_opt: Allocate (In|Out)putStream.pkt earlyAndreas Rheinhardt2021-10-08
| | | | | | | Avoids checks lateron in the hot path. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg: Remove unnecessary av_packet_unref()Andreas Rheinhardt2021-10-08
| | | | | | | 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>
* fftools/ffmpeg: Fix crash when flushing non-fully setup output streamAndreas Rheinhardt2021-10-08
| | | | | | | | | 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>
* fftools/ffmpeg, doc/examples: Remove redundant av_packet_unrefAndreas Rheinhardt2021-10-03
| | | | | | av_interleaved_write_frame() already returns blank packets. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/vf_subtitles, fftools/ffmpeg: Don't set sub_text_formatAndreas Rheinhardt2021-09-20
| | | | | | | | | Unnecessary since 1f63665ca567fbc49fa80166d468a822c2999efa, 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>
* ffmpeg: use display matrix frame side data for autorotationJames Almer2021-09-16
| | | | | | | And give it priority over stream side data when present. Fixes part of ticket #6945. Signed-off-by: James Almer <jamrial@gmail.com>
* Revert "ffmpeg: force 128k default audio bitrate if nothing is specified and ↵Andreas Rheinhardt2021-09-05
| | | | | | | | | | | | | | | | | | | | | | | | there is no specific default" This reverts commit 628a73f8f3768513fa6152c98d54842cf2ae1aad. 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 041cd5a0c55e02dd3b9a2419644b03103819c3d3. 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>
* ffmpeg: let AVFilterGraph parse the filter_threads optionJames Almer2021-09-04
| | | | | | | | | 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>
* fftools: Remove remnants of resample_optsAndreas Rheinhardt2021-09-03
| | | | | | | | | | | | | | 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 420cedd49745b284c35d97b936b71ff79b43bdf7 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>
* ffmpeg: fix order between field order autodetection and overrideJan Ekström2021-07-25
| | | | | | | | | | | | | | | | 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 fbb44bc51a647862eb05ae3f9d7d49a0be9bed57 , 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
* fftools/ffmpeg: Fix runlength for strncmp()Thilo Borgmann2021-07-19
|
* ffmpeg: delay readrate enforcement for decoded streamsGyan Doshi2021-07-19
| | | | | | | 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.
* fftools/ffmpeg: Fix declaration-after-statement warningAndreas Rheinhardt2021-07-18
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg: fix -t inaccurate recording timeShiwang.Xie2021-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ffmpeg: add option readrateGyan Doshi2021-07-17
| | | | | | | Allows to read inputs at arbitrary rates. -re is equivalent to -readrate 1 Tested with -copyts {+ start_at_zero}, -ss, streamcopied & decoded streams.
* fftools/ffmpeg: Add new variant source_no_drop to the force_key_frames optionKeyun Tong2021-07-16
| | | | Suggested-By: ffmpeg@fb.com
* ffmpeg: silence a thread_safe_callbacks deprecation warningJames Almer2021-06-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg: remove usage of internal timestamp AVStream fieldsJames Almer2021-06-04
| | | | | | They should not be accessed outside of libavformat. Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: return no chosen output if an uninitialized stream is unavailableJan Ekström2021-05-13
| | | | | | | | | | | | | | | 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 67be1ce0c6de330b1c10d1d121819d8a74a7b1f5 . 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
* fftools/ffmpeg: copy average framerate for streamcopy, when knownAnton Khirnov2021-04-08
|