copying several segments of the same video avconv - copy

I am trying to copy several segments of one video file to a single output video file
I can do it for one segment only by using the following code:
avconv -i input.flv -ss 00:04:50 -t 00:04:00 -codec copy outputfile.flv
Is there any way to do it with several segments?

Related

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

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

Create a .m4s file with ffmpeg

I'm rying to create .m4s files and I'm using this command with ffmpeg: ffmpeg -i input.mov -c:v copy output.m4s
The file can't be created.
Output: Unable to find a suitable output format for tempM4S.m4s tempM4S.m4s: Invalid argument
I'm guessing the file format .m4s is not supported by ffmpeg which is strange because ffmpeg can create .m4s files when trying to create segments for MPEG-DASH. Is there a workaround this problem? WIll I have to use other tools or check ffmpeg's source code for hints?
m4s files do not work by themselves as they do not contain a moov box required for playback. They require an initialization fragment as well.
I am guessing you want to create m4s to include it as part of m4s series. As #szatmary mentioned, these files are not independent. So you can try this:
Merge the m4s files to one mov file.
Merge your mov file with the step 1 output file.
Split again the output file of step 2 to m4s files.
Here's how I achieved this. My use case is an audio-only stream. The backend service ships MPEG-DASH files to static hosting. I upload the initializing .mp4 segment once, subsequently only uploading each new .m4s segment.
Also, the playlist .mpd is updated every segment, in order to tell a newly arriving listener where to begin playback. The listener will pick up an initializing .mp4 file for the desired bitrate, followed by the current and following .m4s segments.
My source material is a series of 10-second media segments in uncompressed .wav format.
I'll run ffmpeg once per each new media segment
I've specified a segment size of 11 seconds, to ensure that ffmpeg generates exactly 1 output .m4s segment for each source media segment.
ffmpeg \
-i pelicans-1234.wav \
-f hls \
-ac 2 \
-c:a aac \
-b:a 128k \
-minrate 128k \
-maxrate 128k \
-start_number 1234 \
-hls_fmp4_init_filename pelicans-128k-IS.mp4 \
-hls_segment_filename pelicans-128k-%d.m4s \
-hls_segment_type fmp4 \
-hls_time 11 \
temp.m3u8

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 split/cut video using vlc in command line after every N minute?

how to split or cut a video using vlc in command line into 5 minute chucks? I know how to do it manually i just go to view->advanced controls and press the record to indicate the start time and press record again to indicate stop time now is there a way to do this in command line? if so can we also make vlc automatically cut/split the video every 5 minutes?
I'd recommend to use FFmpeg. See FFmpeg: How to split video efficiently?
The command to get the first 5 minutes would be:
ffmpeg -i input.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:05:00 output1.avi