text:
Convert mp4 to webm in a reasonable time
I have found this solution provided by hackerb9:
ffmpeg  -i input.mp4  -b:v 0  -crf 30  -pass 1  -an -f webm -y /dev/null
ffmpeg  -i input.mp4  -b:v 0  -crf 30  -pass 2  output.webm

It's works, but the second pass require more than 10 hours (for 30 minutes of video HD).
Now the question is: can I do the same things in a reasonable time?

First of all, consider to avoid "2-pass" if you only need to convert format.
Most of time, CRF is enough unless you have specific requirement on the output file size.
Use "CRF" to control on the quality and size. CRF lower means better quality.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 output.webm

There's parameter "-row-mt" for VP9 encoder to turn on "Row based multithreading" function, which enhances the number of encoder threads.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -row-mt 1 output.webm

And there're some parameters for VP9 encoder to control on the quality/speed tradeoff. So in the "Two-Pass" case, you could try to use those parameter to get more speed by give-up some quality.
-deadline can be set to realtime, good, or best.
-cpu-used sets how efficient the compression will be.
[Reference]
https://trac.ffmpeg.org/wiki/Encode/VP9
https://trac.ffmpeg.org/wiki/Encode/H.264 - "Two-Pass Section"

I have to say you thank you, even if you haven't completely solve my problem, with your script the result it's a file which before it's 1.5 GB, and now is 320 GB, with the same quality.

To speed it up you need to increase the compute power and throughput of your computer. I think on my machine the I/O is the bottleneck, but yours may be different so look at upgrading any or all of the following:

CPU - a faster processor allows for more operations per second
Hard drive - running all video operations off a separate drive to your operating system is essential for speed. For even higher throughput, you can use a RAID array of drives
Entire system - running multiple computers in parallel can, well, parallelise lengthy operations like this. This may be overkill for what you want

It may be simplest for you to just buy a new machine.

Thank you, I had considered several of these options. I have done the conversion by shutting down all other tasks and the Wi-Fi network. Regarding the 'Ferrari', I would say that it's all too easy an answer. :-)

I used to do work with cgi rendering, and the only way to do it in a sensible timeframe was to have multiple machines each with multiple processors, using a high speed RAID array. Video is not quite as computationally expensive, but it is a simple solution to get a better machine, if you have the budget


text:
What are the apparently extra files on a DVD, and what gets lost when the VOB file is converted to MP4?
This is for curiosity only; I'm not trying to break copyright.
(I own the disc and there's a much better quality version available on YouTube).
I copy one file from the disc, convert it from .vob to .mp4 format and end up with a file that's less than 15% of the size of the original disc.
What exactly gets lost during this process?
$ find /tmp/Name -type f | wc
     13      13     405

$ du -s -m /tmp/Name/*
0   /tmp/Name/AUDIO_TS
1   /tmp/Name/AUTORUN.INF
7   /tmp/Name/IVI
192 /tmp/Name/VIDEO_TS

$ ls -l /tmp/Name/VIDEO_TS/
-r--r--r-- 1 ray ray     16384 Jan 10  2003 VIDEO_TS.BUP
-r--r--r-- 1 ray ray     16384 Jan 10  2003 VIDEO_TS.IFO
-r--r--r-- 1 ray ray    116736 Jan 10  2003 VIDEO_TS.VOB
-r--r--r-- 1 ray ray     20480 Jan 10  2003 VTS_01_0.BUP
-r--r--r-- 1 ray ray     20480 Jan 10  2003 VTS_01_0.IFO
-r--r--r-- 1 ray ray     75776 Jan 10  2003 VTS_01_0.VOB
-r--r--r-- 1 ray ray 200710144 Jan 10  2003 VTS_01_1.VOB

$ ffmpeg -i /tmp/Name/VTS_01_1.VOB  /tmp/Name/Name.mp4

$ ls -l /data/Music/Download/Hurt.mp4
-rw-rw-r-- 1 ray ray 28439944 Feb 15 15:38 /tmp/Name/Name.mp4

So:

start with: 13 files, 198 Mb
select: 1 file, 192 Mb
convert: 1 file, 28 Mb

What was lost in the other 12 files?
What was lost in the 85% reduction during the conversion?
The video is 720p at 29.97 fps, and I don't see any significant difference between the two versions on a 4K monitor.

DVDs are usually encoded using an MPEG 2 codec. This is an older codec than h264, and encodes at a higher bitrate (and also encodes video differently) to a low bitrate mp4 encoder which uses an h264 codec.
The VOB files contain the video. The other files are metadata and other stuff you probably don't need if you're just looking to encode the video.
When you compress a video using any lossy compression algorithm, the codec looks for areas in each frame that the human vision system is less likely to notice. So it uses less data to encode areas with less detail in them.
So for example, someone's face might be clearly encoded, but when you look at the shadow on the wall behind them, you may see it looking blocky and those blocks jumping around, as the encoder struggles to render the original video to the best of its ability given the bandwidth constraints.
Watching on a well calibrated large display, it's usually possible to see the difference, especially on darker footage with lots of movement.  A classic way to spot it is looking at things like confetti or water, where the whole screen is in motion.  On low motion scenes, it can be hard to spot.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
ffmpeg how to change audio tbn
I changed my video container with:
ffmpeg -hide_banner -y -i in.mkv -c copy -video_track_timescale 1k out.mp4
But video_track_timescale only changes video tbn, not audio tbn.
To check it:
ffprobe -hide_banner .\in.mkv -read_intervals %+0.3 -show_entries frame=media_type,key_frame,pts,pts_time,pkt_duration,pkt_size -print_format compact
frame|media_type=video|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=16|pkt_size=203501|side_data|
side_data|

frame|media_type=audio|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=N/A|pkt_size=622
frame|media_type=video|key_frame=0|pts=17|pts_time=0.017000|pkt_duration=16|pkt_size=5333
frame|media_type=audio|key_frame=1|pts=21|pts_time=0.021000|pkt_duration=21|pkt_size=551
frame|media_type=video|key_frame=0|pts=33|pts_time=0.033000|pkt_duration=16|pkt_size=1221
frame|media_type=audio|key_frame=1|pts=43|pts_time=0.043000|pkt_duration=21|pkt_size=538
frame|media_type=video|key_frame=0|pts=50|pts_time=0.050000|pkt_duration=16|pkt_size=12132
frame|media_type=audio|key_frame=1|pts=64|pts_time=0.064000|pkt_duration=21|pkt_size=662

ffprobe -hide_banner .\out.mp4 -read_intervals %+0.3 -show_entries frame=media_type,key_frame,pts,pts_time,pkt_duration,pkt_size -print_format compact
frame|media_type=video|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=16|pkt_size=203501|side_data|
side_data|

frame|media_type=audio|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=1024|pkt_size=622
frame|media_type=video|key_frame=0|pts=17|pts_time=0.017000|pkt_duration=16|pkt_size=5333
frame|media_type=audio|key_frame=1|pts=1024|pts_time=0.021333|pkt_duration=1024|pkt_size=551
frame|media_type=video|key_frame=0|pts=33|pts_time=0.033000|pkt_duration=16|pkt_size=1221
frame|media_type=audio|key_frame=1|pts=2048|pts_time=0.042667|pkt_duration=1024|pkt_size=538
frame|media_type=video|key_frame=0|pts=50|pts_time=0.050000|pkt_duration=16|pkt_size=12132
frame|media_type=audio|key_frame=1|pts=3072|pts_time=0.064000|pkt_duration=1024|pkt_size=662

As we can see, in in.mkv, tbn is same for both audio/video aka 1k. But in out.mp4, tbn is different. Video has 1k tbn because I set it with -video_track_timescale, but where's the similar option for audio?

There's no such option for audio in MP4. MKV uses a fixed timescale of 1000 which is why audio has that tbn. In MP4, ffmpeg will set it to the sample rate.
The latter is precise.
Notice the timestamps for audio in MKV are not evenly spaced:
pts=0|pts_time=0.000000
pts=21|pts_time=0.021000
pts=43|pts_time=0.043000
pts=64|pts_time=0.064000

Compare with MP4, which are:
pts=0|pts_time=0.000000
pts=1024|pts_time=0.021333
pts=2048|pts_time=0.042667
pts=3072|pts_time=0.064000

Note that even though you said There's no such option for audio in MP4, it can be done. It's just that it's not implemented.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How do I stop OBS from contrasting my mouse pointer?
I just started transitioning from Xbox Game Bar which I previously used for recordings to OBS, and I don't know why, but the game I'm playing records the mouse in a very different way. The first image is how the recording looked to me and Xbox Game Bar, and the second is what OBS showed. Obviously, OBS is trying to contrast the mouse to the background, but I don't want that. How would I turn mouse contrast off?

This script looks as though it would allow you to add a "skin" to your mouse cursor, which would allow you to make the mouse cursor look like whatever you wanted:
https://obsproject.com/forum/resources/obs-studio-mouse-cursor-skin.1010/

I'm confused - how would I download all of this?


text:
Upscale before or after doubling framerate?
I use both Topaz AI (to upscale the resolution of the frames) and Flowframes (to double the FPS), but I'm interested in knowing whether the order of these 2 operations will affect the final result if you have any idea or a technical detail to share about this ? Thank you very much !

Probably this answer is a bit of trial and error. But Imho is a way better option to upscale the images before and double the frames after.
My tests with Flow frame showed me some glitches when two moving objects intersected. It was a 3D animation, so there was no motion blur. This shows me that the "guessing" that needs to do and analyze is way more than an upscaling. You do not want to amplify any imperfection that the process does.
Although we now have AI algorithms to upscale, it is a process that have being done for years, and it is more simple. So do this process that needs to "guess" very little. Then do the second one with "reliable" pixel data; invented but reliable.

I see your logic. Thank you very much for your answer.


text:
Removing parts of audio while leaving other parts intact
This is a bit of a niche question but, I recorded a video with a strange bird call that I was going to post somewhere for someone to ID it but there were people talking so you can’t hear the bird call that well. The human voices are at a lower pitch than the bird call. Is there any way in any software to cut out the lower pitch human voices but leave the higher pitch bird call so you can hear it better?
Thanks so much!
Tip11000

You can have a go at doing this in Adobe Audition by switching the view from Waveform to Spectral Frequency Display. If the birds and the voices occupy totally different parts of the frequency spectrum, you may be in luck.  Use the Spot Healing Brush to erase the unwanted frequences in your audio file.
More on adobe's blog page


text:
Changing the DEFAULT video stream?
I used VLC to play what's supposed to be a video file, and it plays just a still image with sound; Before trashing it, I decided to open it in the Windows Media Player, and to my surprise I can see video and sound normally.
Next I used ffprobe and discovered the video file contains 3 streams, and VLC picks up the 1st (video) stream, which is just a mjpeg image! Whereas WMP picks up the 2nd (video) stream.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mySupaDupaFile.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.33.100
  Duration: 01:46:15.80, start: 0.000000, bitrate: 3191 kb/s
  Stream #0:0[0x1](und): Video: mjpeg (Baseline) (mp4v / 0x7634706D), yuvj444p(pc, bt470bg/unknown/unknown), 749x972, 99348 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
  Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3101 kb/s, 25 fps, 25 tbr, 90k tbn
  Stream #0:2[0x3](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 82 kb/s (default)

Looking at the ffprobe output, stream#0 is marked as (default).
Does ffmpeg have a command that can unset (default) on stream-0, and set (default) on stream-1 ?
For now, I have just re-encoded into another file the h264 + aac streams, and discarded the mjpeg stream, but would like to know if it's possible just to change the default video stream ! (and more generally how to mark a stream as DEFAULT when there are multiple streams).

Final answer: Use -map to copy all 3 streams. First disposition UNSETS the existing default; Second disposition SETS the NEW default;
If you don't unset, all 3 streams are marked as default, and thus when opening in VLC the mjpeg will still play !
ffmpeg -i "myInputFile.mp4" -y ^
    -c copy -map 0:0 -map 0:1 -map 0:2 ^
    -disposition:v:0 0 ^
    -disposition:v:1 default ^
    myOutputFile.mp4

Based on https://ffmpeg.org/ffmpeg.html, there is an example of making the second audio stream the default stream:
ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv

such that making the second video stream the default stream would be
ffmpeg -i in.mkv -c copy -disposition:v:1 default out.mkv

No need for multiple commands.

@Gyan what multiple commands?

@xer-rex Using your example, I end up with the mjpeg stream as the default, and the sound stream as the default; i.e. 2 streams only, the actual video stream h264 is dropped ! But thanks for pointing me to the DISPOSITION flag, see my revised answer below.


text:
Converting a log colour space to linear using ffmpeg
I'm making some viewing files of some neg film scans. The film scans are converted to FFV1.mkv using rawcooked and then I have an ffmpeg recipe to create the viewing files.
I have managed to convert from neg to pos, but would also like to change the colour space from log to lin so the viewing files are a bit easier to watch.
Is this possible in ffmpeg?
My recipe so far :
for %%a in ("*.mkv") do ffmpeg -i "%%a" -i .\THE_LOGO.png -c:v libx264 -crf 23 -maxrate 5M -bufsize 2M -c:a aac -b:a 192k -filter_complex "yadif, format=yuv420p, negate, [1]scale2ref=w=oh*mdar:h=ih*0.17[logo][video];[video][logo]overlay=290:48, drawtext='fontfile=c\:/Windows/Fonts/Arial.ttf': timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2.2*lh) :fontsize=100 :fontcolor=white: box=1: boxcolor=black: boxborderw=7" -y "%%~na_BITC.mp4"
Many thanks :-)

I have managed to create a working recipe using curves - whilst not strictly a log to lin lut, it gives a more watchable output.
for %%a in ("*.mkv") do ffmpeg -i "%%a" -i .\THE_LOGO.png -c:v libx264 -crf 23 -maxrate 10M -bufsize 2M -c:a aac -b:a 192k -filter_complex "yadif, format=yuv420p, curves=all='0/0 0.5/0.75 1/1', curves=increase_contrast, negate, [1]scale2ref=w=oh*mdar:h=ih*0.17[logo][video];[video][logo]overlay=100:100, drawtext='fontfile=c\:/Windows/Fonts/Arial.ttf': timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2.2*lh) :fontsize=150 :fontcolor=white: box=1: boxcolor=black: boxborderw=7" -color_primaries bt709 -color_trc bt709 -colorspace bt709 -y "%%~na_BITC.mp4"


text:
Is there an equivalent to FX Console in Premiere?
The free FX Console plugin for After Effects allows you to instantly apply effects and other things to the selected clip. Is there an equivalent for Adobe Premiere? It would be a real timesaver.

Seems like Excalibur is and is even more polished than FX console but not for free :
https://knightsoftheeditingtable.com/excalibur


text:
ffmpeg max resolution surpassed
I'm creating a sprite sheet for my website which will be used as an animated background mask on a button hover. The only issue I'm having is creating the sprite sheet mask
I have 297 720p images I want to put as one long line, so I am using ffmpeg's tile_complex
ffmpeg -i %04d.png -filter_complex tile=297x1 output.png

I get this output, which basically says the image resolution is too high and therefore it can't encode
Picture size 380160x720 is invalid
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Any ideas?
For the buttons, I can descale the resolution a lot as they will appear small using this
ffmpeg -i %04d.png -vf scale=iw/6:-1 %04d.png

However, with the title that appears large on the screen, I don't want a loss of quality
I am following Kevin Powell's video on it:

The mask he uses he draws by hand, so he doesn't show how to take a pre-existing image sequence and use it

Using jimp (js)
const Jimp = require('jimp');
const path = require('path');

async function createSpriteSheet(inputPath, frameCount, frameWidth, frameHeight, outputFilePath) {
  // Create a new image to hold the sprite sheet
  const spriteWidth = frameWidth * frameCount;
  const spriteHeight = frameHeight;
  const sprite = new Jimp(spriteWidth, spriteHeight);

  // Iterate over the frames and append them to the sprite sheet
  for (let i = 0; i < frameCount; i++) {
    const framePath = path.join(inputPath, `frame_${i}.png`);
    const frame = await Jimp.read(framePath);
    sprite.blit(frame, i * frameWidth, 0);
  }

  // Save the sprite sheet to disk
  await sprite.writeAsync(outputFilePath);
}

// Example usage:
const inputPath = 'path/to/image/sequence';
const frameCount = 10;
const frameWidth = 1280;
const frameHeight = 720;
const outputFilePath = 'path/to/sprite_sheet.png';

createSpriteSheet(inputPath, frameCount, frameWidth, frameHeight, outputFilePath);

// Example usage:
createSpriteSheet(10, 1280, 720, 'path/to/sprite_sheet.png');

This code defines a function called createSpriteSheet that takes four arguments: frameCount, frameWidth, frameHeight, and outputFilePath. The frameCount argument specifies the number of frames in the image sequence, the frameWidth and frameHeight arguments specify the dimensions of each frame, and the outputFilePath argument specifies where to save the resulting sprite sheet.
To use this function, simply call it with the appropriate arguments. In the example usage above, the function is called with frameCount set to 10, frameWidth set to 1280, frameHeight set to 720, and outputFilePath set to 'path/to/sprite_sheet.png'. You should replace these values with the actual dimensions and file paths of your image sequence.

While ffmpeg is a powerful tool for video and image processing, it may not be the best option for creating sprite sheets with large image sequences due to the limitation you've encountered. However, there are other tools and libraries that can help you automate the process of creating sprite sheets without reducing the image resolution.
One such tool is TexturePacker, which is a commercial software that allows you to create sprite sheets from image sequences, with the ability to customize the layout, compression, and other settings. TexturePacker also supports multiple output formats and can generate CSS code for easy integration with your website or application.
Another option is to use a library like Phaser, which is an open-source game development framework that includes built-in support for sprite sheets. With Phaser, you can load your image sequence and automatically create a sprite sheet, which can be used to animate your game objects or as a background mask in CSS.
If you prefer a command-line approach, you can use a scripting language like Python or Node.js to automate the process of creating sprite sheets. For example, you can use the Pillow library in Python to load and manipulate images, and then generate a sprite sheet using the Pygame library or a custom script. Similarly, you can use the Jimp library in Node.js to load and process images, and then generate a sprite sheet using a custom script.
In summary, while ffmpeg may not be the best tool for creating sprite sheets with large image sequences, there are other options available that can help you automate the process without reducing the image resolution, such as TexturePacker, Phaser, or custom scripts using Python or Node.js.


text:
What does the tag "-tag:v hvc1" means?
I am using FFMpeg to compress a video to X265/HEVC. When I am doing it normally the converted video doesn't working on iPhone or iPad. But while I am using the tag - "-tag:v hvc1" in the command. Now the output video working fine. So what does the tag means? and what's the pros and cons of using this tag?
Lastly, form where I can get these tags and command easily?

The FFMpeg document gave the idea of using the tag option with a FourCC code, and H.265/HEVC Video Encoding Guide gave the idea of Final Cut and Apple stuff compatibility. The hvc1 is defined to support Apple devices.


text:
AE2023: Parent object to null-parented path with round corners?
So this is a bit of an odd usage scenario even for AfterEffects, but I wanted to see if it might be possible. Short version, I have a path that I made with the Pen tool, whose anchor points are parents to nulls, with a Round Corners effect applied.
Is there a way to get another object to animate along a path set up like this?
The only way I know of to get an object to animate along a path is to copy the path itself and paste it onto the Position property of the object I want to animate. That isn't working with this setup, and neither is trying to drag the parent pickwhip from the object's Position property to the Path property of the path layer.
Failing that, I'm out of ideas. Is what I'm describing even possible?

This isn't easily modifiable but should work:
Make the shape path
Round the corners
Make the stroke width as thin as possible but visible
Select Layer --> AutoTrace, and AutoTrace the shape, being sure to set all the tolerances very low, so the traced version closely fits your original rounded path.
After tracing, you will have a new layer containing some masks.  Make sure there's only one mask - find the right one that best matches your shape.  Delete any extra ones that appear that are not needed.
Copy the mask keyframe.
Select the new object that you want to move along the path.  Give it one position keyframe.
Paste your mask keyframes onto the position keyframe of your second object.

Not-easily-modifiable I can handle. I'm hoping that at the point where I am in the workflow I wouldn't have to make any changes to the paths--I will give this a go!

There’s also a script somewhere that converts masks to shapes, which might help you. If I find it, I’ll add it

Awesome, thank you!


text:
ffmpeg clipping: video splits on i-frames but not audio
I use ffmpeg because I want to do video editing without re-encoding. I only know the bare bones options for this though:
ffmpeg -i input.mp4 -ss 00:00:30 -to 00:05:00 -acodec copy -vcodec copy output.mp4

The audio, for the output of the above command, starts at 30 seconds, however this video only starts at the next i-frame after the 30 second mark, sometimes this might even be around 33 seconds.

Using -ss as input option together with -c:v copy might not be accurate since ffmpeg is forced to only use/split on i-frames. Though it will—if possible—adjust the start time of the stream to a negative value to compensate for that. Basically, if you specify "second 157" and there is no key frame until second 159, it will include two seconds of audio (with no video) at the start, then will start from the first key frame. So be careful when splitting and doing codec copy. https://trac.ffmpeg.org/wiki/Seeking

This is quite annoying, to have audio playing and be waiting for the video.
Is there a way to seek the audio to the same timestamp as the first video time?

Did you ever find a solution to this issue? I'm encountering the same problem.

@ACPrice no perhaps you should ask on a different stackexchange site

@ACPrice I figured out the answer

The answer is contained in this SE answer https://unix.stackexchange.com/a/388148/551103
You use two -ss. Before the input: -ss ${starting_timestamp_minus_10s}. After the input: -ss 10.
i.e.
ffmpeg -ss ${starting_timestamp_minus_10s} -i input_file -ss 10 output_file


text:
How do I create an master HLS playlist using existing .m3u8 playlists
I'm using FFmpeg to generate streaming files for a single resolution initially. Here is how my playlist and master-playlist looks like.
master.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=2305600,RESOLUTION=852x480,CODECS="avc1.640034,mp4a.40.2"
stream_480p.m3u8

stream_480p.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXTINF:10.000000,
stream_480p0.ts
#EXTINF:10.000000,
stream_480p1.ts
#EXT-X-ENDLIST

later, if I add another stream, say 720p. I want my master.m3u8 to include that stream and serve the clients. How to achieve this? Are there any existing commands in FFmpeg that I can use here? or create the master.m3u8 programmatically?

ffmpeg can only create playlists as a fresh set - which includes master and renditions. Will have to do it programmatically.

@Gyan I'm trying to do it now, but not able to figure out how to get the exact values for the BANDWIDTH and CODECS params, which I have to put in the master.m3u8. Do you know of any docs to get those values and create the master.m3u8 programmatically?

Use ffmpeg to create a fresh set of playlists and use the values printed there.

Here is how I programmatically created the master playlist, reading from 2 different master playlists using python.
        streams = list()

        # read from 1st master playlist
        primary_master_playlist = open("master_1.m3u8", "r")
        while True:
            line = primary_master_playlist.readline()
            if not line:
                break
            elif line.lower().startswith("#ext-x-stream-inf"):
                streams.append(line + primary_master_playlist.readline() + "\n")

        # read from 2nd master playlist
        secondary_master_playlist = open("master_2.m3u8", "r")
        while True:
            line = secondary_master_playlist.readline()
            if not line:
                break
            elif line.lower().startswith("#ext-x-stream-inf"):
                streams.append(line + secondary_master_playlist.readline() + "\n")

        # write to final master playlist
        final_master_playlist = open("master.m3u8", "w")
        final_master_playlist.write("#EXTM3U\n")
        final_master_playlist.write("#EXT-X-VERSION:3\n")

        for stream in streams:
            final_master_playlist.write(stream)
        final_master_playlist.close()


text:
Why is my 480p Handbrake conversion of NTSC home video DVD much larger file size than the DVD?
I'm not super experienced with video production but I understand the technical basics of resolutions, frame rates, compression types, etc.
I have an NTSC DVD containing a long (3h) home movie shot on VHS.  (A commercial outfit converted the original VHS tape to DVD many years ago.)  I'm trying to produce a digital video file for YouTube, PC viewing, etc.
I used Handbrake to convert it using the "fast 480p" setting that uses h.264 - the original video is pretty low quality to begin with.  But the converted video is over 5GB, larger than the 3GB size of the original DVD .iso image!
The only thing i can think of is that the converted NTSC video has tracking noise along the bottom edge, which might screw up compression, but can someone help me understand how converting a 480p NTSC DVD video results in a LARGER file size?  Should I be using a different compressor or something?

Try using a highe/slower compression rate, two pass compression, and or VBR below 10 Mb/s

Fast conversion does not do much compression if you select slowest setting it will produce much smaller file size. Or you could swap from H.264 code to H.265, it will reduce your file size dramatically.

I don't know if  DVD supports h.265. It's pretty new for hardware support.


text:
2 video files, one has the audio with 15FPS, the other has the video with 5FPS, audio is out of sync
I'm trying to sync the audio and video of 2 different files, one is a 15 FPS webcam stream with audio and the other is a screen share with 5 FPS. This is an educational setting.
I'm trying to do the math in my head on what causes the audio desync, is it the 10FPS difference?
I first extracted the audio from the webcam mp4 and inserted it into the video using mkvmerge, then used handbrake to encode it in constant fps and it didn't work. I tried 5, 15 and 30 fps in handbrake.
The question is, is there a way I can sync these by messing with FPS or some other property, or d I need to manually determine how desynced the audio is and manually shift it?

To repeat the answer, when files are recorded independently, they will almost always have sync issues. A full video editor is really the only solution if you must have perfect sync. In the future, an application that records both files and accounts for syncing along the way will save you this headache.

The two devices that recorded the videos weren't synchronised together, so their clocks will drift over time.  There's no way to guarantee perfect synchronisation, but if you have audio recorded on both, you could use something like Premiere's multi-cam workflow to sync the footage.  If it drifts, you'll have to do some manual editing and recutting to get it back into sync.

Thanks, hadn't thought of it that way.


text:
ffmpeg - How do I modify Channel Layout labels only on 8 separate mono audio tracks?
I have a QuickTime .mov file which has 1 video track (ProRes 4444 XQ) and 8 mono audio tracks, which combined make up the 5.1 surround mix and a stereo mixdown. Per delivery requirements, I need to modify the audio track metadata to specify which channel each track represents - F, L, C, LFE, etc. - as visible in the attached screenshot from QuickTime Player.

I have successfully modified this using a very old copy of QuickTime Pro 7 running on Windows, but I would like to use ffmpeg on a modern system. The .mov file is exported from DaVinci Resolve, but there doesn't seem to be any option for modifying these labels. With ffmpeg, I have attempted numerous combinations of -map and -filter_complex flags, but I have not been successful yet.
I know I can keep the 8 audio tracks separate using the following command, but with the channel layout for each still listed as 'mono':
ffmpeg -i test_8mono.mov -c:v copy -c:a pcm_s24le -map 0:v:0 -map 0:a:0 -map 0:a:1 -map 0:a:2 -map 0:a:3 -map 0:a:4 -map 0:a:5 -map 0:a:6 -map 0:a:7 ~/Desktop/test1.mov
I know I can output only one of the 8 tracks using this command, and have the channel layout correctly listed as 'Left' in QuickTime Player:
ffmpeg -i test_8mono.mov -c:v copy -c:a pcm_s24le -filter_complex "[0:a]channelmap='map=0':channel_layout=FL" ~/Desktop/test1.mov
But I cannot figure what combination of these two will keep all 8 tracks separate (not multi-channel audio), but with channel_layout specified for each.

For anyone who needs the same thing as OP - MultitrackMaker for Mac does exactly this and is free.  Haven't tried it on Ventura, but it runs on Monterey.  https://www.mixagesoftware.com/index.html

Thank you! Completely solved my problem and it runs fine on macOS 13.3.1.


text:
FFmpeg is encoding at a lower bitrate than what is specified
I'm fairly new to FFmpeg, I'm using this command: ffmpeg -i "C:\FFmpeg\Handbrake\Trackmania\Trackmania.mp4" -c:v libx264 -preset veryslow -b:v 10000  -fps_mode passthrough "C:\FFmpeg\Handbrake\Trackmania\Compressed\AV1\QSV VERYSLOW.mp4", but FFmpeg is actually encoding at around 300kbps, which result in a horrible video quality. I've tried changing the bitrate, but this doesn't fix the issue

-b:v is bitrate, so 10000 is 10 kbps. You probably want 10000k.

Thanks ! I was used to AV1 with QSV that had the bitrate in Kilobits by default


text:
Use same output file name from pipe as input name with ffmpeg
I'm trying to get the output name to be the same as the input name while using the pipe command in ffmpeg.
The file is called 1-Minute Audio Test for Stereo Speakers & Headphones [2ZrWHtvSog4].m4a
I'm trying to get the output filename to be automatically the same as the input file name but with the mp3 extension.
So the final name should be 1-Minute Audio Test for Stereo Speakers & Headphones [2ZrWHtvSog4].mp3 without having to type it in manually.
Example:
yt-dlp -o - -f 139 --external-downloader aria2c --external-downloader-args '-d ./ -x 10' https://www.youtube.com/watch?v=2ZrWHtvSog4 | ffmpeg -i pipe: -codec:a libmp3lame -b:a 8000 -ac 1 -ar 8000 test_audio.mp3

These commands create a file called test_audio.mp3 it should be 1-Minute Audio Test for Stereo Speakers & Headphones [2ZrWHtvSog4].mp3
I'm not sure how to pipe the name variable from the input file to the output file of ffmpeg.

yt-dlp -o - -f 139 --external-downloader aria2c --external-downloader-args '-d ./ -x 10' https://www.youtube.com/watch?v=2ZrWHtvSog4 | ffmpeg -i pipe: -codec:a libmp3lame -b:a 8000 -ac 1 -ar 8000 -f mp3 "$(basename "$(yt-dlp -e https://www.youtube.com/watch?v=2ZrWHtvSog4 | sed 's/[\/:*?"<>|]/_/g')").mp3"

To use the same output file name from the pipe as the input name with ffmpeg, you can modify the command as follows:
yt-dlp -o - -f 139 --external-downloader aria2c --external-downloader-args '-d ./ -x 10' https://www.youtube.com/watch?v=2ZrWHtvSog4 | ffmpeg -i pipe: -codec:a libmp3lame -b:a 8000 -ac 1 -ar 8000 -f mp3 "$(basename "$(yt-dlp -e https://www.youtube.com/watch?v=2ZrWHtvSog4 | sed 's/[\/:*?"<>|]/_/g')").mp3"

Explanation:

The basename command is used to extract the base name from the URL. It retrieves the video title using yt-dlp -e https://www.youtube.com/watch?v=2ZrWHtvSog4 and then replaces any characters that are not allowed in file names with underscores using sed 's/[\/:*?"<>|]/_/g'.
The $(...) syntax is used to execute a command and use its output as part of the larger command.
$(basename "$(yt-dlp -e https://www.youtube.com/watch?v=2ZrWHtvSog4 | sed 's/[\/:*?"<>|]/_/g')").mp3 is the resulting file name with the .mp3 extension added.

Replace test_audio.mp3 in your original command with the modified file name expression. This will create an output file with the same name as the video title retrieved from the URL.


text:
With ffmpeg print onto clipped video hh:mm:ss time *from original* and hh:mm:ss total duration from original
I am using arch linux and bash and ffmpeg, all are up to date and the latest versions.
I am clipping a video that is 30 seconds long and wish to clip from 5 secs to 10 seconds to a new file, from the original.
In the bottom right hand corner of the clip I wish to show timestamps from the original video as follows

in the  5th second "00:00:05/ 00:00:30"
in the  6th second "00:00:06/ 00:00:30"
etc
in the 10th second "00:00:10/ 00:00:30"

This is an apparentley simple question(?) but the syntax of the command is not at all obvious and I am hoping an expert may shed some light on this.
All I have so far for the drawtext part, which does not do what I want as it only counts the elapsed time from t=0 of the new clip, whereas I want it to show the timestamp and total duration of the original clip
drawtext I started with
"drawtext=text='%{pts\:gmtime\:0\:%M\\\\\:%S}':fontsize=24:fontcolor=black:x=(w-text_w-10):y=(h-text_h-10)"

ffmpeg line with drawtext I have started with
ffmpeg -ss 00:00:05 -i  "$in_file" -filter_complex "drawtext=fontfile=font.ttf:text='sample text':x=10:y=10:fontsize=12:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=5,drawtext=text='%{duration\:hms}':fontsize=12:fontcolor=black:x=(w-text_w-10):y=(h-text_h-10)" -t 5 -c:a copy -c:v libx264 out_file.mp4

Here is the solution.
The ffmpeg presentation timestamp %{pts} can only be zeroed and offest, as far as I know, using the C gmtime function, with the time set to 1st Jan 2000 in unix time seconds, ie 946684800 seconds, or some other arbitrary time at midnight.
946684800 seconds in UNIX time gives midnight 00:00:00 on 01/01/2000  as a starting point for our calculations, to which we can add our own offset, in this case 5 seconds, as follows.
We don't display the %d-%m-%Y portion of the date, so our method is not seen. Works very well. Took a bit of figuring out though.
# set file names
in_file="my_video_file.mp4"
out_file="my_video__clipped.mp4"

# set start and end times of the clip to be made
start_time_z="00:00:05"
end_time_z="00:00:10"

######################################################################
##########                                                  ##########
##########       get the duration of the                    ##########
##########          input video in hh:mm:ss format          ##########
##########        and convert it to seconds                 ##########
##########                                                  ##########
######################################################################

total_duration=$(ffprobe -v error -show_entries format=duration \
  -of default=noprint_wrappers=1:nokey=1 "$in_file" \
  | awk '{printf("%02d:%02d:%02d\n", ($1/3600), ($1%3600)/60, $1%60)}')

# escape the ":" in the time stamp so that they can be printed by ffmpeg
total_duration="$(echo $total_duration | sed 's@:@\\:@g')"

# display the duration of the original video. Check we have captured it correctly
####    yad --text="\n\n$total_duration\n\n" --button="Submit":0

######################################################################
##########                                                  ##########
##########       convert the variable                       ##########
##########             $start_time_z   which                ##########
##########                    = 00:00:05                    ##########
##########                                                  ##########
##########    into seconds and add to it unix time for      ##########
##########           00:00:00 on 1st Jan 2000               ##########
##########                                                  ##########
######################################################################

# convert the clip start time from hh:mm:ss to seconds
start_secs=$(echo "$start_time_z" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')

# convert the clip end time from hh:mm:ss to seconds
end_secs=$(echo "$end_time_z" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')

# duration of the clip
duration_z=$((end_secs-start_secs))

# Add start time to 946684800 which is 00:00:00 on 1st Jan 2000
total_z=$(echo "$start_secs + 946684800" | bc)
echo $total

######################################################################
##########                                                  ##########
##########   run the command to create the MAIN  clip       ##########
##########                                                  ##########
######################################################################

#   below string shows unix time in action
#     by removing the %d-%m-%Y portion we remove the 01-01-2000 part
#       this appears to be the only way to shift pts and add a time shift onto it

# drawtext=fontfile=font.ttf:text='%{pts\:gmtime\:$total_z\:%d-%m-%Y %T} / "$total_duration"':fontsize=$main_clip_font_size:fontcolor=white:x=(w-text_w-10):y=(h-text_h-10)" \

ffmpeg -ss "$start_time_z" \
    -i "$in_file_name" \
    -filter_complex \
"drawtext=fontfile=font.ttf:text='%{pts\:gmtime\:$total_z\:%T} / "$total_duration"':fontsize=$main_clip_font_size:fontcolor=white:x=(w-text_w-10):y=(h-text_h-10)" \
       -t  $duration_z \
       -c:a copy -c:v libx264 \
       "$out_file"

Does anyone know of a native ffmpeg command, or other way to add and offset in seconds to ffmpeg's %{pts} command without the above workaround?


text:
how to input ffmpeg to live loop 6 or 8 hours?
I'm currently using this, and i want it to be loop 6 or 8hours, how to edit this?
ffmpeg -re -y -i HayDay.mp4 -c:a copy -ac 1 -ar 44100 -b:a 96k -vcodec libx264 -pix_fmt yuv420p -vf scale=1080:-1 -r 30 -g 60 -tune zerolatency -f flv -maxrate 2000k -preset veryfast "rtmps://live-api-s.facebook.com:443/rtmp/FB-222653387188323-0-AbwCY_lFkOiN-FhG"

The direct answer is to add -stream_loop -1 -t 6:00:00 before -i HayDay.mp4 but the better answer is to encode it once and then apply the above options to the encoded file and stream that.


text:
ffmpeg showing "landscape resolution" for portrait video
I have two video files, one on landscape and one on portrait. On my phone's gallery detail screen their resolutions are, respectively, 1280x720 and 720x1280. This is correct because the landscape video has the width larger than the height and the portrait one has the opposite.

However if I use ffprobe to get video resolution, they both show 1280x720.
$ ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 20230531_083540.mp4
1280x720

$ ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 20230531_085120.mp4
1280x720

Is there something I'm missing? Complete ffprobe output for both files below.
$ ffprobe 20230531_083540.mp4
ffprobe version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20230531_083540.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-05-31T11:40:02.000000Z
    com.android.version: 13
    com.android.capture.fps: 30.000000
  Duration: 00:03:20.57, start: 0.000000, bitrate: 5366 kb/s
  Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1280x720, 5111 kb/s, 30.01 fps, 30 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      rotate          : 180
      creation_time   : 2023-05-31T11:40:02.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -180.00 degrees
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2023-05-31T11:40:02.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]

$ ffprobe 20230531_085120.mp4
ffprobe version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20230531_085120.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-05-31T11:59:27.000000Z
    com.android.version: 13
    com.android.capture.fps: 30.000000
  Duration: 00:04:27.17, start: 0.000000, bitrate: 4627 kb/s
  Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1280x720, 4370 kb/s, 29.78 fps, 30 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      rotate          : 270
      creation_time   : 2023-05-31T11:59:27.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of 90.00 degrees
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2023-05-31T11:59:27.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]

ffprobe is correct.
Generally, cameras will store portrait videos as landscape along with metadata to indicate to players if the video needs to be re-oriented for display.
See the following in the ffprobe readouts:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20230531_083540.mp4':
...
Side data:
  displaymatrix: rotation of -180.00 degrees

and
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20230531_085120.mp4':
...
Side data:
  displaymatrix: rotation of 90.00 degrees

Oh, okay! Yeah, I figure it was something like that but didn't pay attention to that Side data. Thanks a lot!

Though it's strange how Samsung shows the resolution after the rotation.


text:
Is Interlaced Scanning compatibile with Dolby Vision
I've tried setting the resolution to 1080i while Dolby Vision is active and it would revert to 2160p.
So is Interlaced Scanning compatible with Dolby Vision?
I didn't manage to find a definitive answer on the internet.

Interlaced scanning is a legacy carried from SDR TV to Full-HD era, and it's long deprecated in the UHD time. So yes, Interlaced scanning will be incompatible with any UHD technology, including Dolby Vision (which is an HDR format)


text:
Overlay text annotation on an independent video track
I have 25 short videos of family (~3 min each) that I would like to label with names of the various people. There can of course be many people on the screen at once, so I need to be able to add multiple labels (maybe with a box around the person and the name below, I'll have to see what it looks like). The labels also need to move with the person they're labeling, so AI object tracking would be nice, but that sounds complex/expensive so I can do that manually if need be.
This will make it easy to see who's who, but it would ruin the video for casual viewing. So I also want to be able to turn this layer/track off, just like subtitles.
This is inspired by Flickr's note feature, but that's just for static images.
So my questions are:

Can I do this with a standard format like MP4? I'd like to avoid a proprietary format or website if possible, since this is for genealogy and will be archived. Who knows if "VideoAnnotations.io" will still be a thing in 30 years.
HOW do I do this? I'm even having trouble figuring out how to search for what I want, since I'm not a video person and I don't really know the right terms to use. I'd appreciate a description of what this process is called, and then what tools I'd need to do it. Hopefully free tools, although I can get free access to iMovie, Pixelmator Pro and Adobe Creative Cloud. (I've never used Premire, but… there's a first time for everything.)
It would be awesome if this could just be a text file I set next to the video, like an .srt, which would hold the various screen locations, strings and time stamps. I'd be willing to sacrifice a lot in the looks department to get something simple like this. But I don't know if it exists.

I have learned that subtitles are WAY more flexible than I understood. Using the free Aegisub tool, you can create multiple, overlapping subtitle lines synced up to video or audio. And you also have control of the font, size, style and position of the text. So while it would still be a pain to use this to have labels literally follow people moving around the screen, you can easily place temporary text next to the person the first time they show up, and let the viewer do the "tracking" themselves.
And the best part is that the subtitle files are all just UTF-8 text, so they're small and easily to edit as needed. And the subtitle format used, .ass, is a standard which is supported by VLC.


text:
ffmpeg amerge ignoring channel layout
I am trying to reconstruct a 7.1 channel output after processing, and ffmpeg keeps outputting a 5.0(side). (trimmed for readability)
ffmpeg -i "intermediate/refined.mka" -i "intermediate/extracted.data" -filter_complex "\
...
[ml9][mr9][mc2][ms1][mm2][mt2][mw2][me2]amerge=inputs=8,aformat=channel_layouts=7.1[out]" -map "[out]" "intermediate/mixed.mka"

Output:
...
Input #0, matroska,webm, from 'intermediate/refined.mka':
    Stream #0:0: Audio: wavpack, 44100 Hz, stereo, fltp
...
Input #1, dts, from 'intermediate/extracted.data':
    Stream #1:0: Audio: dts (DTS-HD MA), 48000 Hz, 7.1, s32p (24 bit)
...
Output #0, matroska, to 'intermediate/mixed.mka':
    Stream #0:0: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.0(side), fltp, 448 kb/s

I am feeding 8 mono channels into amerge and adding the 7.1 aformat constraint, and it gives me a 5.0 without warning or error. By everything I've read in the docs amerge should only add channels, never discarding them. Any idea what's going on here?

AC3 doesn't support 7.1.  Only took like 25 hours of messing with the filter chain to figure it out.


text:
Decoding H.264/AVC Frames in MP4: What's the Output Format?
I am currently working on a personal programming challenge to develop an MP4 decoder using VB.NET and the .NET Framework 4.8.1 as a WinForms application. I have obtained the ISO 14496-12 documentation, which serves as the basic structure for MP4 files.
At this stage, I have successfully prepared various lists containing frame sizes, chunk positions, and information from the stsc and stts boxes. Additionally, I have been able to identify keyframes within the MP4 files.
However, I have come to realize that the ISO 14496-12 documentation is not sufficient for decoding the frame bytes, which are encoded in H.264/AVC. To proceed with decoding, I understand that I need to refer to the ISO/IEC 14496-10 documentation specifically for H.264/AVC.
My question is twofold:

When decoding the frame bytes according to the documentation, would the output data be in a specific format, such as JPEG (identified by the FF D8 marker), or would it be raw bytes representing pixel data? This clarification would help me. In the former case, I could simply save an image using .NET functions.
Considering my current progress and the information I have mentioned, do you foresee any need for me to purchase a third documentation source?

Any guidance or suggestions would be appreciated.

"would the output data be in a specific format, such as JPEG (identified by the FF D8 marker), or would it be raw bytes representing pixel data?"

An H.264 decoder should decode to raw YUV by default, although it's generally appreciated for standalone use to have a YUV4MPEG2 mode as well, for easier piping, and to have basic format metadata preserved.
Usually the encoding is in YU420P format. There are many examples of converting (via a For-loop) any YUV420p data into RGB data. You can finally encode the newly converted RGB into JPEG.

"Do you foresee any need for me to purchase a third documentation source?"

No, unless you want to also handle audio then you'll need the AAC documentation. That is iso/iec 13818-7. You can also learn by analysing AAC bytes whilst following the source code of some open-source projects that are decoding AAC data. Articles online also explain structure of AAC. You can still get a result without the ISO document itself (eg: read articles from those who repeat its words as they teach about AAC audio's bytes structure).

Good, that made me confident.


text:
ffmpeg - Copy the first 2 tracks of audio to new 6 tracks so all 8 tracks contains audio from the first 2
I have a 2 audio track mxf file and need to clone the video but create 8 audio tracks. The tracks 1 and 2 should be copied into 3 and 4, 5 and 6 and 7 and 8. Some files that I'm dealing with are 4 track files with the silence in 3 and 4, and some are genuine 2 track mxf's with a mono audio in each one. Not wearing my ffmpeg boots for quite some time, any ideas how to achieve this? Thanks!

In case anyone ever needs it, this worked out for me, the combination of split filter and map.
-filter_complex "[0:1]asplit=4[1:1][1:3][1:5][1:7];[0:2]asplit=4[2:2][2:4][2:6][2:8]"

-map 0:v:0 -map "[1:1]" -map "[2:2]" -map "[1:3]" -map "[2:4]" -map "[1:5]" -map "[2:6]" -map "[1:7]" -map "[2:8]"

The whole command:
ffmpeg -y -i <input_2_tracks>.mxf -filter_complex \
"[0:1]asplit=4[1:1][1:3][1:5][1:7];[0:2]asplit=4[2:2][2:4][2:6][2:8]" \
-map 0:v:0 -map "[1:1]" -map "[2:2]" -map "[1:3]" -map "[2:4]" -map "[1:5]" \
-map "[2:6]" -map "[1:7]" -map "[2:8]" \
-c:v copy -c:a pcm_s24le -ar 48000 <output_8_tracks>.mxf

This will take input with any number of tracks and copy the first two tracks into the eight tracks in the output file. The asplit arguments [1:1][1:3] etc. may be named arbitrarily.


text:
Sound Effect Identification and Text Pop Up Editing
I watched this aviation video and I am trying to replicate the text pop-up exactly like this in Adobe Premier Pro when it says GROSSKOTZENBURG:
https://www.dropbox.com/s/26cbgpw235f2374/PilotsEye%20Sound%20Effect.mp4?dl=0
Specs are:

Background sound effect as soon as the text appears (if you could kindly help me identify what effect is used precisely, that would be much appreciated as I really like it)
Text appears to reveal itself in stages and moves as the video moves (if you could guide me to a youtube tutorial that perhaps covers the text motion side of things)
Text revelation itself (animation) - if you could point out a tutorial that covers this, would be highly appreciated

Apologies if my question isn't up to the standards of this forum

The sound is three short 1kHz sine wave bursts with a gap between them. You could generate this in Adobe Audition or Audacity.
The effect looks like a 2D motion track in after effects, so the movement of the text tracks the movement of the landscape.  Before that there are two position and scale keyframes to make the text jump into position and out of position at the end.
All of this could be made with After Effects or Premiere. Here's a tutorial that explains both methods:

The font looks like Helvetica Neue Extended Light according to WhatTheFont.

Wow! I love you man. Thank you for your time.
Can I buy you a coffee?


text:
Video delay when transcoding from an nginx-rtmp-module RTMP stream
I am using the nginx-rtmp-module for accepting RTMP streams and then publishing them locally for transcoding with FFmpeg.
After a recording is made, there is an observable freeze in the video for the first ~1-2 seconds, but the audio plays without issue. After that initial pause, the video will start playing without issue.
This issue only appears when the FFmpeg process starts after the RTMP stream has already been published locally. If the FFmpeg process is started before the RTMP stream has been received by the nginx-rtmp-module, I do not observe the freeze.
I would like to know what is causing this issue and if it can be avoided. Any assistance would be greatly appreciated. Thank you.
Flow:
[Internet] -------->[RTMP stream]-------->[Server running nginx-rtmp-module]-------->[FFmpeg attached to locally publish RTMP stream (rtmp://localhost/live/stream-key)]
Tools used:
https://github.com/arut/nginx-rtmp-module
FFmpeg version 5.1.3-1
Example command:
ffmpeg -loglevel info -hide_banner -y \
-i rtmp://localhost/live/stream-key \
-c:v libx264 -s 640x360 -b:v 600k -profile:v main -preset veryfast \
-c:a copy \
output.mp4

I found a solution on the nginx side by setting the wait_key and wait_video options to on in the nginx.conf file.
https://github.com/dreamsxin/nginx-rtmp-wiki/blob/master/Directives.md#wait_key


text:
How to filter out black frames from ffmpeg command that takes screenshots?
I'm using this command to create screenshots from a video, each time there is a frame change.
ffmpeg -i "$video_file" -filter_complex "select=bitor(gt(scene\,0.5)\,eq(n\,0))" -vsync drop "$frames_dir/%04d.jpg"
It seems to work pretty well, but there are a few black images in the screenshots that I'd like to remove.
I'm not well versed in advanced ffmpeg commands and I think the command above can be adapted to throw away the black frames. Does anybody know how?

Use the blackframe and metadata filters after select.
ffmpeg -i "$video_file" -filter:v "select=bitor(gt(scene\,0.5)\,eq(n\,0)),blackframe=amount=1,metadata=mode=select:key=lavfi.blackframe.pblack:value=95:function=less" -vsync drop "$frames_dir/%04d.jpg"


text:
Extracting a screenshot from a video using ffmpeg
I feel like this should be so simple but I just can't find any way to do it. I simply want to grab the opening frame of a video file and output it as a PNG within a filter-complex command.
I can do this using the following command in isolation although I get a warning:
ffmpeg -y -i infile -frames:v 1 output.png

[image2 @ 0000020bbf053640] The specified filename 'output.png' does not contain an image sequence pattern or a pattern is invalid.

[image2 @ 0000020bbf053640] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.

How do I incorporate the same outcome in a filter-complex function?
I have used the following crop command:
ffmpeg -y -i input.mp4 -filter_complex "[0]crop=iw:ih[grab]" -map [grab] "out.png"
and although I do get the required output, I get warning/error which I'd rather not get:

[image2 @ 000002a9089c1280] The specified filename 'out.png' does not contain an image sequence pattern or a pattern is invalid.

[image2 @ 000002a9089c1280] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.

[image2 @ 000002a9089c1280] Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?
av_interleaved_write_frame(): Invalid argument

Error muxing a packet for output file #0

Just drop the output label "[grab]" so you don't have to -map it.
$ ffmpeg-4.4-amd64-static/ffmpeg -y -i input.mp4 -filter_complex "[v:0]crop=iw:ih" -frames:v 1 -f image2 out.png

On newer versions of FFmpeg, you'll get a warning that tells you that you have to put a number pattern in your output filename. You can ignore this warning, since you're using the -frames:v 1 option to write only a single frame to that file.
However, if you drop the -frame parameter, you'll get an error, because FFmpeg tries to write to the same file again (as indicated by the frame counter at the end):
$ ffmpeg-6.0-amd64-static/ffmpeg -y -i input.mp4 -filter_complex "[v:0]crop=iw:ih" -frames:v 1 -update 1 -f image2 out3.png
[...]
[image2 @ 0x5f5b280] The specified filename 'out3.png' does not contain an image sequence pattern or a pattern is invalid.
[image2 @ 0x5f5b280] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.
[image2 @ 0x5f5b280] Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?
av_interleaved_write_frame(): Invalid argument
[out#0/image2 @ 0x5f5b140] Error muxing a packet
frame=    2 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.40 bitrate=N/A speed= 1.1x
video:2023kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

Despite the error, the first frame is still written to disk, and that's what you wanted anyways.
To avoid these warnings and errors, pass the -update 1 option which tells the image2 muxer that it's okay to overwrite the same image file over and over again. Since you're writing a single file only with the frames:v 1 option, the -update 1 option is unnecessary, but doesn't hurt.
Of course, if you're using number patterns in your filename, you won't encounter this overwrite issue at all, e.g.: out_%03d.png.

As the 2nd warning says, use -frames along with -update.
ffmpeg -y -i input.mp4 -filter_complex "[0]crop=iw:ih[grab]" -map [grab] -frames:v 1 -update true "out.png"

Thanks for your help. I tried to upvote but am not reputationable enough.


text:
FFMPEG on AWS Lambda Only outputs half a second of video when converting video from mobile safari
I am running FFMPEG on AWS Lambda using nodejs (installed via @ffmpeg-installer/ffmpeg).  I am able to convert videos recorded on most devices / browsers, but when I attempt to convert videos recorded on Mobile Safari, the length of the output video is ~1/2 a second regardless of the input length.
The command executed in the lambda is:
ffmpeg -i input.mp4 -y -crf 18 -vcodec libx264 -codec:a aac -preset medium  output.mp4

Using FFprobe, The metadata of the input file is:
{
  streams: [
    {
      index: 0,
      codec_name: 'h264',
      codec_long_name: 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
      profile: 'Baseline',
      codec_type: 'video',
      codec_tag_string: 'avc1',
      codec_tag: '0x31637661',
      width: 1920,
      height: 1080,
      coded_width: 1920,
      coded_height: 1080,
      closed_captions: 0,
      film_grain: 0,
      has_b_frames: 0,
      sample_aspect_ratio: 'N/A',
      display_aspect_ratio: 'N/A',
      pix_fmt: 'yuvj420p',
      level: 40,
      color_range: 'pc',
      color_space: 'unknown',
      color_transfer: 'unknown',
      color_primaries: 'unknown',
      chroma_location: 'left',
      field_order: 'progressive',
      refs: 1,
      is_avc: 'true',
      nal_length_size: 4,
      id: '0x1',
      r_frame_rate: '30000/1001',
      avg_frame_rate: '60000/1991',
      time_base: '1/600',
      start_pts: 26,
      start_time: 0.043333,
      duration_ts: 4008,
      duration: 6.68,
      bit_rate: 10175170,
      max_bit_rate: 'N/A',
      bits_per_raw_sample: 8,
      nb_frames: 'N/A',
      nb_read_frames: 'N/A',
      nb_read_packets: 'N/A',
      extradata_size: 31,
      side_data_type: 'Display Matrix',
      displaymatrix: '',
      rotation: '-90',
      tags: [Object],
      disposition: [Object]
    },
    {
      index: 1,
      codec_name: 'aac',
      codec_long_name: 'AAC (Advanced Audio Coding)',
      profile: 'LC',
      codec_type: 'audio',
      codec_tag_string: 'mp4a',
      codec_tag: '0x6134706d',
      sample_fmt: 'fltp',
      sample_rate: 48000,
      channels: 1,
      channel_layout: 'mono',
      bits_per_sample: 0,
      initial_padding: 0,
      id: '0x2',
      r_frame_rate: '0/0',
      avg_frame_rate: '0/0',
      time_base: '1/48000',
      start_pts: 0,
      start_time: 0,
      duration_ts: 319488,
      duration: 6.656,
      bit_rate: 181302,
      max_bit_rate: 'N/A',
      bits_per_raw_sample: 'N/A',
      nb_frames: 'N/A',
      nb_read_frames: 'N/A',
      nb_read_packets: 'N/A',
      extradata_size: 2,
      tags: [Object],
      disposition: [Object]
    }
  ],
  format: {
    filename: 'input.mp4',
    nb_streams: 2,
    nb_programs: 0,
    format_name: 'mov,mp4,m4a,3gp,3g2,mj2',
    format_long_name: 'QuickTime / MOV',
    start_time: 0,
    duration: 6.723333,
    size: 8651792,
    bit_rate: 10294646,
    probe_score: 100,
    tags: {
      major_brand: 'iso5',
      minor_version: '1',
      compatible_brands: 'isomiso5hlsf',
      creation_time: '2023-08-05T19:03:15.000000Z'
    }
  },
  chapters: []
}

Any ideas on why the output of my command on this file always results in a ~0.5 second long output?

Turns out that the version of FFmpeg that I had installed via the @ffmpeg-installer/ffmpeg npm package was ~5 years out of date (compiled in 2017). I manually updated to the latest version and the problem with ios Safari videos disappeared.


text:
ffmpeg error Input link parameters do not match the corresponding output link parameters
I need to concatenate n mp4 videos of different resolutions via ffmpeg. However, I am receiving an error despite the fact that in the filter_complex before performing the concat operation I scale all the vdeos to the same resolution:
Example of the command with 3 videos:
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex "[0:v]scale=1024:576:force_original_aspect_ratio=1[v0]; [1:v]scale=1024:576:force_original_aspect_ratio=1[v1]; [2:v]scale=1024:576:force_original_aspect_ratio=1[v2]; [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" -map [v] -map [a] output.mp4

Output:
$ ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex "[0:v]scale=1024:576:force_original_aspect_ratio=1[v0]; [1:v]scale=1024:576:force_original_aspect_ratio=1[v1]; [2:v]scale=1024:576:force_original_aspect_ratio=1[v2]; [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" -map [v] -map [a] output.mp4
ffmpeg version 2023-08-28-git-b5273c619d-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 17.100 / 58. 17.100
  libavcodec     60. 23.100 / 60. 23.100
  libavformat    60. 10.101 / 60. 10.101
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9. 11.100 /  9. 11.100
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2021-10-08T12:31:56.000000Z
  Duration: 00:03:15.51, start: 0.000000, bitrate: 464 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1444x876 [SAR 1:1 DAR 361:219], 335 kb/s, 30 fps, 30 tbr, 30k tbn (default)
    Metadata:
      creation_time   : 2021-10-08T12:31:56.000000Z
      handler_name    : Mainconcept MP4 Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2021-10-08T12:31:56.000000Z
      handler_name    : Mainconcept MP4 Sound Media Handler
      vendor_id       : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-02-28T15:42:03.000000Z
  Duration: 00:03:00.70, start: 0.000000, bitrate: 518 kb/s
  Stream #1:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1796x970 [SAR 1:1 DAR 898:485], 390 kb/s, 30 fps, 30 tbr, 30k tbn (default)
    Metadata:
      creation_time   : 2023-02-28T15:42:03.000000Z
      handler_name    : Mainconcept MP4 Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
  Stream #1:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2023-02-28T15:42:03.000000Z
      handler_name    : Mainconcept MP4 Sound Media Handler
      vendor_id       : [0][0][0][0]
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video3.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-02-27T11:18:11.000000Z
  Duration: 00:03:00.67, start: 0.000000, bitrate: 589 kb/s
  Stream #2:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1800x970 [SAR 1:1 DAR 180:97], 461 kb/s, 30 fps, 30 tbr, 30k tbn (default)
    Metadata:
      creation_time   : 2023-02-27T11:18:11.000000Z
      handler_name    : Mainconcept MP4 Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
  Stream #2:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2023-02-27T11:18:11.000000Z
      handler_name    : Mainconcept MP4 Sound Media Handler
      vendor_id       : [0][0][0][0]
File 'output.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 (h264) -> scale:default
  Stream #0:1 (aac) -> concat
  Stream #1:0 (h264) -> scale:default
  Stream #1:1 (aac) -> concat
  Stream #2:0 (h264) -> scale:default
  Stream #2:1 (aac) -> concat
  concat -> Stream #0:0 (libx264)
  concat -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_concat_3 @ 000001c73586c800] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586c800] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while filtering: Invalid argument
[Parsed_concat_3 @ 000001c73586b300] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586b300] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[Parsed_concat_3 @ 000001c73586c600] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586c600] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[Parsed_concat_3 @ 000001c73586ce00] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586ce00] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[out#0/mp4 @ 000001c73710c900] Nothing was written into output file, because at least one of its streams received no packets. frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=N/A bitrate=N/A speed=N/A
Conversion failed!

The solution provided to this problem in this question partially solves the problem, as the second concatenated video has no audio (the first one does), but I still can't figure out how to extend the solution to 3 or more videos.
Anyone know how to help me?

You're setting force_original_aspect_ratio to 1 (decrease) so the videos can't be assumed to be the same resolution after scale. You'll need to pad the video to a common resolution and then reset the SAR.
So,
scale=1024:576:force_original_aspect_ratio=1

should become
scale=1024:576:force_original_aspect_ratio=decrease,pad=1024:576:-1:-1,setsar=1

Thanks a lot, now it works


text:
How can I create a POV scene with no camera movement?
I'd like to create a POV scene where my hands are visible doing something, but the camera must not move.
Something like this (jump to 1:00)

I think some kind of POV gear which is mounted to the body is not working here, since there's absolutely no movement of the camera.
Any ideas?

Use a stable mount that keeps the camera strictly in position. Then work from behind that.

You are correct, the camera is not mounted to the body in that example.
Instead, use a tripod or work surface mount to hold you camera in front of you. For modern small cameras, it is easy to ensure it does not get in your way.


text:
Can not upload 4K 60 FPS video from Iphone 14 Pro to Youtube with default settings
I can not upload 4K 60 FPS video from Iphone 14 Pro to Youtube from PC (with Camera default settings).
Site says about unsupported format.
How to fix this without 3rd party apps?

Are you recording HEVC files?  YouTube says it supports it, but that would be my first guess - try switching and see if it works...
From Apple's support page:

Go to Settings > Camera.
Tap Formats.
Tap Most Compatible.

YouTube recommend using H.264 files:
https://support.google.com/youtube/answer/1722171
You might be able to convert your files to h.264 format using Windows' built in hidden video editor inside the Photos app (but I'm on a Mac so can't confirm).

The default upload resolution is 1080p,
Try to change the upload quality settings to "full quality" on the YouTube app.
I hope this helps.


text:
How do you edit the video by lowering the quality and then uploading it again using Premiere Pro like this video?
https://www.youtube.com/shorts/cXGA9wAMuSY
I want to edit it like this video, but I want to know how to edit it by lowering the quality and then raising it again.

It's an effect known as Data Moshing - here's how to do it in After Effects:
https://www.premiumbeat.com/blog/datamoshing-make-footage-look-trippy/


text:
How can i go higher than the frequency limit set on EQ band 6 automation in davinci resolve
Very new to audio stuff so sorry if i get some terms wrong in advance.
I'm using automation to keyframe the frequency on band 6 in the EQ as shown here

Even when it hits the bottom, i still dont feel its enough. Band 6 seems to have a frequency limit (automation wise) that changes depending on the starting point of the band. This image shows what i want automation to keep doing but it wont. i start it at 20k6 and it stops at 1k4 for some reason.

I can move the band before hand to get a lower frequency but that also effects the starting point. My goal is to get a stronger muffle effect at the end by automating the 6th band to go lower while keeping the same starting point. Please let me know if there is a better way to get this effect.

it's in the manual…page 3300 (yeah, ikr, it's a big manual, but it is searchable;)
Im trying to do this without having to launch DaVinci, as my machine is currently editing another huge project in a different app.
Each of the bands will have a highest & lowest frequency it can reach. Try maybe the middle band. Set it to hi-shelf [which is not quite the same as hi-pass, but should be OK for this]. If it will reach even 12k it's probably high enough to start.
Dial in a negative gain - you can automate this too.
You can change the slope with the Q dial.
Then automate reducing the frequency over the period you need the sound to get duller.
With a little fiddling, you ought to be able to get what you want, with only a maximum of 6 parameter points in your automation.


text:
FFmpeg does not encode chapter titles
I am trying to add chapters to a .mp4 file.
When I tried extracting the metadata using the following command:
ffmpeg -i INPUT.mp4 -f ffmetadata FFMETADATAFILE.txt
I got an output file as follows:
;FFMETADATA1
major_brand=mp42
minor_version=0
compatible_brands=isommp42
encoder=Lavf60.15.100

So now I try to add some chapters as such
[CHAPTER]
TIMEBASE=1/1000
START=0
END=424510
title=mytitle1

[CHAPTER]
TIMEBASE=1/1000
START=424511
END=941600
title=mytitle2

[CHAPTER]
TIMEBASE=1/1000
START=941601
END=1227260
title=mytitle3

I use the ffmpeg -i INPUT.mp4 -i FFMETADATAFILE.txt -map_metadata 1 -codec copy OUTPUT.mp4 command to encode the metadata to my video file, and for some reason I only ever get 'Chapter 0', 'Chapter 1', and 'Chapter 2'.
I tried using the -map_chapters 1 argument as well but results have been unchanged.
I am using the Latest Auto-Build (2023-10-14 13:02) Windows build by BtbN. Thanks in advance for the help.

Does adding using the combination -map_metadata 1 -map_chapters 1 work? See https://superuser.com/a/1320404 .

@baltakatei adding -map_chapters was the solution for me. thank you

Turns out the latest version by BtbN and gyan.dev does have an issue, because the chapters encoded just fine when I used the version 5.1.2 build by gyan.dev.
I previously tried using the release version 6.0 but it had the same problem, so the solution is to simply use release version 5.1.2.

Possibly related: https://trac.ffmpeg.org/ticket/10482


text:
Can FFmpeg create a gradient box with colors sampled from the box edges?
As shown in these video screen captures, I would like to replace the text in the upper left of the videos to another language.
What I am thinking is first to create a gradient box with colors that are automatically sampled along the edges of the box. Then it would be easy to drawtext the replacement text. For each video file, the background gradient doesn't change, so it can be sampled only once for each file.
Is this possible in FFmpeg? Other ideas on how to achieve the text replacement is also welcome.

I eventually found an answer to my question: FFmpeg delogo filter
delogo options I used for the videos in the question is: (for testing you can set show=1)
delogo=x=85:y=47:w=300:h=40:show=0
Sample ffmpeg/ffplay -vf options for encoding, delogo + drawtext filters:
-vf "delogo=x=85:y=47:w=300:h=40:show=0,drawtext=text='SampleText':fontfile="${FONTFILE}":fontcolor=white:fontsize=34:x=93:y=54:alpha=0.9"

delogo is pretty neat, I wonder how they did this. Quite fast too.


text:
Video editing software that automatically performs search-and-replace
My employer owns a number of video recordings that discuss a company product. Many of those videos were created using Camtasia, a commercial video editing software product. The video recordings repeatedly mention terminology associated with a given company product. That terminology is used both in the audio and video portions of those video recordings. When that terminology is used in the video portion of the video recordings, the related text was often entered into a Powerpoint slide deck that was then incorporated into the video recording.
A small amount of updated terminology needs to be incorporated into both the audio and video portions of those video recordings. I'd like to see whether there are one or more tools that we might use to automatically perform a search-and-replace operation for the updated terminology.
Ideally:

Text shown in the video would be updated using the same font and other formatting used in the original text to display the updated terminology.
Audio would be updated using a credible simulation of the original speaker's voice reading the updated terminology.

Whatever degree of automation we can use to accomplish this task would be worth our consideration.
I'd like to thank the StackExchange Video Production community for your anticipated assistance in answering this question.

While each of these things you want are technically possible right now, in reality you would need to create the tooling for your needs. There is no off the shelf product to do this, there is no way to shortcut the effort you need to make.
tl;dr - you're going to need to re-record the audio, and recreate the powerpoint slides and edit them into your video.


text:
ffmpeg make 1s of 240fps video from 4s of 60fps?
How can I use ffmpeg to create 1 second of 240fps from every 4 seconds of 60fps video?
I see only seen questions asking for the opposite.
Background
Our drone is only able to capture 60fps, but if we move it around slowly and compress 4 seconds into 1 second then we should make a "slow motion" video. Right?

The basic command would be
ffmpeg -i 60fps.mp4 -vf "settb=1/240,setpts=(PTS-STARTPTS)/4,fps=240" out.mp4

I assume audio is absent or immaterial.


text:
No Resize Handles showing in Kdenlive
When I try to resize the Motion Tracking "Marquee", I am not getting the "Resize Handles" that used to be there yesterday. I am sure I hit a wrong key somewhere, but I dont have a clue what it might be and not sure of the name for them so google searches come back with random videos that do not mention these "Resize Handles". Any clue how to get them back?
The Image on the Left is what I am getting, the Image on the Right is what SHOULD be showing,

I found it. After uninstalling, reinstalling, updating, I finally found the answer. It is the button near the Play controls, looks like a Crop Tool, says "Show/Hide Edit Mode"


text:
Convert Anamorphic Pixels to Square Ones and Preserve Displayed Image Size
Given a video with anamorphic pixel aspect ratio (see the screenshot from HandBrake).

What I need is to stretch the images stored in the video stream (in other words, to convert the video to 1:1 pixel aspect ratio). So, the converted video should have the following parameters:
- Storage Size: 758x540
- Display Size: 758x540
- Pixel Aspect: 1:1

The only way that currently I can think up is to export the images, scale them by means of a bash utility like convert, and assemble them back into a video.
Are there any simpler ways to do that?
Notes: I'm currently using HandBrake, MKVToolNix GUI, and Kdenlive on Ubuntu OS. Any other software recommendations are welcome.

I think I've found the solution. In HandBrake, set Anamorphic to None, tick Allow Upscaling, and change Scaled Size. Unticking Automatic may also be needed. If so, playing with the first value in Display Size and second value in Scaled Size may be required.


text:
Math formula for finding 'HH:MM:SS:MMM' Timecode given a number of frames and FPS?
I have been at this for a few days and while I have made progress I am stuck on the last bit, getting timecode to display as HH:MM:SS:MS rather than HH:MM:SS:FF. To do this I need a formula for the milliseconds part
I know this is will be complicated for Drop-Frame Timecodes so I have ruled them out. I am only concerned with NDF Timecodes.
The formula I have for finding a NDF Timecode, for example a video of 30 frames with a 12 FPS:

To get the hours, 30 / (12* 3600), 3600 is the number of seconds in a hour
To get the minutes, 30 / (12 * 60) - (0 * 60), 0 is the sum from step 1
To get the seconds, (30 / 12) - ( (0 * 3600) - (0 * 60)
To get the frames, 30 % 12 (Modulas)

The Timecode would be 00:00:02:06, as shown at Frames to Timecode Calculator.
I would like to make a slight tweak at step 4, to instead get the milliseconds needed for format HH:MM:SS:MMM. I have tried to unsuccessfully solve it on my own, I searched around and turned up with nothing too.
I am not a math wizard by any chance, not even a half rate one. I would really like to learn how to do this though. Any help would be greatly appreciated!

Frames are fractions of a second, thus:
frameduration = 1 / framerate
framecomponent = totalframes % framerate
millisecondscomponent = framecomponent * frameduration * 1000
// finally
millisecondscomponent = ((totalframes % framerate) * 1000 ) / framerate

In your example:
millisecondscomponent = ((30 % 12) * 1000 ) / 12 = 500 ms

Thank you for this, I understand it much better now and can do it on my own.


text:
Vertical text with drawtext filter
Is there any way to overlay vertical (eg, Japanese) text using the ffmpeg drawtext filter?
I've searched around but didn't find anything.  The documentation makes reference to the ft_load_flags= vertical_layout as a parameter to libfreetype but searching further came up with nothing.
Something like this:

drawtext using textfile
echo "こ
れ
は
蹤
型
で
す
。" > test.txt

ffmpeg -i "input.mp4" -vf "
drawtext=textfile=test.txt:
fontcolor=white:
font='Noto Serif CJK JP':
fontsize=h/12:
x=w-text_w-20:
y=(h-text_h)/2
" -c:a copy -t 5 output.mp4 -y
ffplay output.mp4

That is a clever solution!  I'll give it a try. Thank you

Works great. Thank you!


text:
Setting the default subtitles
I managed to create the subtitle file, using different language with one single FFMPEG command:
ffmpeg -y -loglevel "repeat+info"
-i "file:Intervista.mp4"
-i "file:Intervista_fr.srt"
-i "file:Intervista_en.srt"
-i "file:Intervista_it.srt"
-c copy
-map 0 -dn -map "-0:s" -map "-0:d"
-map "1:0" "-metadata:s:s:0" "language=FR" "-metadata:s:s:0" "handler_name=French"  "-metadata:s:s:0" "title=French"
-map "2:0" "-metadata:s:s:1" "language=ENG" "-metadata:s:s:1" "handler_name=English" "-metadata:s:s:1" "title=English"
-map "3:0" "-metadata:s:s:2" "language=ITA" "-metadata:s:s:2" "handler_name=Italiano"  "-metadata:s:s:2" "title=Italiano"
"file:output.mp4"

For some reason, the default subtitles shown when I start the video is English, which is the one in the middle. How do I set the default subtitle file to Italian?

Add -disposition option :
-disposition:s:0 0 -disposition:s:1 0 to clear the disposition for first and second subtitles (fr and eng).


text:
librav1e cannot even utilize half of my CPU
Since I heard librav1e is kind of the fastest AV1 software encoder, I attempted to use it to convert an old MPEG-4 Visual video to AV1, but the result is way slower than the popular SVT-AV1 encoder. When I was using the default preset and a vbr of ~1200kbps of SVT-AV1 I can get an about 110 fps speed for that video, but when I use librav1e it barely exceeds 8fps, even with --speed 10. Manually setting thread count or ramping up tiles does not work either. When I examine closely I see my CPU usage is normally 100% all the time with SVT-AV1, but with rav1e I only get about 30%~40% CPU Utilization.
I have confirmed that rav1e is using AVX2 by piping YUV output to a natively-built rav1e, both on Windows and Linux, so now I am quite puzzled by the situation: why does rav1e failed to pump out the full potential of my machine?
For a bit more context I am using a gaming laptop with 5800H CPU.

rav1e isn't the fastest AV1 software encoder. Compared to the other encoders, it's barely been developed since 2020 when Mozilla laid off many of their employees, including the Xiph team working on rav1e. No one's probably bothered to rethink the "fastest and safest AV1 encoder" tagline, or maybe they think it's technically correct because rav1e is the only AV1 encoder written in Rust, which is a memory-safe programming language, thus making rav1e the fastest AV1 encoder that is also "safe".
In any case, I think the claim is misleading to most people who come across it.
The actually fastest AV1 software encoder is SVT-AV1, followed by libaom (to the best of my knowledge. I have no idea about proprietary encoders, and FOSS ones seem to be the only ones relevant to your question). rav1e is the slowest and least efficient of the pack. It only supports tile threading, and it's inadvisable to split an old, likely low-resolution MPEG-4 file to enough tiles to saturate a 16-thread CPU. Tiles decrease compression efficiency and ideally you'd avoid them altogether.
I kinda doubt you'll be able to get 100% CPU utilization with any of these encoders, though YMMV as always. I'm only getting ~75% CPU usage at best on a Ryzen 7 3700X (measured with /usr/bin/time -f "%P"), depending on the preset. If you have a bunch of files you need to encode, consider running two or more encoding processes in parallel if you want to max out your CPU.


text:
Insert Audio at Every 60 Seconds and Delay Another Audio Stream until the End of the Inserted Audio with ffmpeg
I am trying to use FFmpeg to insert an audio clip at every 60 seconds into an audio file. I also want to delay the original audio stream  until the end of the inserted audio clip , so that the inserted audio doesn't overlap with the original audio.
I would prefer a solution that doesn't involve splitting the original file into 60 seconds videos and then combine then together , as it makes the following steps, that I have to do, many times more complex.
Possible Solution:
I think the -ss flag could be used to set the timestamp of the inserted audio clip to 60 seconds after the end of the last segment. Then, I could use a delay filter to delay the original audio track until the end of the inserted audio clip.
However I am not sure how to create command. Mainly the part , where we apply this filter at every 60 seconds intervals.
Thanks for any help in advance!!

concat demuxer
#!/bin/bash

f="../input.mp3"
a="in.mp3"

# get duration of input
d=$(ffprobe -v 0 -show_entries format=duration -of default=nw=1:nk=1 "$f")

# get seconds
d=${d%.*}
echo $d

# variables
i=0
o=60

# create list of inputs
l="list.txt"
echo "ffconcat version 1.0" > $l
echo "file '$f'" >> $l
echo "outpoint $o" >> $l
# increase variables by 60 sec
i=$o
((o+=60))
while (( $i < $d )); do
    # insert audio clip
    echo "file '$a'" >> $l
    # add audio next 60 sec
    echo "file '$f'" >> $l
    echo "inpoint $i" >> $l
    echo "outpoint $o" >> $l
    # increase variables by 60 sec
    i=$o
    ((o+=60))
done
cat $l

ffmpeg -f concat -safe 0 -i "$l" -c copy output.mp3 -y

ffplay output.mp3

could you please explain me, how this solves it , so I can extend and use it to my needs?


text:
How to create a video WITHOUT alpha, from a png sequence WITH alpha using ffmpeg
I have a sequence of pngs with alpha, and I'd like to encode to h264 without alpha, overlaid on black.
My usual command for image sequence to h264 is
ffmpeg -r 30 -i 'template %05d.png' -c:v libx264 -pix_fmt yuv420p out.mp4
(unfortunately -pattern_type glob -i '*.png' doesn't work on windows)
But this seems to be doing something strange, as if treating the alpha as single bit:

Where the alpha is 1, the output pixels are from my input image (correct and nice).
Where the alpha is 0, the output pixels in the video is black (correct and nice).
But anywhere in between, it's as if it's ignoring the alpha for those pixels.

My alpha is straight (not premultiplied), and I'd like the output to be as if I'd overlaid the images with non-premultiplied alpha on black.
See image below (from aftereffects. left: alpha, middle: desired output, right: ffmpeg output)

(Note. Everything I've searched on this topic always comes up with "how to preserve alpha in video". But that's not what I'm after).

Use the overlay filter to composite the output image.
ffmpeg -framerate 30 -i 'template %05d.png' -vf "split=2[bg][img];[bg]format=yuv420p,drawbox=c=black:t=fill[bg];[bg][img]overlay=alpha=straight" -pix_fmt yuv420p -c:v libx264 out.mp4

That worked, Thank you!


text:
Getting an error when attempting to use FFmpeg to copy primary AC3 audio to aac_he secondary audio
I am attempting to add secondary audio with FFmpeg to copy my primary audio over and encode it with libfdk_aac using profile aac_he. When I do, I am getting the following errors:
[NULL @ 000001f4d7830b80] [Eval @ 0000003fb93fdf50] Undefined constant or missing '(' in 'aac_he'
[NULL @ 000001f4d7830b80] Unable to parse option value "aac_he"
[NULL @ 000001f4d7830b80] Error setting option profile to value aac_he.
Error setting up codec context options.
Error initializing output stream 0:1 --*
Here is the command I am trying to use:
ffmpeg -y -fflags -genpts -i -map 0:v -c:v copy -map 0:a -c:a:0 copy -map 0:a -c:a:1 libfdk_aac -profile:a aac_he e:\nf.ts
I would expect it to copy the Primary audio to Audio 1 (AC3), and then re-encode the audio from Audio 1 to to Audio 2 (aac_he).
If I only use aac native audio, instead of aac_he, it works fine using this command:
ffmpeg -y -fflags -genpts -i %%f -map 0:v -c:v copy -map 0:a -c:a:0 copy -map 0:a -c:a:1 aac e:\nf.ts
From this, I get Audio 1 (AC3) and Audio 2(aac).
or it works if I just re-encode the primary audio like using this command:
ffmpeg -y -fflags -genpts -i %%f -map 0:v -c:v copy -map 0:a -c:a:0 libfdk_aac -profile:a aac_he e:\nf.ts
From this, I get Audio 1(aac_he)
Is there something about using the aac_he in the secondary audio position that ffmpeg has issues with?

-profile:a aac_he applies to all output audio streams. Apply it to only the intended stream; -profile:a:1 aac_he.


text:
Action cam - Bad video color in some cases - reason?
if you compare these two screenshots which were made from a video (DJI Osmo Action 4) with the same settings, you see the quality on the one is pretty nice, but the trees in the other one look pretty bright with bad quality.
What could be the reason, that the trees look so bad in the other case? It is because it was too light and should I have used some ND filter or something?
Color was set to "normal, 10bit", light is set to "auto", recording was 4K 25 frames.

The second image isn't exposed as well as the first image. If the camera was on Auto mode, it will continuously try to adjust the exposure and colour settings to compensate to get the best image recorded. But sometimes it will fail to correctly guess the right settings.
All cameras have a lower dynamic range than your eyes, so they have to make some compromises through adjustments to colour, exposure, white balance etc to create a pleasing image.
Check the manual on pages 13-14 for how to manually adjust exposure and white balance. You will get more consistency, but this might be less useful on an "action" camera, where you're often shooting for motion and excitement rather than precise accuracy (e.g. if you set the exposure in an outdoor position, then go into a tunnel, the camera will not adjust the exposure and the image will appear too dark).

Ok thanks, that explains it. So would it basically be better to make all settings manually to find a compromise that fits for all different landscapes?
(Currently I use only 2 profiles, one for dark indoor videos, so everything is set to manually, and one for outdoor where almost all the settings are set to auto)