1
I am trying to add an overlay to a FLV file fetched from YouTube. The input file is 4.4MB and playable by QuickTime so it doesn't appear to have any issues.
ffmpeg -i input.flv -vf drawtext="fontfile='arial.ttf':text='hello':fontsize=9" output.flv
I receive the following output after a surprisingly short few seconds:
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on May 15 2013 13:13:12 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.flv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2010-01-31 13:44:29
Duration: 00:02:20.85, start: 0.000000, bitrate: 249 kb/s
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 56 kb/s
Metadata:
creation_time : 2010-01-31 13:44:29
handler_name : (C) 2007 Google Inc. v08.13.2007.
Stream #0:1(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 191 kb/s, 29.84 fps, 29.97 tbr, 30k tbn, 29.97 tbc
Metadata:
creation_time : 2010-01-31 13:44:29
handler_name : (C) 2007 Google Inc. v08.13.2007.
File 'output.flv' already exists. Overwrite ? [y/N] y
Output #0, flv, to 'output.flv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf54.63.104
Stream #0:0(und): Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
Metadata:
creation_time : 2010-01-31 13:44:29
handler_name : (C) 2007 Google Inc. v08.13.2007.
Stream #0:1(und): Audio: mp3 ([2][0][0][0] / 0x0002), 22050 Hz, mono, fltp
Metadata:
creation_time : 2010-01-31 13:44:29
handler_name : (C) 2007 Google Inc. v08.13.2007.
Stream mapping:
Stream #0:1 -> #0:0 (mpeg4 -> flv)
Stream #0:0 -> #0:1 (aac -> libmp3lame)
Press [q] to stop, [?] for help
frame= 4201 fps=1386 q=10.0 Lsize= 4304kB time=00:02:20.85 bitrate= 250.3kbits/s
video:3603kB audio:550kB subtitle:0 global headers:0kB muxing overhead 3.618454%
Now output.flv is left unplayable by QuickTime, and Flash complains that the audio codec is not supported. The only program capable of playing it successfully is VLC. Its filesize is the same as input.flv. What could be the cause of this, and what options could produce a playable copy?
UPDATE
Truncated output received from using various encoders:
ffmpeg -i input.flv -c:v libxvid -c:a copy -q:v 5 output2.flv
...
Stream mapping:
Stream #0:1 -> #0:0 (mpeg4 -> libxvid)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 4201 fps=303 q=5.0 Lsize= 6597kB time=00:02:20.85 bitrate= 383.7kbits/s
video:5491kB audio:968kB subtitle:0 global headers:0kB muxing overhead 2.120003%
ffmpeg -i input.flv -c:v mpeg4 -c:a copy -q:v 5 output3.flv
...
Stream mapping:
Stream #0:1 -> #0:0 (mpeg4 -> mpeg4)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 4201 fps=2523 q=5.0 Lsize= 6852kB time=00:02:20.85 bitrate= 398.5kbits/s
video:5746kB audio:968kB subtitle:0 global headers:0kB muxing overhead 2.044082%
ffmpeg -i input.flv -c copy outputcopy.flv
...
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 4201 fps=0.0 q=-1.0 Lsize= 4394kB time=00:02:20.85 bitrate= 255.6kbits/s
video:3289kB audio:968kB subtitle:0 global headers:0kB muxing overhead 3.216934%
Getting the info on any of these files gives me a lot of the following types of errors (where n is an increasing integer):
- Stream discovered after head already parsed
- header damaged
- max_analyze_duration 5000000 reached at 5014000 microseconds
- Could not find codec parameters for stream n (Video: mpeg4, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
- decoding for stream n failed
This is followed by messages of type:
Stream #0:n: Video: mpeg4, yuv420p, 1k tbr, 1k tbn
I just upgraded ffmpeg and its dependencies through MacPorts and am still out of luck. This is happening for every FLV file I've tried from YouTube and elsewhere.
-c:v mpeg4
gives me similar results.-c:v libxvid
takes a more realistic amount of time to process but still does not produce a playable output. Even a straight copy commandffmpeg -i input.flv -c:v copy -c:a copy output.flv
without filters does not work unfortunately. – danronmoon – 2013-07-08T15:30:12.097Please don't truncate your output of the other commands. If it's too long for the question body, paste it to a pasteboard – this will make it easier to identify problems. Do you have a sample maybe? Does the file play, say in VLC?
– slhck – 2013-07-08T16:59:05.177The truncated output for the last 3 was the same as the first complete output at the top (bunch of metadata for the original file). OK I must admit my original command (as well as output3.flv, thanks for this) does work with VLC but not with anything else (Flash says audio codec is not supported). This is good news but I think it is reasonable to expect playback in other video players, so I'm rewording the question. – danronmoon – 2013-07-08T17:45:14.787
Seems a bit tricky. With QuickTime you'll have to use the officially supported FLV video codecs, at least according to my tests. Haven't been able to find an MPEG-4 Part 2 video stream in an FLV container from YouTube yet, though – seems I only either get H.264 or Sorenson H.263-encoded ones. – slhck – 2013-07-08T18:45:38.990
-c:a aac
causes ffmpeg to hang, forcing me to close and open a new terminal.-c:a mp3
still produces a file unplayable with QT. The youtube id this question is based on is rNp-cj5dEA8. If you could give me a YT id and the associated command that works for you (original and copy both playable by QT), I could try it out and see if it works on my machine. BTW what type of ffmpeg build do you have? Starting to think I might have to downgrade or reinstall. – danronmoon – 2013-07-08T21:01:08.530For the video ID you gave me I only get two possible FLV options (based on what
– slhck – 2013-07-09T18:31:38.170youtube-dl
shows), one with H.264 video inside, and one with Sorenson H.263. Both are playable in QuickTime. I don't get an MPEG-4 version – are you maybe using some other YouTube downloading service that does a transcode? I just tried the "regular"ffmpeg -i input.flv output.flv
and it's playable in QuickTime. Both on latestffmpeg
compiled from Git as well as 1.2.1.I've been using MacTubes to test #5. I just installed youtube-dl and downloaded #5 and I noticed that the filesize and resolution were different from the one I downloaded from MacTubes, and that the video encoder is flv1, the same as what you had. Even more mind-boggling is the fact that I can't get the file downloaded from youtube-dl to play in QT. So I think the issue is getting too localized, and with all the discrepancies I've been encountering I think the sane route is to sing VLC's praises and focus on other tasks. Thanks for your help. – danronmoon – 2013-07-09T19:14:25.530
Sure. Ping me in chat or here if you need to cross-check something though. I'm sorry I couldn't help you any more, but there seem to be many factors in play here. – slhck – 2013-07-09T19:20:46.373