summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAge
* 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>
* 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>