When children’s story videos have different sizes, frame rates, codecs, or audio tracks, FFmpeg may join or loop them unevenly. This guide shows how to normalize your own video files, check the results, and create a repeatable loop without changing the original files.
What You’ll Need
- FFmpeg installed and available from a terminal or command prompt. Check with
ffmpeg -version. - A folder of video files you have permission to use, plus enough free disk space for converted copies.
- A target format and playback specification. The examples below use MP4, H.264 video, AAC audio, 1280 × 720 pixels, and 30 frames per second. Adjust these to suit your player.
- A text editor or terminal for saving and running commands. Paths with spaces should be enclosed in quotes.
Step-by-Step
- Keep the originals and choose the target. Make a working copy of the files and create a separate output folder, such as
converted. Decide the resolution, frame rate, codecs, audio sample rate, and whether every clip needs audio. A consistent format means these properties match; it does not mean every story has the same duration. - Inspect each source file. Run
ffprobe -v error -show_streams -show_format -of json "story1.mp4". Look at video dimensions, frame rate, codec, pixel format, and audio stream details. This helps identify unusual files, such as a portrait video, variable frame rate, or a clip with no audio. FFmpeg can process many formats, but inspection prevents surprises. - Convert one test clip first. Use a command like:
ffmpeg -i "story1.mp4" -map 0:v:0 -map 0:a:0? -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,fps=30,setsar=1" -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -ar 48000 -ac 2 -b:a 160k -movflags +faststart "converted/story1.mp4"
The video is fitted inside a 1280 × 720 frame, with black bars where needed rather than cropping the picture. The optional audio map (0:a:0?) means a missing audio stream will not stop conversion. If the stories are silent, you can omit audio options and mapping instead of creating an audio track. - Check the test output. Play it from beginning to end, especially the opening and final seconds. Confirm that the image is not stretched or unexpectedly cropped, the sound is present at a reasonable level, and subtitles or important artwork have not been cut off. Check its properties with
ffprobeas well. If the test looks wrong, fix the settings before converting the rest. - Convert the remaining files using the same settings. Run the command for each source, changing only the input and output names. On macOS or Linux, a simple shell loop is:
for f in *.mp4; do ffmpeg -i "$f" -map 0:v:0 -map 0:a:0? -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,fps=30,setsar=1" -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -ar 48000 -ac 2 -b:a 160k -movflags +faststart "converted/${f%.*}.mp4"; done
This example processes only files ending in.mp4in the current folder. For other extensions, adapt the pattern. On Windows, run individual commands or use a PowerShell loop, taking care to quote paths correctly. - Make a concat list in playback order. Create a plain-text file called
list.txtin the output folder. Add one line per converted file, in the order you want, for example:file 'story1.mp4'
file 'story2.mp4'
file 'story3.mp4'
Use forward slashes in paths where possible. If filenames contain apostrophes, spaces, or unusual characters, use safe relative filenames or rename the copies to simple names. The concat demuxer expects valid quoting and paths. - Join the normalized clips. From the output folder, run
ffmpeg -f concat -safe 0 -i list.txt -c copy stories.mp4. Stream copying is fast and avoids another quality-loss encoding pass, but it works reliably only when the streams and encoding parameters are compatible. If FFmpeg reports incompatible streams or the join has glitches, re-encode the combined output with the same video and audio settings instead of using-c copy. - Loop the result for playback or create a longer file. For a player that supports looping, use that player’s repeat setting; this avoids creating a huge file. To make a file containing five repetitions, use
ffmpeg -stream_loop 4 -i stories.mp4 -c copy stories-5-loops.mp4. The input plays once plus four repeats. The output can be large, so check available storage first. To loop indefinitely, use a player or streaming command that supports continuous looping rather than trying to create an infinite file. - Verify the final result. Play the joined or repeated file across every transition. Listen for a brief silence, click, or abrupt change at each boundary. Confirm that the final duration is expected and that the target device accepts the codec and resolution. Keep the original sources until the result has been checked on the actual playback setup.
Common Mistakes
- Using different conversion settings. A single clip with a different frame size, frame rate, or audio layout can make concat stream copying fail. Apply the same filters and codec options to every input.
- Stretching images to fill the frame. Setting a fixed size without preserving aspect ratio distorts characters and illustrations. Use scale-and-pad to add bars, or choose a deliberate crop only when losing some image area is acceptable.
- Assuming every clip has audio. A required audio map can fail on silent files. The optional map in the example handles missing audio, but if some clips have audio and others do not, joining may still produce uneven sound behavior. Consider adding a silent audio track to silent clips if your player or workflow requires audio on every segment.
- Using
-c copyto fix mismatched files. Copying does not normalize or repair streams. Re-encode when formats or timestamps are incompatible. - Overwriting sources or making an oversized loop file. Write to a new folder and estimate the output size from the source size and number of repeats before creating a long file.
Tips
Keep a record of the exact settings so future stories match. The example’s CRF value controls quality and file size: a lower CRF generally means higher quality and a larger file, while a higher value means more compression. Try a short sample before choosing a setting for a whole collection. Use -preset to trade conversion speed for compression efficiency; it does not directly set visual quality.
Black bars are often preferable to cropping story artwork. If the display requires a different aspect ratio, choose a matching target resolution rather than stretching the picture. Also avoid changing frame rate without a reason: converting to 30 fps is practical for many playback setups, but the best target is the one supported by your device and source material.
Troubleshooting
- “File not found” or a path error: Check the current folder, spelling, capitalization, and file extension. Quote paths containing spaces, and verify that the output folder already exists.
- Concat reports different parameters: Confirm every clip was converted with the same resolution, frame rate, codec, pixel format, audio sample rate, and channel count. Re-encode the joined result if needed.
- Video is sideways or has the wrong framing: Check the source’s rotation metadata and inspect the converted file. Some inputs need an explicit rotation adjustment; do not add one blindly, because FFmpeg may already apply the rotation.
- Audio is missing, out of sync, or cuts off: Inspect the audio streams with
ffprobe. Test one file with audio mapping removed or adjusted, and check each transition. Re-encoding can correct some timestamp problems, but investigate a source that is already out of sync. - The output will not play on the target device: The device may not support the selected codec, resolution, or audio format. Check its documented playback capabilities and convert a short test to a supported combination.
- The loop has a pause or visible jump: Look for a gap or abrupt ending in the source clips. FFmpeg repeats the encoded content; it cannot make two unrelated scenes appear seamless. Trim or edit the boundary if a seamless transition is important.
Frequently Asked Questions
Does every clip need the same length?
No. Consistency means matching technical properties such as resolution, frame rate, and codecs. Clips can have different durations.
Will converting make the picture better?
No. Conversion can improve compatibility, but it cannot restore detail missing from a low-quality source. Re-encoding may reduce quality slightly.
Can I loop a playlist without creating a new video?
Yes. Use a media player or playback system with a repeat or playlist-loop option. The command-line examples are for concatenating clips or writing a finite repeated file.
Why use yuv420p?
It is a widely compatible pixel format for H.264 playback. A device with different requirements may need another format, so check its specifications.
What does -safe 0 do?
It permits paths in the concat list that the concat demuxer would otherwise reject as unsafe. Use it only with a list you created and trust; relative filenames in a controlled folder are preferable.
Can the command process every video extension?
The shell-loop example matches only *.mp4. You can add patterns for other extensions, but avoid processing files already in the output folder or accidentally overwriting your sources.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Immortals Fenyx Rising Co-op, Crossplay and Friends
- AI Inference Near the Device: When It Makes Sense
- Restore Default Settings on a Sons of the Forest Server
- How to Clean Gaming Headset Ear Pads Safely
- First Light Trophy List and How to Earn Them
- Thieves Dressed as Apple Employees: What Happened?