Tag Archives: ffmpeg

How to Combine an Image and Audio File to Video File

Motivation:

  • You have a JPG and WAV file. You want to combine them to a FLV file in order to upload it to YouTube without losing audio quality.
  • You have a JPG and MP3 file. You want to combine them to a MP4 file in order to upload it to YouTube.

Combining JPG and WAV to FLV:

  1. Download ffmpeg.
  2. Unzip the downloaded package to C:\Users\admin\Downloads\ffmpeg-7.0.1-essentials_build folder.
  3. Copy your image.jpg and audio.wav file to C:\Users\admin\Downloads\ffmpeg-7.0.1-essentials_build/bin folder.
  4. Open Command Prompt.
  5. Execute the commands below.
    cd C:\Users\admin\Downloads\ffmpeg-7.0.1-essentials_build\bin
    ffmpeg -r 1 -loop 1 -i image.jpg -i audio.wav -acodec copy -r 1 -shortest -vf scale=1280:720 output.flv
  6. Open output.flv file to verify result.
  7. Upload ouput.flv file to YouTube.

Combining JPG and MP3 to MP4:

  1. Download ffmpeg.
  2. Unzip the downloaded package to C:\Users\admin\Downloads\ffmpeg-7.0.1-essentials_build folder.
  3. Copy your image.jpg and audio.mp3 file to C:\Users\admin\Downloads\ffmpeg-7.0.1-essentials_build/bin folder.
  4. Open Command Prompt.
  5. Execute the commands below.
    ffmpeg -loop 1 -framerate 1 -i image.jpg -i audio.mp3 -map 0 -map 1:a -c:v libx264 -preset ultrafast -tune stillimage -vf fps=10,format=yuv420p -c:a copy -shortest output.mp4
  6. Open output.mp4 file to verify result.
  7. Upload output.mp4 file to YouTube.

 

 

 

How to Trim, Cut or Combine MP4 or MP3 Files Without Re-Encoding

Motivation:

  • You have MP4 files with unwanted portions. You want to trim these portions.
  • You want to cut a MP4 file into files with equivalent length for uploading to specific storage that limits length of an uploaded video.
  • You want to combine multiple MP4 files into single file for copying to specific storage in a single upload.
  • You want to trim start and end portion of MP3 file.

Trimming MP4 file:

  1. Download XMedia Recode.
  2. Unzip the downloaded package.
  3. Click on the XMedia Recode.exe file to open the application.
  4. Open a MP4 file.
  5. Under the Format tab set
    Profile = Custom
    Format = MP4
    File Extension = mp4
  6. Click the Video tab and set Mode = Copy on the middle panel.
  7. Click the Audio tab and set Mode = Copy on the middle panel.
  8. Click the Filters/Preview tab and set Start Time and to (End Time) value text boxes.
  9. Click the Add to queue button (with the + icon) on the tool bar.
  10. Click the Encode button on the tool bar.

Splitting MP4 file to multiple files with equivalent length:

    1. Download XMedia Recode.
    2. Unzip the downloaded package.
    3. Click on the XMedia Recode.exe file to open the application.
    4. Open a MP4 file.
    5. Under the Format tab set
      Profile = Custom
      Format = MP4
      File Extension = mp4
    6. Click the Video tab and set Mode = Copy on the middle panel.
    7. Click the Audio tab and set Mode = Copy on the middle panel.
    8. Click the Filters/Preview tab and specify appropriate time range for each file, for example from 00:00:00:0000 to 00:09:00:0000.
    9. Click the Add to queue button (with the + icon) on the tool bar.
    10. Click the Encode button.

    Repeat the procedure for the same file with different time ranges.

    For example use time range from 00:09:00:0000 to 00:18:00:0000 for creating the second file, then time range from 00:18:00:0000 to 00:27:00:0000 for creating the third file, etc.

    Combining multiple MP4 files into single MP4 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP4 files to the bin folder.
    4. Create vidlist.txt with the content below in the bin folder.
    file 'Part 1.mp4'
    file 'Part 2.mp4'
    file 'Part 3.mp4'
    file 'Part 4.mp4'
    file 'Part 5.mp4'
    file 'Part 6.mp4'

    4. Open Command Prompt, navigate to the bin folder and execute the command below.

    ffmpeg -f concat -safe 0 -i vidlist.txt -c copy output.mp4

    Trimming start and end portion of MP3 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP3 file to the bin folder.
    4. Execute the command below:
    ffmpeg -ss 671 -t 2169 -i 01.mp3 -c:a copy out_01.mp3
    # -s: start position (in seconds)
    # -t: end position (in seconds) 
    # -c:a copy: no reencoding.