title=New title" movie.mkvCode is worth 1000 wordslet's dive into it :
youtubeVideoUrl='https://music.youtube.com/watch?v=JozAmXo2bDE' audioFormatCode='251'; audioFile='audio.webm' videoFormatCode='248'; videoFile='video.webm' yt-dlp -f $audioFormatCode "$youtubeVideoUrl" -o "$audioFile" yt-dlp -f $videoFormatCode "$youtubeVideoUrl" -o "$videoFile" ffmpeg -i "$audioFile" -i "$videoFile" -c:a copy -c:v copy 'audio_video.webm'
ffmpeg -i "$audioFile" -i "$videoFile" -c:a aac -c:v copy 'audio_video.mp4'
for audioFile in *wav; do ffmpeg -i "$audioFile" -af aformat=s16:44100 "${audioFile%.*}.flac"; done
This encodes to 16 bits at 44100 hertz.
ffmpeg -i inputFile -ss startTime -t duration -codec copy outputFile
hh:mm:ss[.xxx] format.The command above may work pretty well. But, depending on the input file itself (I got this with a .avi file), it may end in a huge series of :
Re-encoding the audio track (here in mp3 format) fixed it :
During the tests to find the right start time (-ss value), save time by not processing the input until the end :
TESTING : outputDir='./output'; mkdir -p "$outputDir"; for input in *avi; do echo "$input"; ffmpeg -y -i "$input" -ss 15.5 -t 15 -c:v copy -c:a mp3 "$outputDir/$input"; done REAL : outputDir='./output'; mkdir -p "$outputDir"; for input in *avi; do echo "$input"; ffmpeg -i "$input" -ss 15.5 -c:v copy -c:a mp3 "$outputDir/$input"; done
StreamStream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 fps, 1k tbn, 47.95 tbc (default) Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s my TV plays this audio track Stream #0.2(fre): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s I want this one played Stream #0.3(fre): Subtitle: srt Stream #0.4(eng): Subtitle: srt
StreamStream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 fps, 1k tbn, 47.95 tbc (default) Stream #0.1(fre): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s Stream #0.2(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/sWe've not picked the subtitles tracks !
This method should be preferred whenever possible since it only extracts the audio data with no reconversion :
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 389 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default) Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
encoder 'aac' is experimental and might produce bad results. Add '-strict experimental' if you want to use it.
https://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg/9570992#9570992 ffmpeg -i in.mov -vf "transpose=1" out.mov For the transpose parameter you can pass: 0 = 90Counterclockwise and Vertical Flip (default) 1 = 90Clockwise 2 = 90Counterclockwise 3 = 90Clockwise and Vertical Flip https://ffmpeg.org/ffmpeg-filters.html#transpose-1
ffmpeg -i inputFile -vf scale=iw*0.25:-1 -codec:a copy outputFile
-codec:a copy allows to stream copy the audio without re-encoding.