summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAge
* 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>
* fftools/ffmpeg: add new abort_on flag which aborts if there is a stream ↵Marton Balint2020-05-26
| | | | | | which received no packets Signed-off-by: Marton Balint <cus@passwd.hu>
* Stop hardcoding align=32 in av_frame_get_buffer() calls.Anton Khirnov2020-05-22
| | | | Use 0, which selects the alignment automatically.
* fftools/ffmpeg: use local variable with same contents directlyLimin Wang2020-05-06
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* fftools/ffmpeg: use a bsf list instead of individual bsfsMarton Balint2020-05-02
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* ffmpeg: Remove the hw_device_ctx globalMark Thompson2020-04-26
| | | | | The ad-hoc libmfx setup code is the only place its still used, so move it into that file.
* ffmpeg: Use hardware config metadata with encodersMark Thompson2020-04-26
| | | | | | | 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.
* ffmpeg: Do not clip timestamps at LONG_MAX.Carl Eugen Hoyos2020-04-15
| | | | Fixes ticket #8612.
* fftools/ffmpeg: also flush encoders which have a variable frame sizeMarton Balint2020-04-13
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* fftools/ffmpeg: Disable copy_ts on timestamp wraparoundMichael Niedermayer2020-04-04
| | | | | | | | This allows handling more than 26.5h of mpeg* input Fixes: Ticket 7876 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* ffmpeg: Print an error instead of a debug message on exit.Carl Eugen Hoyos2020-03-31
| | | | Reported-by: Forum user NewPlaza
* ffmpeg: explicitly handle sub2video subpicture initializationJan Ekström2020-03-16
| | | | | | | | 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.
* fftools/ffmpeg: Fix integer overflow in duration computation in seek_to_start()Michael Niedermayer2020-02-16
| | | | | | | | | 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>
* fftools/ffmpeg: Integrate two checksAndreas Rheinhardt2020-02-13
| | | | | | | | | 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>
* ffmpeg: Do not print "SDP:" on top of sdp files.Carl Eugen Hoyos2020-01-27
| | | | Fixes ticket #7068.
* ffmpeg: don't force source-tracked keyframes for duplicatesGyan Doshi2020-01-05
| | | | | Prevents a run of consecutive duplicate frames from all being encoded as keyframes, when force_key_frames is set to source.
* ffmpeg: remove premature rescaling of forced_keyframe timesGyan Doshi2020-01-05
| | | | | The user-set forced KF times are parsed *after* this deleted loop and rescaled right after parsing.
* fftools/ffmpeg: Reindent after last commitNicolas Gaullier2019-12-21
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools/ffmpeg: Fix forward CPB props in to outNicolas Gaullier2019-12-21
| | | | | | | 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>
* fftools/ffmpeg: Free swresample dictionary during cleanupAndreas Rheinhardt2019-10-25
| | | | | | | | | | 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>
* fftools/ffmpeg: Improve streamcopyAndreas Rheinhardt2019-10-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ffmpeg: switch to avformat_seek_file for stream_loopGyan Doshi2019-09-05
| | | | | Fixes stream_loop with very short files where seeking is generic index search
* libavformat: improve logs with cur_dtsAndreas Hakon2019-04-19
| | | | | | | | | | | 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>
* fftools/ffmpeg: Check if we do have also a filter_complex filter.Thierry Foucu2019-03-28
| | | | | | | | | | | | | | | | | 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>
* ffmpeg: improve the intra stream discontinuity messageJan Ekström2018-12-18
| | | | | | Now it actually tells which stream from which input and of which type had an absolute DTS discontinuity larger than dts_delta_threshold.
* ffmpeg: Avoid duplicating Closed Captions when increasing frame rate.Carl Eugen Hoyos2018-11-27
| | | | Fixes ticket #7506.
* fftools/ffmpeg: delete the unused code.Jun Zhao2018-11-27
| | | | | | | There are come from 2012 ago and have never been used from this time. Signed-off-by: Jun Zhao <mypopydev@gmail.com>
* fftools/ffmpeg: Repair reinit_filter featureMichael Niedermayer2018-11-16
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools/ffmpeg: Indent the codeJun Zhao2018-11-11
| | | | Signed-off-by: Jun Zhao <mypopydev@gmail.com>
* fftools/ffmpeg: Put the variable declaration at uppper for block.Jun Zhao2018-11-11
| | | | | | | move the variable declaration at start of upper for block and remove the redundant brace. Signed-off-by: Jun Zhao <mypopydev@gmail.com>