summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAge
* 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
|
* fftools/ffmpeg: when framerate is set, prefer its inverse as output timebaseAnton Khirnov2021-04-08
| | | | | Codec timebase is not well-defined for streamcopy, so it should only be used as the last resort.
* fftools/ffmpeg: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools: Switch to const AVCodec * where possibleAndreas Rheinhardt2021-03-02
| | | | | | | | | | | 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>
* fftools/ffmpeg, ffplay: Don't set refcounted_framesAndreas Rheinhardt2021-02-28
| | | | | | | 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>
* ffmpeg: add -fpsmax to clamp output framerateGyan Doshi2021-02-05
| | | | Useful when encoding in batch or with aberrant inputs.
* avcodec: remove long dead debug_mv codeJames Almer2021-01-25
| | | | | | FF_API_DEBUG_MV has been zero since ffmpeg 4.0 Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: use sigaction() instead of signal() on linuxAndriy Gelman2021-01-16
| | | | | | | | 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>
* ffmpeg: delay first statsGyan Doshi2020-12-24
| | | | | | Wait for all output files to be initialized before printing first stats. Avoids breaking output file dump report.
* ffmpeg: don't delay printing initial statsGyan Doshi2020-12-23
| | | | | | | 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.
* ffmpeg: add option stats_periodGyan Doshi2020-12-23
| | | | | | | | | 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.
* ffmpeg: stop accessing deprecated stream-embedded codec contextAnton Khirnov2020-12-10
|
* avcodec: deprecate thread_safe_callbacksAnton Khirnov2020-11-27
| | | | | | | | | 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.
* fftools/ffmpeg: fix the wrong bitrate and speed statsLimin Wang2020-10-31
| | | | | | | | | | | | | | | | 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>
* ffmpeg: move field order decision making to encoder initializationJan Ekström2020-10-29
| | | | | | | | | | | 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.
* ffmpeg: pass decoded or filtered AVFrame to output stream initializationJan Ekström2020-10-29
| | | | | | | | | | 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".
* ffmpeg: move A/V non-streamcopy initialization to a later pointJan Ekström2020-10-29
| | | | | | | | | | | | | | | | - 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.
* ffmpeg: move AVFrame time base adjustment into a functionJan Ekström2020-10-29
| | | | This will have to be called later for video down the line.
* ffmpeg: add a data size threshold for muxing queue sizeJan Ekström2020-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* ffmpeg: deduplicate init_output_stream usage logicJan Ekström2020-10-17
| | | | | Adds a wrapper function, which handles any errors depending on how fatal a failure would be.
* fftools/ffmpeg: Fix leak of AVFilterInOut in case of errorAndreas Rheinhardt2020-08-23
| | | | | | | | | | | | 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>
* fftools/ffmpeg: make specifying thread_queue_size turn on threaded inputMarton Balint2020-07-29
| | | | | | | | 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>
* fftools/ffmpeg: update text requesting samplesAndriy Gelman2020-06-01
| | | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Reviewed-by: Marton Balint <cus@passwd.hu>