Flutter - How get use data in FFMPEG commands (input & output) - flutter

In Flutter, How to use data in FFMPEG commands (input & output).
Like:
ffmpeg -i 1.mp3 -i 2.mp3 -i 3.mp3 -i 4.mp3 -filter_complex "[0:a][1:a][2:a][3:a]amerge=inputs=4[aout]" -map "[aout]" output.mp3
2 Question regarding this command:
What is the path to bring the '1.mp3', '2.mp3'... to the FFMPEG.
Where is the 'output.mp3' goes to? eventually?
Didn't find any solution, let's speak locally and after that remotely (API/SERVER).

What is the path to bring the '1.mp3', '2.mp3'... to the FFMPEG.
Your ffmpeg command in your question assumes 1.mp3 and 2.mp3 are in the current working directory that ffmpeg is being executed in.
For example, in Linux if the files are in /home/aix/music, then you would have to navigate to /home/aix/music in your terminal (such as by running cd /home/aix/music) before running the ffmpeg command shown in your question.
Or, provide the full path to the files and the current directory will not matter:
ffmpeg -i /home/aix/videos/1.mp4 -i /home/aix/videos/2.mp4 ...
Where is the 'output.mp3' goes to? eventually?
output.mp3 goes wherever you tell it to. Because no path was provided the ffmpeg command in your question it will output output.mp3 into the current directory.
Or, provide the full path to output output.mp3 in the desired directory:
ffmpeg -i input.mp3 /home/aix/music/encoded/output.mp3

Related

Swapping FFMPEG input source

I'm using FFMPEG to stream RMTP to a server. I wish to change what I'm streaming without breaking the connection to this server.
My current FFMPEG command looks like so:
ffmpeg -f v4l2 -s 1280x720 -r 10 -i /dev/video0 -c:v libx264 -f flv -r 30 -pix_fmt yuv420p "rtmp://server live=true pubUser=user pubPasswd=pass playpath=stream"
If I wanted to change from /dev/video0 to /dev/video1 then I need to stop this program and re-run the command swapping out the -i bit.
Since FFMPEG can read from stdin as well as files, I believe it should be possible to switch the input source on the fly by either piping the output of a different program, or utilizing UNIX sockets. There may also be a solution built into FFMPEG which I'm not aware of.
My question now is: what's the simplest / least code / most recommended way of switching these inputs? Is there a third-party tool that's recommended? Does FFMPEG have an alternate command-line parameter I've never heard of? If I do use a UNIX socket of stdin, is there a recommended way to change what's being written to them?
One of my concerns is that if I have FFMPEG read in from a UNIX socket and in a separate shell I have a different instance of FFMPEG writing to this UNIX socket, during the brief period when I'm switching sources the first instance of FFMPEG (which is doing the broadcasting) would die, as it couldn't find any video data to stream.

How do I convert files with ffmpeg through the command line?

I do know how to actually convert the files, I don't know if the input and output should include the path of the file or just the file itself - do I write it like this:
ffmpeg -i input.ext1 output.ext2
or like this:
ffmpeg -i C:\Path\input.ext1 C:\Path\output.ext2

FFMPEG corrupting audio data when trying to edit metadata

I'm trying to use FFMPEG to edit some metadata in Powershell. My problem is that FFMPEG simply outputs an audio file with the correct metadata, but the audio does not play. The length of the track is reduced to a fraction of a second. Here is the command I'm using in Powershell:
& $ffmpeg -y -i $flac.fullname -c copy -metadata track="$tracknumber" $flac.fullname
Previously, I tried having -map 0:0 in there too, but it didn't make a difference. Thanks for any help.
Edit: I'm not sure if this is intentional behavior or not, but if I change the output path to be a new destination (rather than saving over the old destination) it does work correctly. So as a workaround, I'm just using a temp folder as an output then moving the files back to where I want them.
FFmpeg does NOT do in-place editing. Destination has to be a new file.
ffmpeg -y -i file.flac -c copy -metadata track="$tracknumber" newfile.flac

Trim mp4 files without encoding it again

I have a .mp4 video file, I need to trim it, however no matter how I do it, trimmed video is being encoded again which results in noisy video.
What I've tried:
Open video with Matlab, read frames and write only the frames that I want to have in trimmed video, I use 'MPEG-4' option.
Trim video using Windows Movie Maker.
Trim video using VirtualDub.
In first 2 scenarios original mp4 movie is encoded again after trimming it. I couldn't get mp4 files open in VirtualDub.
So what would be the easiest way to trim a video without re-encdong it?
You can do the split and re-encode in one command.
Create a text file, list.txt,
like this
file 'in.mp4'
inpoint 48.101
outpoint 67.459
file 'in.mp4'
inpoint 76.178
outpoint 86.399
file 'in.mp4'
inpoint 112.140
outpoint 125.031
then run,
ffmpeg -f concat -i list.txt -an -crf 18 out_merged.mp4
I've solved it with the following commands:
ffmpeg.exe -ss 48.101 -t 19.358 -i in.mp4 -an out_part1.mp4
ffmpeg.exe -ss 76.178 -t 10.221 -i in.mp4 -an out_part2.mp4
ffmpeg.exe -ss 112.140 -t 12.891 -i in.mp4 -an out_part3.mp4
ffmpeg -i out_part1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt1.ts
ffmpeg -i out_part2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt2.ts
ffmpeg -i out_part3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt3.ts
ffmpeg -i "concat:intrmdt1.ts|intrmdt2.ts|intrmdt3.ts" -c copy out_merged.mp4
And some explanation:
Giving -ss (start time) and -t (duration) options before -i (input) option avoids unnecessary decoding.
Not using -c copy provides transcoding hence result more precise cut (got this from here).
I used -an because I didn't need the audio, if you need audio just omit this option.
Before concatenating the resulting trimmed videos I needed to transcode them to mpeg transport streams, to achieve lossless concatenation (for more details you can see this link).

how to use -o flag in wget with -i?

I understand that -i flag takes a file (which may contain list of URLs) and I know that -o followed by a name can be specified to rename a item being downloaded using wget.
example:
wget -i list_of_urls.txt
wget -o my_custom_name.mp3 http://example.com/some_file.mp3
I have a file that looks like this:
file name: list_of_urls.txt
http://example.com/some_file.mp3
http://example.com/another_file.mp3
http://example.com/yet_another_file.mp3
I want to use wget to download these files with the -i flag but also save each file as 1.mp3, 2.mp3 and so on.
Can this be done?
You can use any script language (PHP or Python) for generate batch file. In thin batch file each line will contains run wget with url and -O options.
Or you can try write cycle in bash script.
I ran a web search again and found https://superuser.com/questions/336669/downloading-multiple-files-and-specifying-output-filenames-with-wget
Wget can't seem to do it but Curl can with -K flag, the file supplied can contain url and output name. See http://curl.haxx.se/docs/manpage.html#-K
If you are willing to use some shell scripting then https://unix.stackexchange.com/questions/61132/how-do-i-use-wget-with-a-list-of-urls-and-their-corresponding-output-files has the answer.