LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-20-2015, 05:22 AM   #1
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 130

Rep: Reputation: 26
High quality desktop capture using FFMPEG


I want to capture my desktop using ffmepg. I'd like to understand it more.
I have 1366x768 desktop and used the following command to capture:
Code:
ffmpeg -video_size 1365x767 -framerate 25 -f x11grab -i :0.0 output.mp4
ffmpeg version: 2.6.3
But didn't produce high quality video.
How can I create better quality with it?

Also it has this output on terminal:

Code:
ffmpeg version 2.6.3 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-2.6.3/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-pthreads --enable-libtheora --enable-libvorbis --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-x11grab --enable-avfilter --enable-gnutls --enable-libcdio --enable-libssh --enable-libcaca --enable-libsmbclient --enable-opengl --arch=x86_64
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1440065657.342327, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1365x767, 25 fps, 25 tbr, 1000k tbn, 25 tbc
File 'output2.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'output2.mp4':
  Metadata:
    encoder         : Lavf56.25.101
    Stream #0:0: Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 1365x767, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.26.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
[swscaler @ 0xb56500] Warning: data is not aligned! This can lead to a speedloss
Past duration 0.605492 too large     812kB time=00:00:03.92 bitrate=1697.8kbits/s dup=91 drop=0    
Past duration 0.678398 too large
Past duration 0.718544 too large
Past duration 0.614342 too large     868kB time=00:00:04.48 bitrate=1587.4kbits/s dup=91 drop=0    
Past duration 0.604546 too large     955kB time=00:00:05.00 bitrate=1564.8kbits/s dup=91 drop=0    
Past duration 0.624870 too large
Past duration 0.601967 too large    1025kB time=00:00:05.48 bitrate=1531.8kbits/s dup=91 drop=0    
Past duration 0.631111 too large    1074kB time=00:00:06.04 bitrate=1456.7kbits/s dup=91 drop=0    
Past duration 0.710487 too large
Past duration 0.631538 too large    1150kB time=00:00:06.56 bitrate=1436.6kbits/s dup=91 drop=0    
Past duration 0.682411 too large
Past duration 0.769875 too large
Past duration 0.609062 too large
frame=  412 fps= 30 q=24.8 Lsize=    2403kB time=00:00:16.48 bitrate=1194.3kbits/s dup=113 drop=0    
video:2400kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.109095
Received signal 2: terminating.

Last edited by Sefid par; 08-20-2015 at 05:27 AM.
 
Old 08-20-2015, 06:47 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
you need to set the vscale option otherwise ffmpeg will use a variable video scale rate
 
Old 08-20-2015, 09:12 AM   #3
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 130

Original Poster
Rep: Reputation: 26
Thank you. But id doesn't have vscale option. I've checked the man page.
Of course I found a solution, using video codec: h264:
Code:
fmpeg -video_size 1365x767 -framerate 25 -f x11grab -i :0.0 -vcodec h264 output14.mkv
In fact I needed to install the x264 first and then recompile ffmpeg using X264 library enabled.

Last edited by Sefid par; 08-22-2015 at 04:42 AM.
 
Old 08-20-2015, 09:37 AM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Sorry my bad missed the h264 qscale is used with mpg's like so
Code:
ffmpeg -video_size 1365x767 -framerate 25 -f x11grab -i :0.0  -q:v 0 output14.mpg
For best results.
Should have read your post properly
 
Old 08-20-2015, 04:23 PM   #5
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 130

Original Poster
Rep: Reputation: 26
It seems it doesn't work on hw:0

Code:
Option q:v (use fixed quality scale (VBR)) cannot be applied to input file hw:0 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file hw:0.
 
Old 08-20-2015, 04:49 PM   #6
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 130

Original Poster
Rep: Reputation: 26
It seems it doesn't work on hw:0

Code:
Option q:v (use fixed quality scale (VBR)) cannot be applied to input file hw:0 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file hw:0.
 
Old 08-20-2015, 05:17 PM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
ffmpeg is very fussy about the order of the options, also the options change quite frequently, fyi i use the git version as it is always the most up to date
 
1 members found this post helpful.
Old 08-20-2015, 05:46 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
My avconv line of sorts (a fork of ffmpeg) uses -f alsa -i default which lets you bypass using hw:0 and lets your default in your .asoundrc handle that part. The only way so far that I've gotten recording to have "selectable" audio sources.

Code:
avconv -f alsa -i default -f  x11grab -s 1920x1080 -r:v 25 -draw_mouse 1 \
       -i :0.0+0,0 -r:v 25 -aspect 16:9 -pix_fmt yuv444p -async 1 \
       -codec:a pcm_s16le -filter_complex asyncts=compensate=1:min_delta=0.1:max_comp=500:first_pts=0" \
       -codec:v libx264 -pre:v lossless_ultrafast -y OUTPUT.mkv
The -async 1 and -filter_complex parts are to maintain video+audio sync. The -pix_fmt yuv444p is to maintain colors as yellows tend to not be yellow without it. Although my system is not that spec-tastic so my actual capture frame rate is closer to 5 for it to have a steady framerate and enough resources to have something worth recording.
 
  


Reply

Tags
ffmpeg, screencast



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FFMpeg - help with fade filter losing quality eskimoroll Linux - Newbie 4 06-16-2023 06:36 AM
Lower video quality with ffmpeg? anon109 Linux - General 4 03-01-2013 02:20 AM
[SOLVED] High quality batch ffmpeg video encoding propofol Linux - Software 6 11-22-2012 01:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration