EzDevInfo.com

libav interview questions

Top libav frequently asked interview questions

How to install libav/avconv on OSX?

OSX comes with a command line video conversion utility avconvert but this tool provides limited functionality compared to the avconv provided by libav.

How can I install avconv on OS X?


Source: (StackOverflow)

Burn-in subtitles with avconv?

I have a mkv file and want to convert it to an DVD compatible mpg file with avconv. How can I also burn-in one subtitle stream from the same mkv file?

avconv -i input.mkv -map 0:0 -map 0:1 -target pal-dvd -aspect 16:9 -q:v 1 -acodec mp2 -ac 2 -ab 128k output.mpg


Source: (StackOverflow)

Advertisements

Why would I choose Libav over FFmpeg, or is there even a difference?

From what I've seen it looks to me like Libav's avconv is thought to become a successor of ffmpeg — is that correct?

If that's true, why is that so? What exactly is libav doing better and why would I want to choose it over ffmpeg?

I came to this "issue" while installing Ubuntu 12.04.1 LTS in a VM and when I've installed ffmpeg it came up with a message telling mit ffmpeg is deprecated and I first thought "wtf?".

If I use avconvWill I be able to migrate my scripts depending on ffmpeg more or less easy to libav? I'm mostly using it for writing meta data and doing audio conversion (wav, flac, vorbis, mp3, aac).


Source: (StackOverflow)

Resizing videos with ffmpeg/avconv to fit into static sized player

I have a html 5 video player which is 700px wide, 400px high. I'm trying to use avconv to use ffmpeg to resize (while retaining the aspect ratio) and making sure it fits into my player.

Input can be a file of any size, so I need to resize the larger ones but center the smaller ones with black bars. So far I've tried: -s and -aspect, I've seen pad being used with the -vf switch but don't understand how it works enough to get what I need.

Images

This is a rough idea of what I need. I'm not sure if it's even possible. It's almost like CSS's max-width/max-height. I realise this may just be a jumble of words but if anyone happens to understand what I'm talking about, I'd appreciate help, Thanks.

avconv command:

avconv -y -i control.avi -vcodec libx264 -b 2000k -bufsize 20M -acodec aac -strict experimental -ar 44100 -ab 256k bigbuck_out.mp4


Source: (StackOverflow)

Split MKV based on Chapters

I have a long MKV file which I want to split into its individual chapters.

Running ffmpeg -i long.mkv gives me all the information about the chapters embedded in the file:

 Duration: 01:23:45.80, start: 0.000000, bitrate: 8116 kb/s
    Chapter #0.0: start 0.000000, end 235.000000
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 235.000000, end 450.160000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 450.160000, end 789.400000
    ...

There are 10 chapters in the file - I want to end up with 10 separate files.

It looks like -map_chapters might to something similar - but I can't find any documentation on it.


Source: (StackOverflow)

avconv can't convert stream to MP4 file, fails with "Unable to set encoding parameters"

I'm trying to script some testing of Wowza Media Server. Basically, I'm attempting to just beat the living bejeepers out of the thing. I have 5 slightly older computers, originally XP boxes, which I have installed Mint 15 on. I have a script that basically calls the file (or a symbolic link to the file) and takes it into avconv, then dumps it into null.

The idea here is that with 5 of these computers all starting a new thread every second, up to the max they can handle without freezing, we'll get a decent idea of what our current implementation can handle. The script I have works great, but only on some machines. The systems are all the same hardware, and I installed the same software on them in the beginning, although some of them may have had additional packages installed for various tasks since then. The command I issue in script is:

avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[h264 @ 0xd87ae0] mmco: unref short failure
[applehttp @ 0xd80d40] max_analyze_duration reached
[applehttp @ 0xd80d40] Estimating duration from bitrate, this may be inaccurate
Input #0, applehttp, from     'http://OUR_DOMAIN.com:1935/vod/_definst_/encode/video_file/00/00/00/12/13/mp4:TestFile.mp4/playlist.m3u8':
  Duration: 02:05:54.00, start: 27.728000, bitrate: N/A
    Stream #0.0: Data: [21][0][0][0] / 0x0015
    Metadata:
      variant_bitrate : 1610015
    Stream #0.1: Video: h264 (Main), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 23.98 tbr, 90k tbn, 47.95 tbc
    Metadata:
      variant_bitrate : 1610015
    Stream #0.2: Audio: aac, 48000 Hz, 5.1, s16
    Metadata:
      variant_bitrate : 1610015
[buffer @ 0x13e02c0] w:1280 h:720 pixfmt:yuv420p
[libvo_aacenc @ 0x12c49c0] Unable to set encoding parameters
Output #0, mp4, to '/dev/null':
    Stream #0.0: Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc
    Metadata:
      variant_bitrate : 1610015
    Stream #0.1: Audio: libvo_aacenc, 48000 Hz, 5.1, s16, 200 kb/s
    Metadata:
      variant_bitrate : 1610015
Stream mapping:
  Stream #0:1 -> #0:0 (h264 -> mpeg4)
  Stream #0:2 -> #0:1 (aac -> libvo_aacenc)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Any clues would be greatly appreciated. Thanks!


Source: (StackOverflow)

Resizing with avconv causes pixellation in output

I am trying to resize a video from 1920x1800 to 1280x720 for phone viewing.

This is the command I used:

avconv -i input.mkv \
-map 0:v -map 0:a:1 -map 0:s:0 \ # map video, 2nd audio stream, and subtitles
-s 1280x720 \                    # resize
-c:a copy -c:s copy \            # copy audio and subtitles
output.mkv`

The output is indeed the correct resolution, but it suffers from artifacts.

Input:

input

Output:

output

Output detail:

enter image description here


Source: (StackOverflow)

avconv giving error on audio stream

Trying to convert an mkv file to avi:

 avconv -i 1.mkv ./converted/1.avi

Getting this output:

avconv version 0.8.1-4:0.8.1-0ubuntu1, Copyright (c) 2000-2011 the Libav developers
  built on Mar 22 2012 05:29:10 with gcc 4.6.3
[matroska,webm @ 0x8ba3aa0] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from '1.mkv':
  Metadata:
    TITLE           : 
    ARTIST          : 
    COMPOSER        : 
    SYNOPSIS        : 
    DATE_RELEASED   : 
    GENRE           : 
  Duration: 00:07:48.54, start: 0.000000, bitrate: N/A
    Stream #0.0(eng): Video: h264 (Main), yuv420p, 1910x800 [PAR 1:1 DAR 191:80], 24 fps, 24 tbr, 1k tbn, 180k tbc (default)
    Stream #0.1: Audio: aac, 44100 Hz, stereo, s16 (default)
[buffer @ 0x8dcd160] w:1910 h:800 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0x8f24540] invalid bit rate
Output #0, avi, to './converted/1.avi':
  Metadata:
    TITLE           : 
    ARTIST          : 
    COMPOSER        : 
    SYNOPSIS        : 
    DATE_RELEASED   : 
    GENRE           : 
    Stream #0.0(eng): Video: mpeg4, yuv420p, 1910x800 [PAR 1:1 DAR 191:80], q=2-31, 200 kb/s, 90k tbn, 24 tbc (default)
    Stream #0.1: Audio: ac3, 44100 Hz, stereo, flt, 200 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
  Stream #0:1 -> #0:1 (aac -> ac3)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Google has turned up nothing.


Source: (StackOverflow)

How to correctly use x265 lossless parameter with avconv

x265 has a lossless mode which is used for ultra-high bitrates with zero loss of quality. I tried using this mode with avconv as follows:

avconv -i input.mp4 -c:v libx265 -x265-params lossless -c:a copy output.mp4

However, using this mode has an opposite effect : video came out to be of extremely low quality. It was totally lossy!!

Am I using the parameter incorrectly? Or am I somehow misunderstanding the definition of the word "lossless"?

Important Links:


Source: (StackOverflow)

How do I merge a folder of PNG images to a mp4 movie using avconv?

I have a folder containing many time stamped PNG images which I'd like to merge to a short movie. The contents of that directory looks like this:

└── images
    ├── img_20130421_115547.png
    ├── img_20130421_115617.png
    ├── img_20130421_115926.png
    ├── img_20130421_120034.png
    ├── img_20130421_120129.png
    ├── img_20130421_120245.png
    ├── img_20130421_120354.png
    ├── ...

I tried running the following commands inside the images directory, to no avail:

$ ffmpeg -y -f image2 -pattern_type glob -i 'img*.png' -r 24 out.mp4
ffmpeg version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Unrecognized option 'pattern_type'
Failed to set value 'glob' for option 'pattern_type'

$ avconv -y -f image2 -r 24 -i 'img_%08d_%06d.png' out.mp4
avconv version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
img_%08d_%06d.png: No such file or directory

$ avconv -y -f image2 -r 24 -i 'img_%*.png' out.mp4     
avconv version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
img_%*.png: No such file or directory

$ avconv -y -f image2 -r 24 -i 'img_%.png' out.mp4 
avconv version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
img_%.png: No such file or directory

I'm using Ubuntu 12.10. How do I get this to work? thanks.


Source: (StackOverflow)

Why does avconv change the fps when deinterlacing?

I have a .MTS 1080i of 25fps (mediainfo) that I deinterlaced with avconv -i input.MTS -vf yadif -c:a copy output.mp4. As the wiki says, the default value for yadif is 0 which "outputs one frame for each frame".

My question is, why does output.mp4 have 50fps? Also, is it normal that it is much smaller than the input?

As requested:

wantoast@crunchbang:~/videos/video/videocamera$ avconv -i 00000.MTS
avconv version 0.8.16-6:0.8.16-1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 16 2014 23:10:48 with gcc 4.7.2
Input #0, mpegts, from '00000.MTS':
  Duration: 00:00:37.44, start: 1.000033, bitrate: 16506 kb/s
  Program 1 
    Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
    Stream #0.2[0x1200]: Subtitle: pgssub
At least one output file must be specified
wantoast@crunchbang:~/videos/video/videocamera$ avconv -i 00000.MTS -vf yadif -c:a copy output.mp4
avconv version 0.8.16-6:0.8.16-1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 16 2014 23:10:48 with gcc 4.7.2
Input #0, mpegts, from '00000.MTS':
  Duration: 00:00:37.44, start: 1.000033, bitrate: 16506 kb/s
  Program 1 
    Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
    Stream #0.2[0x1200]: Subtitle: pgssub
[buffer @ 0xa5eb40] w:1920 h:1080 pixfmt:yuv420p
[yadif @ 0xa5cba0] mode:0 parity:-1 auto_enable:0
[libx264 @ 0xa59b00] using SAR=1/1
[libx264 @ 0xa59b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0xa59b00] profile Main, level 4.2
[libx264 @ 0xa59b00] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=1 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: libx264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=-1--1, 50 tbn, 50 tbc
    Stream #0.1: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (copy)
Press ctrl-c to stop encoding
frame= 1870 fps= 16 q=-1.0 Lsize=   29093kB time=37.38 bitrate=6375.8kbits/s dup=935 drop=0    
video:27902kB audio:1170kB global headers:0kB muxing overhead 0.070776%
[libx264 @ 0xa59b00] frame I:122   Avg QP:22.47  size: 49023
[libx264 @ 0xa59b00] frame P:1748  Avg QP:25.43  size: 12923
[libx264 @ 0xa59b00] mb I  I16..4: 61.9%  0.0% 38.1%
[libx264 @ 0xa59b00] mb P  I16..4:  2.8%  0.0%  0.5%  P16..4: 36.5%  2.8%  1.7%  0.0%  0.0%    skip:55.7%
[libx264 @ 0xa59b00] coded y,uvDC,uvAC intra: 38.5% 80.0% 19.8% inter: 7.1% 27.2% 0.2%
[libx264 @ 0xa59b00] i16 v,h,dc,p: 35% 18% 15% 31%
[libx264 @ 0xa59b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 35%  4%  3%  3%  4%  3%  2%
[libx264 @ 0xa59b00] i8c dc,h,v,p: 50% 18% 26%  6%
[libx264 @ 0xa59b00] Weighted P-Frames: Y:1.1% UV:0.7%
[libx264 @ 0xa59b00] ref P L0: 63.3%  9.7% 13.0% 13.9%  0.1%
[libx264 @ 0xa59b00] kb/s:6111.45
wantoast@crunchbang:~/videos/video/videocamera$ avconv -i output.mp4 
avconv version 0.8.16-6:0.8.16-1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 16 2014 23:10:48 with gcc 4.7.2
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x216e460] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf53.21.1
  Duration: 00:00:37.47, start: 0.000000, bitrate: 6358 kb/s
    Stream #0.0(und): Video: h264 (Main), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 6111 kb/s, 50 fps, 50 tbr, 50 tbn, 100 tbc
    Stream #0.1(und): Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
At least one output file must be specified

Source: (StackOverflow)

Avconv increases file size

I am using the version of avconv in Ubuntu 12.04 to archive videos. I would preferably use some kind of lossless video compression (e.g., huffyuv or FFV1), but using the original video stream (copy codec) would also be acceptable. Unfortunately, with any of these options the output file (mkv containing only the video in whatever format) is much larger than the input file (vob containing video, audio, and subtitles). I could understand if the lossless compression just did a horrible job on my particular video, but I see no reason why using the copy codec would increase file size.

Google turns up one person having this same problem here, but the only response is a useless insult caused by the libav/ffmpeg split.

Is there a reason this should happen, or is this a bug? Is there a workaround or a fix in ffmpeg, a later version of avconv, or a different piece of software?

Update: It seems like it may be related to this question at least partially, but that does not explain why it happens when I use a codec of "copy". I still have not tried this with ffmpeg; I plan to do that tonight.

Update 2: Here's the actual command and output, which I said several days ago should be available in a few hours. From this, it seems that the problem is partially but not entirely due to muxing, as generating a raw .m2v file works without issue (and mkvmerge works on that file without issue). Using the flags that the Libav FAQ recommends does not help.

Thu 2 Aug 2012 13:58:51 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
1 $ ls
total 1774448
drwxrwxr-x 2 daniel daniel       4096 Jul 28 20:24 keep/
-rw-rw-r-- 1 daniel daniel          0 Aug  2 13:58 timings
-rw-rw-r-- 1 daniel daniel 1816995840 Aug  2 12:34 Title.vob
-rw-rw-r-- 1 daniel daniel          0 Aug  2 13:58 typescript
Exit Code: 0

Thu 2 Aug 2012 13:58:52 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
2 $ avprobe -v verbose Title.vob 
avprobe version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2007-2012 the Libav developers
  built on Jun 12 2012 16:52:09 with gcc 4.6.3
  configuration: --extra-version='4:0.8.3-0ubuntu0.12.04.1' --arch=amd64 --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-libfreetype --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil    51. 22. 1 / 51. 22. 1
  libavcodec   53. 35. 0 / 53. 35. 0
  libavformat  53. 21. 0 / 53. 21. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  52.  0. 0 / 52.  0. 0
[mpeg @ 0xd4a7a0] max_analyze_duration reached
Input #0, mpeg, from 'Title.vob':
  Duration: 00:43:35.39, start: 0.195633, bitrate: 5557 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x20]: Subtitle: dvdsub
    Stream #0.2[0x21]: Subtitle: dvdsub
    Stream #0.3[0x22]: Subtitle: dvdsub
    Stream #0.4[0x23]: Subtitle: dvdsub
    Stream #0.5[0x24]: Subtitle: dvdsub
    Stream #0.6[0x25]: Subtitle: dvdsub
    Stream #0.7[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.8[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.9[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s (comment)
    Stream #0.10[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
Exit Code: 0

Thu 2 Aug 2012 13:58:58 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
3 $ avconv -v verbose -i Title.vob -c:v copy -map 0:v:0 Title.m2v
avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Jun 12 2012 16:52:09 with gcc 4.6.3
  configuration: --extra-version='4:0.8.3-0ubuntu0.12.04.1' --arch=amd64 --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-libfreetype --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil    51. 22. 1 / 51. 22. 1
  libavcodec   53. 35. 0 / 53. 35. 0
  libavformat  53. 21. 0 / 53. 21. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  52.  0. 0 / 52.  0. 0
[mpeg @ 0x1ab77a0] max_analyze_duration reached
Input #0, mpeg, from 'Title.vob':
  Duration: 00:43:35.39, start: 0.195633, bitrate: 5557 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x20]: Subtitle: dvdsub
    Stream #0.2[0x21]: Subtitle: dvdsub
    Stream #0.3[0x22]: Subtitle: dvdsub
    Stream #0.4[0x23]: Subtitle: dvdsub
    Stream #0.5[0x24]: Subtitle: dvdsub
    Stream #0.6[0x25]: Subtitle: dvdsub
    Stream #0.7[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.8[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.9[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s (comment)
    Stream #0.10[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, mpeg2video, to 'Title.m2v':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 720x480 [PAR 32:27 DAR 16:9], q=2-31, 9800 kb/s, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press ctrl-c to stop encoding
frame=62709 fps=4237 q=-1.0 Lsize= 1402285kB time=2615.30 bitrate=4392.4kbits/s    
video:1402285kB audio:0kB global headers:0kB muxing overhead 0.000000%
Exit Code: 0

Thu 2 Aug 2012 13:59:45 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
4 $ avconv -v verbose -i Title.vob -c:v copy -map 0:v:0 Title.avi
avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Jun 12 2012 16:52:09 with gcc 4.6.3
  configuration: --extra-version='4:0.8.3-0ubuntu0.12.04.1' --arch=amd64 --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-libfreetype --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil    51. 22. 1 / 51. 22. 1
  libavcodec   53. 35. 0 / 53. 35. 0
  libavformat  53. 21. 0 / 53. 21. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  52.  0. 0 / 52.  0. 0
[mpeg @ 0xdec7a0] max_analyze_duration reached
Input #0, mpeg, from 'Title.vob':
  Duration: 00:43:35.39, start: 0.195633, bitrate: 5557 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x20]: Subtitle: dvdsub
    Stream #0.2[0x21]: Subtitle: dvdsub
    Stream #0.3[0x22]: Subtitle: dvdsub
    Stream #0.4[0x23]: Subtitle: dvdsub
    Stream #0.5[0x24]: Subtitle: dvdsub
    Stream #0.6[0x25]: Subtitle: dvdsub
    Stream #0.7[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.8[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.9[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s (comment)
    Stream #0.10[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, avi, to 'Title.avi':
  Metadata:
    ISFT            : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 720x480 [PAR 32:27 DAR 16:9], q=2-31, 9800 kb/s, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press ctrl-c to stop encoding
frame=62709 fps=186 q=-1.0 Lsize= 6271354kB time=2615.30 bitrate=19644.0kbits/s    
video:1402285kB audio:0kB global headers:0kB muxing overhead 347.223994%
Exit Code: 0

Thu 2 Aug 2012 14:05:24 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
5 $ avconv -v verbose -i Title.vob -c:v copy -map 0:v:0 Title.mkv
avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Jun 12 2012 16:52:09 with gcc 4.6.3
  configuration: --extra-version='4:0.8.3-0ubuntu0.12.04.1' --arch=amd64 --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-libfreetype --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil    51. 22. 1 / 51. 22. 1
  libavcodec   53. 35. 0 / 53. 35. 0
  libavformat  53. 21. 0 / 53. 21. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  52.  0. 0 / 52.  0. 0
[mpeg @ 0xc0d7a0] max_analyze_duration reached
Input #0, mpeg, from 'Title.vob':
  Duration: 00:43:35.39, start: 0.195633, bitrate: 5557 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x20]: Subtitle: dvdsub
    Stream #0.2[0x21]: Subtitle: dvdsub
    Stream #0.3[0x22]: Subtitle: dvdsub
    Stream #0.4[0x23]: Subtitle: dvdsub
    Stream #0.5[0x24]: Subtitle: dvdsub
    Stream #0.6[0x25]: Subtitle: dvdsub
    Stream #0.7[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.8[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.9[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s (comment)
    Stream #0.10[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, matroska, to 'Title.mkv':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 720x480 [PAR 32:27 DAR 16:9], q=2-31, 9800 kb/s, 1k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press ctrl-c to stop encoding
[matroska @ 0xc30900] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument
Exit Code: 1

Thu 2 Aug 2012 14:05:31 MDT pts/3 (100x27) [daniel@daniel-laptop-ubuntu:~/Videos]
6 $ ls
total 9448208
drwxrwxr-x 2 daniel daniel       4096 Jul 28 20:24 keep/
-rw-rw-r-- 1 daniel daniel      16384 Aug  2 14:05 timings
-rw-rw-r-- 1 daniel daniel 6421866918 Aug  2 14:05 Title.avi
-rw-rw-r-- 1 daniel daniel 1435939709 Aug  2 13:59 Title.m2v
-rw-rw-r-- 1 daniel daniel        680 Aug  2 14:05 Title.mkv
-rw-rw-r-- 1 daniel daniel 1816995840 Aug  2 12:34 Title.vob
-rw-rw-r-- 1 daniel daniel      69632 Aug  2 14:05 typescript
Exit Code: 0

Because at least part of the problem seems to be caused by using containers, is there any way to tell avconv to generate raw huffyuv or raw FFv1 files without a container, like specifying a file extension of .m2v does for an MPEG-2 elementary stream?


Source: (StackOverflow)

Hardcoding FFMPEG subtitles on MP4 / MKV

I am using FFMPEG to hard code subs into a video. Having read many posts on the best approach, and whether to use mkv or mp4, but am still none the wiser. The code below uses an mp4 file. The subtitles appear to be processed, judging by the output, but the size 0kb seems to show that nothing is actually rendered, and the output file has audio and video, but no subtitles.

Metadata in VLC shows that a subtitle file is present - but empty.

Here is an example of my SRT file (not putting an empty line in 1 gives an input error msg):

1
00:00:00,000 --> 00:00:00,001

2
00:00:00,001 –-> 00:00:04,761
He drives to school every morning

3
00:00:04,761 –-> 00:00:13,061
Cause love comes slow and it goes so fast

My command line code is:

`ffmpeg -i #{inputfile} -i #{srt_file}  -filter_complex "[0:v][1:s]overlay" #{outputfile} -y`

I have also tried:

`ffmpeg -i #{inputfile} -i #{srt_file}  -c:v libx264 -preset ultrafast \
-c:s mov_text -map 0 -map 1 #{outputfile}`

And the response:

ffmpeg version 2.5.4 Copyright (c) 2000-2015 the FFmpeg developers
built on Feb 25 2015 15:52:19 with Apple LLVM version 6.0 (clang-600.0.54) 
(based on LLVM3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.4 --enable-shared --enable-pthreads
--enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --
host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc 
--enable-libxvid --enable-libass --enable-vda
libavutil      54. 15.100 / 54. 15.100
libavcodec     56. 13.100 / 56. 13.100
libavformat    56. 15.102 / 56. 15.102
libavdevice    56.  3.100 / 56.  3.100
libavfilter     5.  2.103 /  5.  2.103
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 
'/Users/JW/Dropbox/T10/SBRI/_code/videos_final/3rd person present tense (303).mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf56.15.102
Duration: 00:00:43.17, start: 0.036281, bitrate: 862 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 406:405 DAR 
16:9], 732 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
  handler_name    : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s    
(default)
Metadata:
  handler_name    : SoundHandler
Input #1, srt, from '/Users/JW/Dropbox/T10/SBRI/_code/subs/3rd person present tense (303)/srt_file.srt':
Duration: N/A, bitrate: N/A
Stream #1:0: Subtitle: subrip
[srt @ 0x7fd082005c00] sub2video: using 720x576 canvas
[libx264 @ 0x7fd082801200] using SAR=406/405
[libx264 @ 0x7fd082801200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fd082801200] profile High, level 3.0
[libx264 @ 0x7fd082801200] 264 - core 142 r2495 6a301b6 - H.264/MPEG-4 AVC codec - Copyleft     
2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 
analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 
trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 
constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 
weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf 
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

Output #0, mp4, to '/Users/JW/Dropbox/T10/SBRI/_code/videos_final/3rd person present tense 
(303)_subs.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf56.15.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x406 [SAR 406:405 
DAR 16:9], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc (default)
Metadata:
  encoder         : Lavc56.13.100 libx264
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 
s16, 128 kb/s (default)
Metadata:
  handler_name    : SoundHandler
  encoder         : Lavc56.13.100 libvo_aacenc

Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #1:0 (srt) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))

Press [q] to stop, [?] for help
sub2video: non-bitmap subtitle
frame= 1029 fps= 71 q=-1.0 Lsize=    4319kB time=00:00:43.17 bitrate= 819.6kbits/s
video:3612kB audio:675kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:     
0.751962%
[libx264 @ 0x7fd082801200] frame I:44    Avg QP:17.59  size: 16172
[libx264 @ 0x7fd082801200] frame P:495   Avg QP:22.62  size:  5016
[libx264 @ 0x7fd082801200] frame B:490   Avg QP:23.28  size:  1027
[libx264 @ 0x7fd082801200] consecutive B-frames: 24.2% 34.4%  7.6% 33.8%
[libx264 @ 0x7fd082801200] mb I  I16..4: 27.2% 43.8% 28.9%
[libx264 @ 0x7fd082801200] mb P  I16..4:  5.9% 14.8%  2.9%  P16..4: 31.1% 10.7%  4.3%  0.0%  
0.0%    skip:30.3%
[libx264 @ 0x7fd082801200] mb B  I16..4:  0.2%  0.5%  0.2%  B16..8: 26.2%  3.3%  0.6%   
direct: 1.1%  skip:67.8%  L0:40.7% L1:52.4% BI: 6.9%
[libx264 @ 0x7fd082801200] 8x8 transform intra:57.6% inter:72.8%
[libx264 @ 0x7fd082801200] coded y,uvDC,uvAC intra: 41.3% 60.2% 22.0% inter: 9.1% 14.5% 0.6%
[libx264 @ 0x7fd082801200] i16 v,h,dc,p: 41% 25% 11% 22%
[libx264 @ 0x7fd082801200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 20% 23%  4%  5%  6%  5%  5%  4%
[libx264 @ 0x7fd082801200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 20% 12%  5%  8%  9%  7%  6%  4%
[libx264 @ 0x7fd082801200] i8c dc,h,v,p: 53% 20% 21%  6%
[libx264 @ 0x7fd082801200] Weighted P-Frames: Y:14.1% UV:9.9%
[libx264 @ 0x7fd082801200] ref P L0: 68.6% 14.5% 12.3%  4.2%  0.4%
[libx264 @ 0x7fd082801200] ref B L0: 91.7%  7.5%  0.8%
[libx264 @ 0x7fd082801200] ref B L1: 98.4%  1.6%
[libx264 @ 0x7fd082801200] kb/s:689.28

What am I doing wrong?


Source: (StackOverflow)

Accurate and reliable movie editing with avconv

I'm trying to perform movie editing in an automated way with avconv. It is made in two steps:

  1. extract some parts of an input movie:
  2. concatenate the parts to form an output movie:

I tried some combinations of containers and codecs for the intermediate and output movies, but it always resulted in one of the following situations:

  1. the audio becomes more and more delayed during playback of the output movie. It seems that each transition of the concatenated parts adds to the delay of the audio. This happens, e.g., with the following formats and codecs:

    avconv -i input-movie.avi -ss $TIME_1 -vframes $NUMFRAMES_1 -f avi -q 1 -aq 1 -y movie-part1.avi
    avconv -i input-movie.avi -ss $TIME_2 -vframes $NUMFRAMES_2 -f avi -q 1 -aq 1 -y movie-part2.avi
    ...
    avconv -i input-movie.avi -ss $TIME_N -vframes $NUMFRAMES_N -f avi -q 1 -aq 1 -y movie-partN.avi
    
    avconv -i concat:movie-part1.avi|movie-part2.avi|...|movie-partN.avi -f avi -codec mpeg4 -q 1 -acodec libmp3lame -aq 1 -y output-movie.avi
    
  2. audio and video in the output movie are in sync, but it is longer than it should be. In this situation the output of avprobe -show_streams output-movie shows duration and video nb_frames longer than expected, although running avconv -i output-video -f image2 %06d.jpg produces the expected number of jpg frame files (the expected number of frames is $NUMFRAMES_1 + $NUMFRAMES_2 + ... + $NUMFRAMES_N). This happens, e.g., with the following formats and codecs:

    avconv -i input-movie.avi -ss $TIME_1 -vframes $NUMFRAMES_1 -f mpeg -q 1 -aq 1 -y movie-part1.mpeg
    avconv -i input-movie.avi -ss $TIME_2 -vframes $NUMFRAMES_2 -f mpeg -q 1 -aq 1 -y movie-part2.mpeg
    ...
    avconv -i input-movie.avi -ss $TIME_N -vframes $NUMFRAMES_N -f mpeg -q 1 -aq 1 -y movie-partN.mpeg
    
    avconv -i concat:movie-part1.mpeg|movie-part2.mpeg|...|movie-partN.mpeg -f avi -codec mpeg4 -q 1 -acodec libmp3lame -aq 1 -y output-movie.avi
    

Is there a reliable/accurate way to perform these operations and get a resulting movie with audio and video in sync and with the expected number of frames?


Source: (StackOverflow)

How do I extract the timestamps associated with frames ffmpeg extracts from a video with the -r option?

ffmpeg -i myvid.mp4  -r  25  -t  100  image-%d.jpeg 

Is the command I'm using to extract frames and it's working just like I expected. However I'd also like to look at the timestamps of the frames. At whatever precision. 100 miliseconds is good enough for me. Can ffmpeg do this?

Providing additional details,

When I run the above command i get around 100 JPEGs, I guess there is a 1 to 1 (or many to 1) correspondence between these JPEGS and frames of the video. I would like to know the timestamp of the frame that was output as a JPEG image 'i'.

Additionally I tried ffprobe but I find it reports even the video duration inaccurately :(


Source: (StackOverflow)