Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With ffmpeg I'm converting video from mp3 and picture to upload it to youtube. After upload, conversion fails. Reasons are unknown. I believe the problem is in format. By the way If I'm uploading file 5 minutes length, it fails if I upload 30 seconds of this file it succeeds.

I have donwload mp4 file from youtube. Then I uploaded it, it is done very fast. So a nice solution would be to convert videos to the same format that is done by google.

I got the following output by mpeg:

ffmpeg version N-44264-g070b0e1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep  7 2012 17:38:57 with gcc 4.7.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-l
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenj
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      51. 72.100 / 51. 72.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 25.105 / 54. 25.105
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.100 /  3. 16.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtubetrack0.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2012-10-02 22:58:57
  Duration: 00:06:46.66, start: 0.000000, bitrate: 176 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
v420p, 450x360, 78 kb/s, 6 fps, 6 tbr, 12 tbn, 12 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 95
kb/s
    Metadata:
      creation_time   : 2012-10-02 22:58:57
      handler_name    : IsoMedia File Produced by Google, 5-11-2011

Is it possible to construct ffmpeg parameters so that that would give the same format that google internally does? Is the information above sufficient?

I couldn't construct needed params.

For example I don't understand how to set tbn and what 95 kb/s mean in "Stream #0:1(und): Audio:".

Now I just do: ffmpeg -i videoimage.jpg -i audio.mp3 video.mp4

Info I've got:

ffmpeg version N-44998-gdf82454 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct  2 2012 23:03:12 with gcc 4.7.1 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3
 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib
--enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --en
able-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame
--enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enab
le-libxavs --enable-libxvid --enable-zlib
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 63.100 / 54. 63.100
  libavformat    54. 29.105 / 54. 29.105
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.25.105
  Duration: 00:06:46.81, start: 0.000000, bitrate: 129 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p, 450x360,
 3392 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 127
 kb/s
    Metadata:
      handler_name    : SoundHandler

This video fails the conversion on youtube.

I also tried to use other vcode parmam and extensions of output file (mp4, wmv, avi) but failed too.

Would be greatful for help.

share|improve this question
2  
Please include the full, uncut console output and the command you were using to genereate the video in the first place. Also, please don't truncate your second output either. While you're at it, please install the latest version of FFmpeg – then we can probably help you further. YouTube will always reencode your video… but following this should help: Advanced encoding specifications –  slhck Oct 4 '12 at 6:15
    
Thank you, I've tried to supply the requested infor. –  WHITECOLOR Oct 4 '12 at 6:59

1 Answer 1

up vote 3 down vote accepted

YouTube should be able to use almost anything you feed to it. It will always transcode your video no matter what exact formats you supply – for example because it needs to provide different resolutions or other containers such as FLV or WebM for your video, even if it's in an MP4 container when uploaded.

A basic command to produce video for YouTube would be:

ffmpeg -i input.avi -c:v libx264 -c:a aac -strict experimental -b:a 192k out.mp4

You'll just have to change the quality, and eventually framerate with -r and video size with -s:v to match the advanced encoding specifications, so your video is not pillar- or letterboxed (i.e. with black borders).

For more options and a general introduction to FFmpeg, please read our blog entry: FFmpeg: The ultimate Video and Audio Manipulation Tool


But you're creating a video with one image that loops, so you need to tell FFmpeg to loop the image with -loop 1 for the amount of time specified by -t, e.g. 5 minutes:

ffmpeg -loop 1 -f image2 -i image.jpg -c:v libx264 -t 00:05:00.000 out.mp4

With an audio stream, just add the second -i parameter:

ffmpeg -loop 1 -f image2 -i image.jpg -i audio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -t 00:05:00.000 out.mp4

FFmpeg will then map the streams automatically, your image to h.264 video and your audio to AAC:

Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> libx264)
  Stream #1:0 -> #0:1 (mp3 -> aac)

This video should be compatible with YouTube, with a frame rate of 25. If you want to change that, use -r and set another frame rate. I've successfully uploaded video to YouTube with a frame rate of 1 – because it doesn't really matter if you have just one image and an audio track in the background looping.

share|improve this answer
    
Thank you very much. I dind't use loop because ffmpeg converted to video without it and it played well in player. It was a mistake. What do you think is it worth to work on parameters of conversion to speed up uploads of such videos? I mean to make resulting videos maximum fit for parameters that converted by google and downloaded mp4 has (if I upload such video, conversion process takes less time)? –  WHITECOLOR Oct 4 '12 at 9:30
    
Well, you obviously want to supply the best quality content to YouTube so you won't lose as much when they transcode it again. That in turn won't speed up your upload because the file size is huge. YouTube's requirements aren't that hard to fulfill, using -profile:v high might be another option to consider. Personally I would rather wait it out if YouTube really takes a while to encode. –  slhck Oct 4 '12 at 9:49
    
Thank you. I reduced fps to 1, video size and conversion time (on youtube) become 30% less. If to reduce fps more, however put it much less then 1, it does not give more effect. Can you explain this? –  WHITECOLOR Oct 4 '12 at 11:02
    
Maybe YouTube converts it back to 1 fps? Maybe there's a lower boundary on how long it takes to encode a video depending on a certain frame rate. I'm not sure if there are any constraints but it would make sense from a compatibility standpoint. I know MPEG-2 restricts frame rates to certain values, MPEG-4 Part 10 (h.264) doesn't IIRC. –  slhck Oct 4 '12 at 11:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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