From: Joan Lluch <joan.lluch@icloud.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] Global variables in FFmpeg command expressions? Date: Mon, 15 May 2023 20:45:25 +0200 Message-ID: <F0D28566-C41D-4A8B-B851-6BCBFD7517D1@icloud.com> (raw) Hi all, I recently made a feature request to one of the community members. I was ready to pay a reasonable amount for it, but as it was a relatively quick fix, he was kind enough to implement it on his own, and I made a donation to the community instead. The feature I refer to is the “keep” parameter on the mpdecimate filter, which was implemented by Thilo Borgmann. I am a retired software developer and although I embraced some really complex projects in the past (including occasional code contributions to the LLVM compiler project) I am not currently in the disposition to do it anymore due to several reasons mostly related to age. So, I just joined this mailing list because I want to suggest a further improvement to FFmpeg, or otherwise ask for workarounds. The problem I want to solve is to trim duplicated frames of a video clip, in the same exact way that the mpdecimate does, but preserving the corresponding audio sections of the preserved video frames in correct sync on the output video. Or in other words, trim duplicated frames from a video input, while also trimming the corresponding audio, in sync. To accomplish this, I attempted commands such as this one: ffmpeg -i $INPUT -vf "select='if( gt(scene,0.00001), (st(1,t);st(2,1)), if(lte(t-ld(1),${KEEP}),st(2,1),st(2,0)) )', setpts=N/FRAME_RATE/TB" -af "aselect='ld(2)', asetpts=N/SR/TB” $OUTPUT The trick here is (or would be) to use variable number 2 from the video section to tell the audio section which frames to select (based on what the video section is selecting). However, this won't work because ‘variable’ number 2 from the first ‘select’ expression is out of scope on the ‘aselect’ expression. Therefore it always evaluates to 0 in the ‘aselect’ expression and the output goes with no audio. I think that having a way to specify ‘global’ variables, with valid scope through the entire ffmpeg command, featuring 'store global' and 'load global’ semantics, would be very helpful and would enormously increase the use cases for this library. So it would be nice if somebody would look at implementing it. I understand this is far from straightforward, but It would be game changing if done in my opinion. As said, my current use case is trimming the audio stream in sync with the video stream as described above. So alternatively, I would appreciate any hints on how to accomplish this if this is /already/ possible. Thanks John LLuch _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-05-15 18:45 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-15 18:45 Joan Lluch [this message] 2023-05-15 20:15 ` Paul B Mahol 2023-05-17 6:47 ` Joan Lluch 2023-05-18 16:33 ` Paul B Mahol
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=F0D28566-C41D-4A8B-B851-6BCBFD7517D1@icloud.com \ --to=joan.lluch@icloud.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git