== test file: the phone-style clip and its result == published: ffprobe -v error -show_entries stream=codec_type,width,height:stream_side_data=rotation -of default=nw=1 result.mp4 file: result.mp4 (stored 1920x1080, rotation 90) codec_type=video width=1920 height=1080 rotation=90 codec_type=audio exit=0 published: ffmpeg -v error -i original.mp4 -map 0:v -c copy -f md5 - file: original.mp4 picture checksum MD5=5c6058b4675f4c7a7e438a81fe2c80fd exit=0 published: ffmpeg -v error -i result.mp4 -map 0:v -c copy -f md5 - file: result.mp4 picture checksum (same as the original) MD5=5c6058b4675f4c7a7e438a81fe2c80fd exit=0 published: ffprobe -v error -select_streams a:0 -show_entries stream=channels,sample_rate -of csv=p=0 mono.mp4 file: mono.mp4 (sample rate, channels) 24000,1 exit=0 published: ffmpeg -v error -i mono.mp4 -i music.mp3 -filter_complex "[0:a]aformat=channel_layouts=stereo,aresample=44100[o];[1:a]volume=0.3[m];[o][m]amix=inputs=2:duration=first:normalize=0[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -b:a 192k -shortest mixed.mp4 file: mono.mp4 + music at 30%, forced to stereo 44.1 kHz exit=0 published: ffprobe -v error -select_streams a:0 -show_entries stream=channels,sample_rate -of csv=p=0 mixed.mp4 file: mixed.mp4 (sample rate, channels) 44100,2 exit=0 published: ffmpeg -nostats -ss 10 -t 4 -i mixed.mp4 -map 0:a -af volumedetect -f null - 2>&1 | grep mean_volume file: mixed.mp4, music-only window 10-14 s (music alone is -26.4 dB; at 30% about -36.9 dB) [Parsed_volumedetect_0 @ 0x5691687befc0] mean_volume: -36.9 dB exit=0 == edge: inputs the commands were not written for == edge: a clip with no rotation flag prints no rotation line published: ffprobe -v error -show_entries stream=codec_type,width,height:stream_side_data=rotation -of default=nw=1 stereo.mp4 file: stereo.mp4 (1080x1920, no flag) codec_type=video width=1080 height=1920 codec_type=audio exit=0 edge: the mix command on a clip with no sound at all stops with an error, because there is no 0:a to mix published: ffmpeg -v error -i original.mp4 -i music.mp3 -filter_complex "[0:a]aformat=channel_layouts=stereo,aresample=44100[o];[1:a]volume=0.3[m];[o][m]amix=inputs=2:duration=first:normalize=0[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -b:a 192k -shortest mixed.mp4 2>&1 | tail -1 file: original.mp4 has no audio stream Error initializing complex filters: Invalid argument exit=234 edge: for a silent clip, map the music alone instead published: ffmpeg -v error -i original.mp4 -i music.mp3 -map 0:v -map 1:a -c:v copy -c:a aac -b:a 192k -shortest music-only.mp4 file: original.mp4 + music.mp3 exit=0 published: ffprobe -v error -show_entries stream=codec_type,channels,sample_rate:stream_side_data=rotation -of default=nw=1 music-only.mp4 file: music-only.mp4 keeps the rotation flag codec_type=video rotation=90 codec_type=audio sample_rate=44100 channels=2 exit=0 edge: channels of a stereo clip published: ffprobe -v error -select_streams a:0 -show_entries stream=channels,sample_rate -of csv=p=0 stereo.mp4 file: stereo.mp4 24000,2 exit=0 edge: music shorter than the clip. -shortest ends the file at the shorter input, so the video is cut (8 s music, 20 s clip) published: ffmpeg -v error -i original.mp4 -i music8.mp3 -map 0:v -map 1:a -c:v copy -c:a aac -b:a 192k -shortest short-cut.mp4 file: original.mp4 + music8.mp3 (8 s) exit=0 published: ffprobe -v error -show_entries format=duration -of default=nw=1 short-cut.mp4 file: short-cut.mp4, 9.9 s, not 20 s: the cut falls at a video keyframe after the 8 s of music duration=9.900000 exit=0 edge: loop the short music first with -stream_loop -1 on the music input, then -shortest ends at the video published: ffmpeg -v error -i original.mp4 -stream_loop -1 -i music8.mp3 -map 0:v -map 1:a -c:v copy -c:a aac -b:a 192k -shortest short-looped.mp4 file: original.mp4 + music8.mp3 looped exit=0 published: ffprobe -v error -show_entries format=duration -of default=nw=1 short-looped.mp4 file: short-looped.mp4, expect about 20 s duration=20.000000 exit=0