Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg - excerpt from a large video file, preserving its additional streams
29 mars, par BabaGI have a video file that has a stereo audio track and two additional stereo streams of audio. I'll include the mediainfo details at the end. The closest I've come to being able to excerpt a portion of this large file, while keeping all of the streams, is this:
ffmpeg -i output.mov -ss 1200 -map 0 -c copy -to 00:21:00 -map 0:1 -c:a copy -map 0:2 -c:a copy output_excerpt.mov
This seems to give me a bunch of extra streams, though. What's a correct command to do this?
I was expecting four streams, one video, a second for the video's main audio, then two additional strems of 2channels each. This is what my command shows in mediainfo:
Complete name : output_excerpt.mov Format : MPEG-4 Format profile : QuickTime Codec ID : qt 0000.02 (qt ) File size : 492 MiB Duration : 1 min 0 s Overall bit rate mode : Variable Overall bit rate : 68.8 Mb/s Frame rate : 29.970 FPS Writing application : Lavf58.76.100 Video ID : 1 Format : ProRes Format version : Version 0 Format profile : 422 HQ Codec ID : apch Duration : 1 min 0 s Source duration : 59 s 993 ms Bit rate mode : Variable Bit rate : 58.8 Mb/s Width : 720 pixels Height : 540 pixels Display aspect ratio : 4:3 Frame rate mode : Constant Frame rate : 29.970 (30000/1001) FPS Color space : YUV Chroma subsampling : 4:2:2 Scan type : Progressive Bits/(Pixel*Frame) : 5.043 Stream size : 421 MiB (85%) Source stream size : 440 MiB (89%) Writing library : Apple Matrix coefficients : BT.470 System B/G mdhd_Duration : 60025 Audio #1 ID : 2 Format : PCM Format settings : Little / Signed Codec ID : sowt Duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 536 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Bit depth : 16 bits Stream size : 11.0 MiB (2%) Default : Yes Alternate group : 1 Audio #2 ID : 3 Format : PCM Format settings : Little / Signed Codec ID : sowt Duration : 1 min 0 s Source duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 411.2 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 44.1 kHz Bit depth : 16 bits Stream size : 10.1 MiB (2%) Source stream size : 10.1 MiB (2%) Default : No Alternate group : 2 mdhd_Duration : 60008 Audio #3 ID : 4 Format : PCM Format settings : Little / Signed Codec ID : sowt Duration : 1 min 0 s Source duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 411.2 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 44.1 kHz Bit depth : 16 bits Stream size : 10.1 MiB (2%) Source stream size : 10.1 MiB (2%) Default : No Alternate group : 3 mdhd_Duration : 60008 Audio #4 ID : 5 Format : PCM Format settings : Little / Signed Codec ID : sowt Duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 536 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Bit depth : 16 bits Stream size : 11.0 MiB (2%) Default : Yes Alternate group : 4 Audio #5 ID : 6 Format : PCM Format settings : Little / Signed Codec ID : sowt Duration : 1 min 0 s Source duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 411.2 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 44.1 kHz Bit depth : 16 bits Stream size : 10.1 MiB (2%) Source stream size : 10.1 MiB (2%) Default : No Alternate group : 5 mdhd_Duration : 60008
thanks for any guidance on this.
-
Why does fluent-ffmpeg only work when it throws the error Output stream closed
28 mars, par volume oneI am using fluent-ffmpeg to process a video file (and then upload that to Amazon S3). The code is very straightforward but it only works if:
- pipe option
{end: true}
is set in.output()
- which has a side-effect that causes the following console log output
Processing: 19.261847354642416% done Processing: 32.365144874807335% done Processing: 48.80978326261429% done Processing: 78.35771917058617% Processing: 91.49377493455148% done Processing: 99.91264359125745% done An error occurred: Output stream closed
Despite that error, it seems the file is generated correctly and it gets uploaded to Amazon S3 fine.
This is the fluent-ffmpeg code:
import {PassThrough} from 'node:stream'; import FFMpeg from 'fluent-ffmpeg'; let PassThroughStream = new PassThrough(); FFMpeg('/testvideo.mp4') .videoCodec('libx264') .audioCodec('libmp3lame') .size(`640x480`) // Stream output requires manually specifying output formats .format('mp4') .outputOptions('-movflags dash') .on('progress', function (progress) { console.log('Processing: ' + progress.percent + '% done'); }) .on('error', function (err) { console.log('An error occurred: ' + err.message); }) .on('end', function () { console.log('FFMpeg Processing finished!'); }) .output(PassThroughStream, {end: true}) .run(); // Now upload to S3 try { await s3Upload({ AWSS3Client: 'mys3client', Bucket: 'publicbucket, ACL: "public-read", ContentType: 'video/mp4', Key: 'whoever/whatever.mp4', Body: PassThroughStream }); } catch (error) { console.log(`s3Upload error`, error) }
If I set the pipe
output()
option to{end: false}
then there is no error from fluent-ffmpeg and I get"Processing: 100% done FFMpeg Processing finished!"
as the final console log.BUT the problem is that the
s3Upload()
does not do anything. There are no errors. Just no activity.I feel very uncomfortable letting
fluent-ffmpeg
end in an error even if the code itself does the job intended. It will also cause testing to fail. What could be the issue? - pipe option
-
define the input FPS of a stream using ffmpeg-python
28 mars, par tamirgIm creating an HLS playlist using ffmpeg, reading my input from an RTSP stream.
When probing the RTSP stream, i get an FPS which is not the true FPS, and i want to "tell" ffmpeg the actual real FPS.
In the command line, im using the -r flag, which works fine:
ffmpeg -rtsp_transport tcp -r 18 -i rtsp://localhost:554/test -b:v 100KB -vf format=yuvj420p -c:a copy -hls_time 2 -hls_list_size 10 -hls_flags delete_segments -start_number 1 output.m3u8
I noticed that flag must come before the input param. If i use the -r after, it simply doesnt work.
In ffmpeg-python, i dont see any option to do so. And using it as a flag to the .input() function, does not work.
How can i use the -r flag with ffmpeg-python?
-
ffmpeg video compression / specific file size [closed]
28 mars, par justin.esdersCurrently I have 80mb movies that I want to use ffmpeg to convert down to say about 10mb or 15mb. I know there will be a quality loss but they will need to have sound. Is there a way to either specify a file size or higher compression than what I have done previously
ffmpeg -i movie.mp4 -b 2255k -s 1280x720 movie.hd.ogv
They are currently about 25mb a piece
-
ffmpeg, how to cut to exactly at the start and end time ? [closed]
28 mars, par Wayne JulianAccording to this article you can only cut the time, but not specify when to cut from the original video. So the end time will always be wrong. You need to calculate each time on the timeline when your video will end.
e.g.
-ss 01:30:40 -to 03:03:05
will cut your video in the wrong order, because it starting the calculation not from the00:00:00
of the video, but from the-ss 01:30:40
Is there a workaround for this?
example command:
ffmpeg -ss 00:14:15 -an -i "2022-05-30.mp4" -to 01:30:40 -crf 23 -c:v libx264 PART1.mp4
I will lose
14:15
minutes here, it is clearly a bug. I need to extract14:15
from the end time to get the correct time of the result video. When it comes to multiple video-editing it's so annoying.