Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to allow drawtext frame_num/n var to start at a number other than 0 #18

Merged
merged 0 commits into from
Jun 12, 2013

Conversation

mjmvisser
Copy link
Contributor

In reference to https://ffmpeg.org/trac/ffmpeg/ticket/1949

The suggested workaround to use expr\\\:n+1 doesn't solve the problem, as the frame number is drawn as a double (1.000000000) instead of as an integer.

I followed the example set by the image2 format and added a start_number parameter. For example, the following draws the frame number at the bottom right, starting at 30:

-vf drawtext="fontsize=15:fontfile=/path/to/font.ttf:text=%{n}:start_number=30:fontsize=25:fontcolor='white':x=w-text_w-line_h:\y=h-text_h-line_h"

@ubitux
Copy link
Contributor

ubitux commented May 21, 2013

Note that you can do something like:

ffplay -f lavfi color=black -vf "drawtext=text='%{e\:n+123}':fontcolor=white"

May I ask what is the purpose behind such feature? Is it just to solve the problem of n starting at 0 or 1?

Edit1:
Oh mmh, I should have read your initial post, my bad.

But another note; now that the counter is stored in a common place (link->frame_count), I wonder if we couldn't have a more global starting number instead. That would make more sense when using for instance in combination with showinfo filter (which prints the n), or actually any kind of filters where the counter is used (anything with timeline for instance, or various expressions).

Edit2:
To be more specific, maybe have a look to filters_common_options in avfilter.c, and try to add it here. Unfortunately, if you do that, it will be limited to each filter scope. Maybe we need some global libavfilter options, so when a -start_n is specified by a tool, it is populated everywhere. Such thing should be discussed on ffmpeg-devel mailing list or IRC.

I know I'm being pedantic for such a trivial feature, but I believe it can be done way better and have a few benefits in the long term. Adding such option like this now will mean a depreciation burden next time it's implemented generically.

@mjmvisser
Copy link
Contributor Author

Good idea (filters_common_options), I hadn't realized n was used outside of the drawtext filter. I'll update this patch when I have a chance and post a link to it on the mailing list.

cheers,
-Mark

@mjmvisser
Copy link
Contributor Author

Do to some n00bness on my part, this pull request was empty. I've resubmitted it here: #24

TimothyGu pushed a commit that referenced this pull request Dec 9, 2021
…ion parameter

If memory allocation fails, ERROR(ENOMEM) '-12' will be returned.
When resample() is done first, the negative size param would cause buffer-overflow and SEGV in swri_rematrix().
When swri_rematrix() is run first, resample() would not cause an error but Err num as a wrong parameter passing.
Err num should be returned immediately. And remove an unneeded term from an assert.

coredump info:
    #0 0x499517 in posix_memalign (/home/r1/ffmpeg/ffmpeg_4.4.1+0x499517)
    #1 0x6c1f0b4 in av_malloc /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:86:9
    #2 0x6c208fe in av_mallocz /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:239:17
    #3 0x6c207ad in av_mallocz_array /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:195:12
    #4 0x654b2e5 in swri_realloc_audio /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:418:14
    #5 0x654f9a1 in swr_convert_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:601:17
    #6 0x654d2c0 in swr_convert /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:766:19
    #7 0x186cf56 in flush_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:251:13
    #8 0x186a454 in request_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:288:20
    #9 0x787d9c in ff_request_frame_to_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:459:15
    #10 0x7877f1 in forward_status_change /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1257:19
    #11 0x77ed7e in ff_filter_activate_default /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1288:20
    #12 0x77e4e1 in ff_filter_activate /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1441:11
    #13 0x793b3f in ff_filter_graph_run_once /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1403:12
    #14 0x7a7bee in get_frame_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:131:19
    #15 0x7a7287 in av_buffersink_get_frame_flags /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:142:12
    #16 0x792888 in avfilter_graph_request_oldest /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1356:17
    #17 0x5d07df in transcode_from_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4639:11
    #18 0x59e557 in transcode_step /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4729:20
    #19 0x593970 in transcode /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4805:15
    #20 0x58f7a4 in main /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:5010:9
    #21 0x7f6fd2dee0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: negative-size-param (/home/r1/ffmpeg/ffmpeg_4.4.1+0x497e67) in __asan_memcpy

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
BtbN pushed a commit that referenced this pull request Aug 8, 2022
In addition to .eac3, .ec3 is also commonly used by people to name raw
E-AC-3 streams. Enables automatic recognition of the eac3 format for
the .ac3 extension.

For instance Dolby Digital Plus software only support files with
.ec3. Files with .eac3 are not supported. Check issue #18 in the
public dlb_mp4base repository from DolbyLaboratories.

Signed-off-by: Ruben Gonzalez <rgonzalez@fluendo.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants