Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Why not just google it?

Lets try an example. This took chatGPT seconds to answer. Tell me how long it would take a person with zero ffmpeg experience to come up with the same solution using just google / stack overflow.

---

Create me a command using FFMPEG to convert all video files in a directory. The source files are mkv files in 4k, and they should be output as mp4 files with h264 encoding at 720p. Also, produce a thumbnail image for each cropped to 320x320 pixels using a frame of the video 10 seconds from the beginning.

    for file in *.mkv; do
        ffmpeg -i "$file" -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k -vf "select=eq(n\,300)" -s 1280x720 -frames:v 1 "${file%.*}.mp4" && ffmpeg -i "$file" -ss 10 -vframes 1 -s 320x320 "${file%.*}.jpg"
    done


Also, this does not just have to be blindly copy/pasted. ChatGPT also went on to break down exactly what this command does so you can revise it / understand it.

Here's a breakdown of the ffmpeg command and its flags used in the solution:

* -i "$file": Specifies the input file.

* -c:v libx264: Sets the video codec to libx264, which is a widely used H.264 video encoder.

* -preset slow: Specifies the encoding preset as "slow." The encoding presets range from "ultrafast" (fastest but lower compression) to "veryslow" (slowest but higher compression). "Slow" strikes a balance between compression efficiency and encoding time.

* -crf 18: Sets the Constant Rate Factor (CRF) for video quality. A lower CRF value, such as 18, indicates higher quality and larger file sizes. You can adjust this value based on your desired trade-off between quality and file size.

* -c:a aac -b:a 192k: Sets the audio codec to AAC with a bitrate of 192 kbps. Adjust the bitrate value as per your requirements.

* -vf "select=eq(n\,300)": Specifies a video filter to select the frame at the 300th second (10 seconds from the beginning) of the video. You can modify the value inside the eq() function to select a different frame.

* -s 1280x720: Sets the output resolution of the video to 1280x720 pixels, representing 720p resolution.

* -frames:v 1: Specifies that only one frame should be extracted from the video.

* "${file%.*}.mp4": Generates the output MP4 file with the same name as the input file, but with the extension changed to .mp4.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: