7

I would like to download a few videos from youtube and convert them to 3gp so that I can play them on my phone. I would like to know how this can be done using ffmpeg.

I tried the various results on the net only to get the following errors.

  1. I used:

    ffmpeg -i dil.mp4 -sameq -ab 64k -ar 44100 dilenada.3gp
    

I got:

Unsupported codec for output stream #0.1

Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 29.92 (359/12)

  1. I used:

    ffmpeg -y -i dil.mp4 -r 20 -s 352x288 -b 400k -acodec libfaac -ac 1 -ar 2000 -ab 24k dilenada.3gp
    

I got:

Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 29.92 (359/12)

Unknown encoder 'libfaac'

What am I doing wrong?

1
9

Use the following command:

ffmpeg  -y -i movie.mp4 \
        -r 20 -s 352x288 -vb 400k \
        -acodec aac -strict experimental -ac 1 -ar 8000 -ab 24k \
        movie.3gp
1
  • Would have been nice, if you could explain it. Thanks – igaurav Feb 25 '18 at 11:38
1

You probably just need to install the non free/restricted packages of ffmpeg like libavcodec-extra-53 libavformat-extra-53 libavutil-extra-51 and the likes.

Calling ffmpeg with --list-encoders will show the available encoders.

2
  • I tried installing them but still the commands mentioned in the question did not work. – harisibrahimkv May 7 '12 at 18:13
  • Still the same error messages? – LiveWireBT May 7 '12 at 22:18
1

You are doing everything right :). You will have to install for the conversion to work.

Ubuntu Restricted Extras, i.e. libavcodec-extra-53

You may get it from the software center or use the following command

sudo apt-get install ffmpeg libavcodec-unstripped-52

1
1

I ran into problems with ffmpeg too

Apparently, ubuntu is no longer using ffmpeg, but a fork called avconv. This makes some (many ?) commands found on sites unusable on ubuntu.

What I did was just get the original ffmpeg:

sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

not sure how much this would help you, though

1
  • your line is not working here, but at least it is not giving the "unknown codec" error, but one about resolution – josinalvo Jul 23 '12 at 17:29
0

In order to get round this problem, the only option may be to build from source. That solved any issues for me. I uninstalled any of the ffmpeg packages currently on the system that I had tried to use, and used this excellent Ubuntu compilation guide. This was the only way I could encode to proprietary formats such as mp4 and mp3.

In addition, the following script, which I have modified (credit to the original creator), can again be further altered and used to convert mp4 to 3gp or mp4 to mp3 (to extract the audio), or anything whatsoever. It also preserves the original name of the file in the newly converted file: It is however important to fill in the options correctly.

You can use different options for 3gp; for example,you may want a different resolution than qcif (176x144), but I found these settings initially worked for me with my compiled version of ffmpeg. (The conversion may take a while, depending on how powerful your CPU is, as converting it to 3gp reduces the file size quite a lot: 314mb to 13 mb for one of my conversions!)

Save this script below to a new document and make it executable (chmod +x), place it in the desired folder and execute it; or use the terminal to select the folder the script is in and the target folder containing the files; e.g. ~/Scripts/script ~/Downloads

#!/bin/bash
for f in *.mp4
do
    name="${f/.mp4/.3gp}"
    ffmpeg -i "$f" -vcodec h263 -s qcif -r 15 -b 100k -acodec libfaac -ac 1 -ar 32000 -ab 64k -f 3gp "$name"
done

Not the answer you're looking for? Browse other questions tagged or ask your own question.