I am trying to use this ffmpeg command:
ffmpeg -i "full_lowq.flac" -c copy -map 0 -f segment -segment_times "302.825,552.017" "%03d_output.flac"
to take my flac file input "full_lowq.flac" and split it at specific points 302.825,552.017 into output audio files like so:
%01d_output.flac
%02d_output.flac
%03d_output.flac
And this command does work at the moment, except that my three outputted flac files display the wrong 'length' metadata number when viewed in the win10 file browser. like in this example every outputted file has the same length as 11:16
But if i view the audio files in audacity i can see the correct file length such as file 0 have a length of 05:02
Is it possible my input file (https://file.io/oof3eykKwXiI) is corrupted? or my command is making a mistake here? wrong codec?
Related
I'm trying to segment a video and name the cropped files in a specific way. Right now I'm using
ffmpeg -i input.mp3 -f segment -segment_time 59 output_%03d.wav
and looping over created files, parsing their filenames and renaming them accordingly.
I have an array which contains
array=[1650027545, 1650027300, 1650026502, ...]
and want the output files to be in;
output_1650027545.wav
output_1650027300.wav
output_1650026502.wav
format. Since there's no loop, I can't figure out how to implement such a naming scheme. Any help is appreciated!
I'm attempting to concatenate various .ts video clips into one video and then convert the video into an .mp4 file. I know I can make a .txt file formatted like so:
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
and then concatenate them like so:
ffmpeg -f concat -i mylist.txt -c copy all.ts
and then convert the file like so:
ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
My question is, can my .txt file be urls from another domain? e.g.:
http://somewebsite.com/files/videoclip1.ts
http://somewebsite.com/files/videoclip2.ts
http://somewebsite.com/files/videoclip3.ts
Or, do I first have to download all these clips, store them locally on my domain, then make a .txt file pointing to them? I'm using PHP. Thanks.
Yes, this is possible. Note that in the following examples I use the urls and filenames from your question, when testing I used some test files on my own web server.
Trying this with the example text file you provided will give a pretty clear error message:
[concat # 0x7f892f800000] Line 1: unknown keyword 'http://somewebsite.com/files/videoclip1.ts
mylist.txt: Invalid data found when processing input
This is easily fixed by re-introducing the 'file' keyword in mylist.txt:
file 'http://somewebsite.com/files/videoclip1.ts'
file 'http://somewebsite.com/files/videoclip2.ts'
file 'http://somewebsite.com/files/videoclip3.ts'
That updated file will give a different error message:
[concat # 0x7fa467800000] Unsafe file name 'http://somewebsite.com/files/videoclip1.ts'
mylist.txt: Operation not permitted
The reason for this is that ffmpeg will not allow http-urls by default. This can be bypassed by including the -safe 0 argument in your ffmpeg call before the -i argument:
ffmpeg -f concat -safe 0 -i mylist.txt -c copy all.ts
This might work out of the box on your installation, on mine this gave another error message:
[http # 0x7faa68507940] Protocol 'http' not on whitelist 'file,crypto'!
[concat # 0x7faa69001200] Impossible to open 'http://somewebsite.com/files/videoclip1.ts'
mylist.txt: Invalid argument
This is because, on my installation, ffmpeg's default protocol whitelist only includes file and crypto. To allow the http protocol as well, we need to explicitly provide the allowed protocols whitelist in the command. As it turns out, tcp is also required:
ffmpeg -f concat -safe 0 -protocol_whitelist file,http,tcp -i mylist.txt -c copy all.ts
This allowed my installation to download and concatenate the video files.
I am trying to concatenate two video files using ffmpeg, and I am receiving an error.
To eliminate compatibility issues between the two videos, I have been concatenating the same video with itself, and the same error persists.
ffmpeg \
-f concat \
-safe 0 \
-i intro_prepped.avi intro_prepped.avi \
-c copy \
concat.avi
And the error output I receive is....
[concat # 0x220d420] Line 1: unknown keyword 'RIFFf�?'
intro_prepped.avi: Invalid data found when processing input
I have tried various combinations of concat flags and have not been able to get it to work. Has anyone seen this error before?
This is a bit late for the original post, but I was just searching for answers to the same problem so I think it's still relevant and I haven't found any more recent posts answering the same problem.
I found that my .txt file was encoded wrong. I opened the file in Notepad and did a 'Save As...'
I changed the encoding to UTF-8 and the ffmpeg concat command worked.
Docs for several ways of concatenating files: https://trac.ffmpeg.org/wiki/Concatenate
Here's a command I use to concatenate videos:
ffmpeg \
-i "concat:input1.avi|input2.avi|input3.avi" \
-c:a copy \
-c:v copy \
output.avi
I tried all of the aforementioned and it didn't work.
It looks like that the file names in the list have to be specially formatted to look like:
file '/path/to/file1.wav'
with a word file included. I spend a lot of time trying to guess why ffmpeg encountered an error trying to read the file names. It didn't matter if they were in the list or in the command line. So only after I utilized a command
for f in *.wav; do echo "file '$f'" >> mylist.txt; done
to make list from ffmpeg's manual I had success. The only difference was an additional word file.
Here you can read it yourself: https://trac.ffmpeg.org/wiki/Concatenate#demuxer
Your text file is likely encoded in UTF-16.
Fix: (Windows 10)
Open text file
Select 'Save as'
Look by the save button, you get to pick encoding with a drop down box, select UTF-8.
Save and run ffmpeg again.
I used the Powershell code on ffmpegs webpage to make a text file with filenames, and Powershell seems to save text files as some variant of UTF-16, so I chose the safer UTF-8.
The input file should be a text file, not an avi. The text file lists the files to concatenate.
See the concat demuxer documentation and FFmpeg Wiki: Concat.
Nobody had a full, working, concat text file batch file anywhere. So I am posting it
md ts
for %%x in (input\*.m4a) do (ffmpeg -i "%%x" -c copy -bsf:v h264_mp4toannexb ts\%%~nx.ts)
for %%c in ("ts\*ts") do (echo file '%%c')>>list.txt
for %%f in (input\*.m4a) do (set fn=%%~nf)
ffmpeg -f concat -safe 0 -i "list.txt" -c copy "%cd%\%fn%".m4a
I struggled with all these instructions above on my Mac (M1, Ventura, ffmpeg version N-109530-g4a80db5fc2-tessus). None of them worked for me - but a combination of all did the trick!
This is how I got it running:
place all input files the same folder
create input.txt in this folder - content looks like this:
file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
file 'input4.mp4'
Note:
file encoding must be UTF-8
file keyword must be present
filename must not be fully qualified (I got exceptions using '/path/to/input1.mp4')
filename must be enclosed by '
navigate to this folder in the terminal
execute ffmpeg -f concat -i input.txt -c copy ffmpegOUT.mp4
I would like to know how to do the following :
There are 2 folders on my desktop. One is called input, the other output.
1 : Input folder contains a number of MP4 video files.
2 : I execute a .SH script (OSX) and all MP4 video files in the
folder will be resized to 2 other sizes for HLS.
3 : The original video in the folder, the highest version, will be
also moved to the output folder after the other 2 versions were
rescaled and created by FFMPEG in the output folder.
After this, we will use the Apple segmentation tool to segment all 3 versions, and automatically deleting the 3 MP4 video's left in the output folder.
I am not experienced with programming, hence I can use some help on this.
As far as I came with some code :
#!/bin/bash
Cd ~/username/Desktop/input
for name in *.mp4; do
ffmpeg -i "$name" -vf scale=854:480 "../output/${name%.*}_middle.mp4"
ffmpeg -i "$name" -vf scale=426:240 "../output/${name%.*}_low.mp4"
mv "$name" "../output/${name%.*}_high.mp4"
Thanks heaps in advance,
John
Im trying to make a video (whatever the format) from a directory full of jpeg frames.
I tried with avconv (v0.8), as seen on many topics on the internet, and the libav documentation as well :
avconv -i samples/*.jpeg output.mpeg
It seems to work nicely and create the output.mpeg file.
But the file can't be read by any reader (vlc, banshee, totem,...). No error, but nothing happend when I press Play.
If I check the video file size, it is about 20kB, whereas the original video is 10MB. So we can assume the data has not been stored into the file (it is about 20kB no matter the number of frames given on input)
I made a pastebin of the debug log of the processing. I am not familiar with codec world, so I don't understand many things : http://pastebin.com/9dfxFWZe.
I also try a lot of combinations with -s, -r, -b, -vcodec, -f format, etc.. but the probleme is still there.
Am I doing anything wrong ?
Ask me anything that could help you, I will answer very quickly.
Thank you for your help :)
avconv expects you to give the input filenames in a printf-like syntax. Simply using shell wildcards (such as samles/*.jpeg) is not enough.
Your samples seem to be named sample/lapinsnipermin/.jpeg, so try the following command line:
avconv -f image2 -i samples/lapinsnipermin/%03d.jpeg output.mpeg
Does this work? You might also want to add options for the bitrate (e.g -r 25).
Resurrecting this since it came up when Googling for a solution. I finally got it working using this:
knoppix#Microknoppix:~$ avconv -r 1 -i /tmp/photo%d.jpg -r 24 -s 320x240 -vsync cfr /tmp/video.mpg
I couldn't get avconv to recognize the input files in the original names; this shows why:
knoppix#Microknoppix:~$ strace avconv -i /media/sdb1/DCIM/188_0408/IMGP%04d.JPG /tmp/video.mpg 2>&1 | grep 188_0408
execve("/usr/bin/avconv", ["avconv", "-i", "/media/sdb1/DCIM/188_0408/IMGP%0"..., "/tmp/video.mpg"], [/* 36 vars */]) = 0
stat64("/media/sdb1/DCIM/188_0408/IMGP0000.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0001.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0002.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0003.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0004.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
write(2, "/media/sdb1/DCIM/188_0408/IMGP%0"..., 66/media/sdb1/DCIM/188_0408/IMGP%04d.JPG: No such file or directory
I didn't see an option for setting the starting number, so I did this:
i=0; for file in /media/sdb1/DCIM/188_0408/IMGP28*.JPG; do cp $file /tmp/photo$i.jpg; i=$((i+1)); done
The end result is a video of my photos, showing one for each second; the -vsync cfr tells avconv to pad the input frames to match the output framerate.
I found it better to pipe the jpg file in you want so you can control the selection with standard wildcards, try something like this. This also outputs a video that you can user on the web and mobile (ie. using the standard browser tag):
cat samples/*.jpeg | avconv -r 30 -f image2pipe -codec:v mjpeg -i - -pix_fmt yuvj420p -r 30 -c:v libx264 -vf scale=480:300 -y output.mp4