I have multiple video's consisting of a m3u8 file in combination with a bunch of .ts files (10 seconds a piece). I would like to be able to copy pieces from these video's in order to present only the wanted piece of a longer video to the user. The video's range from 30 minutes to 3 hours, and the piece to copy from the video can be up to 1 hour long.
The FFMPEG command I use for this:
ffmpeg -ss 00:00:01 -i /media-storage/3/308/video.m3u8 -to 00:10:25 -hls_time 10 -start_number 1 -hls_playlist_type vod -c copy /media-storage/test/video.m3u8
There does not need to be any re-encoding or converting, but the operation above takes about 30 seconds. (which is only 10 minutes)
Is there any way to improve this command to make it a bit quicker? The cutting does not need to be frame precise.
I use the latest FFMPEG release and my OS is CentOS 8
I've found the issue with the poor performance in the above command.
Turns out the SMB NAS where my data is stored is not very fast when copying data. When I use the above command on the local machine the response is almost instant.
Related
I have a mp3 file(around 7 mins) and I want to shorten the file to 1 minute. But I don't want to just cut it. I want to squish the file without changing the pitch(like speed up).
I already tried with FFmpeg, but FFmpeg just cuts it off.
For info: The file is stored in the fs.
This is doable with ffmpeg. Try using the atempo filter like this:
ffmpeg -i original.mp3 -filter:a "atempo=7.0" -vn seven-times-as-fast.mp3
It should produce a new mp3 file in the same pitch, just seven times faster.
I basically have a large collection of audio mix files in mp3 format, say approx 2 hours worth of music per mp3.
I am trying to work out the best way using the command line to output a preview MP3 file, this mp3 should have 5-10 second previews of the full mix at 6 or so points during the mix.
Example
00:00:10 - 00:00:20
00:30:00 - 00:30:10
00:50:00 - 00:50:10
...
So with the small mp3 file, you can kind of get an idea of the whole mix in a very short preview.
I have seen ffmpeg etc that can preview say 5 seconds up to 15 seconds of an audio, but not sure if this is capable of doing multiple points of the audio.
Any ideas or help is appreciated.
Use the aselect filter in ffmpeg.
ffmpeg -i in.mp3 -af aselect='between(t\,10\,20)+between(t\,1800\,1810)+between(t\,3000\,3010)' -c:v copy preview.mp3
Each between block selects a time range. Times are expressed in seconds.
If I run ffmpeg -ss $TIME -i $URL -frames:v 1 -filter:v $FILTER file.jpg -v trace to get a screenshot of a video from a remote website, it normally runs quite quickly. But videos from a different website are taking much longer to run.
All videos from one particular website are very slow. I've compared two videos that are 3-4MB, one from a website where ffmpeg works almost instantly (0.5 seconds) and another from a website where it works terribly slowly (15 seconds).
Here's the trace output for the slow video http://pastebin.pl/view/raw/4df9fb06. And here's trace output for the fast video http://pastebin.pl/view/raw/4b590932.
Can you identify any reason why one video is so much slower compared to all the other videos? The ffmpeg command I ran is the one from above and the same for both videos. How can I speed this up?
The slow video downloads a few seconds slower than the fast video, but I don't think the ffmpeg command should be showing such a major difference between the two files.
The "fast video" is a regular MP4 with its index upfront. The "slow video" is a fragmented MP4, formatted for DASH, with the samples indices, distributed across the file. To locate the samples that you are seeking to, ffmpeg has to parse the indices, so it has to download a lot more, if not the entire file.
I simply want to segment an mp3 for HTTP Live Streaming in any linux distro (preferably CentOS) for the purpose of audio streaming to an iOS app.
Out of the linux segmenters, I can get the following to compile in CentOS.
http://wiki.andy-chu.com/doku.php?id=http_live_streaming (not sure last time this was updated)
m3u8-segmenter on github (updated months ago)
https://github.com/carsonmcdonald/HTTP-Live-Video-Stream-Segmenter-and-Distributor [ruby wrappers + c] (last updated 2 years ago, and a v2 branch 9 months old)
In order to prep the file for segmenting, here is the ffmpeg conversion string to generate a valid ts file:
$ ffmpeg -er 4 -i input.mp3 -f mpegts -acodec libmp3lame -ar 22050 -ab 32k -vn output.ts
Each of the segmenters require various input switches, all quite simple, and all crash out with a seg fault. #2 actually does some segmenting, but faults after 56 segments every time. I've tried various mp3s with the same results. The issue queues for 2 & 3 are full, with no responses in months of the same issues.
Others must be doing this in a live production environment that isn't running OSX.. what are your methods?
You should try httpsegmenter # http://code.google.com/p/httpsegmenter/
It is based on the segmenter.c
I've compiled and created segmented mp3, aac, mp4.
It can be tricky to match all the compilation requirements, but after that is just "follow the instructions".
For this segmenter you don't need to create a mpeg-ts with the mp3 content. Just give the mp3 as input.
This might not be applicable but http://tldp.org/HOWTO/MP3-HOWTO-11.html mentions several services to use, including an Apache module if Icecast, for example, does not match your needs.
I posted this as comments under this related thread. However, they seem to have gone unnoticed =(
I've used
ffmpeg -i myfile.avi -f image2 image-%05d.bmp
to split myfile.avi into frames stored as .bmp files. It seemed to work except not quite. When recording my video, I recorded at a rate of 1000fps and the video turned out to be 2min29sec long. If my math is correct, that should amount to a total of 149,000 frames for the entire video. However, when I ran
ffmpeg -i myfile.avi -f image2 image-%05d.bmp
I only obtained 4472 files. How can I get the original 149k frames?
I also tried to convert the frame rate of my original AVI to 1000fps by doing
ffmpeg -i myfile.avi -r 1000 otherfile.avi
but this didn't seem to fix my concern.
ffmpeg -i myfile.avi -r 1000 -f image2 image-%07d.png
I am not sure outputting 150k bmp files will be a good idea. Perhaps png is good enough?
Part one of your math is good, the 2 minutes and 29 seconds is about 149 seconds. With 1000 fps that makes 149000 frames. However your output filename only has 5 positions for the number where 149000 has 6 positions, so try "image-%06d.bmp".
Then there is the disk size: Do your images fit on the disk? With bmp every image uses its own size. You might try to use jpeg pictures, they compress about 10 times better.
Another idea: If ffmpeg does not find a (reasonable) frame rate, it drops to 25 or 30 frames per second. You might need to specify it. Do so for both source and target, see the man page (man ffmpeg on unix):
To force the frame rate of the input file (valid for raw formats
only) to 1 fps and the frame rate of the output file to 24 fps:
ffmpeg -r 1 -i input.m2v -r 24 output.avi
For what it's worth: I use ffmpeg -y -i "video.mpg" -sameq "video.%04d.jpg" to split my video to pictures. The -sameq is to force the jpeg in a reasonable quality, the -y is to avoid allow overwrite questions. For you:
ffmpeg -y -r 1000 -i "myfile.avi" -sameq "image.%06d.jpg"
I think, there is a misconception here: the output of a HS video system is unlikely to have an output frame rate of 1000 fps but something rather normal as 30 (or 50/60) fps. Apart from overloading most video players with this kind of speed it would be counterproductive to show the sequence in the same speed as it was recorded.
Basically: 1 sec # 1000 fps input is something like 33 sec # 30 fps output.
Was the duration of the scene recorded really 2:29 min (resulting in a video ~82 min at normal rate) or took it about 4.5 sec (4472 frames) which is 2:29 min in normal playback?
I tried this on ubuntu 18.04 terminal.
ffmpeg -i input_video.avi output_frame_path_images%5d.png
where,
-i = Input