LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FFMpeg - help with fade filter losing quality (https://www.linuxquestions.org/questions/linux-newbie-8/ffmpeg-help-with-fade-filter-losing-quality-4175514758/)

eskimoroll 08-13-2014 09:59 PM

FFMpeg - help with fade filter losing quality
 
Hello,

I am losing a tons of quality applying the fade filter to a segment using FFMpeg. My videos are unplayable once Youtube gets through with them.

The command I am using:
Quote:

ffmpeg -y -i temp1.ts -filter:v "fade=t=in:st=0:d=0.5,fade=t=out:st=60:d=0.5" -preset medium -c:v libx264 "temp1c.ts"
temp1.ts= 158mb
temp1c.ts= 9mb

I tried playing with the -qp param, but the video's color becomes too vivid, almost incoherent.

This is the file I want to add the fade to:
Quote:

$ ffprobe temp1.ts
ffprobe version 2.3.git-1ace957 Copyright (c) 2007-2014 the FFmpeg developers
built on Jul 26 2014 20:25:06 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-x11grab --enable-libpulse --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr
libavutil 52. 92.101 / 52. 92.101
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 49.100 / 55. 49.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.102 / 4. 11.102
libavresample 1. 3. 0 / 1. 3. 0
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegts, from 'temp1.ts':
Duration: 00:00:06.37, start: 1.400000, bitrate: 199407 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High 4:4:4 Predictive) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc

This is the information from the result file:
Quote:

$ ffprobe temp1c.ts
ffprobe version 2.3.git-1ace957 Copyright (c) 2007-2014 the FFmpeg developers
built on Jul 26 2014 20:25:06 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-x11grab --enable-libpulse --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr
libavutil 52. 92.101 / 52. 92.101
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 49.100 / 55. 49.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.102 / 4. 11.102
libavresample 1. 3. 0 / 1. 3. 0
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegts, from 'temp1c.ts':
Duration: 00:00:06.37, start: 1.466667, bitrate: 12181 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc

notKlaatu 08-13-2014 10:16 PM

In your ffmpeg command, you are not setting a bitrate.

So your original file starts out being:

Code:

Duration: 00:00:06.37, start: 1.400000, bitrate: 199407 kb/s
but ends up being:

Code:

Duration: 00:00:06.37, start: 1.466667, bitrate: 12181 kb/s
So you are going from 199407 kbps to 12181 kbps

Hardcode in a bitrate:
Code:

ffmpeg -y -i temp1.ts -filter:v "fade=t=in:st=0:d=0.5,fade=t=out:st=60:d=0.5" -preset medium -c:v libx264 -b:v 35000k "temp1c.ts"
and see what happens.

eskimoroll 08-13-2014 11:11 PM

I tried it and there was a slight improvement, but my videos are still grainy.

Note: The only other operation I do after building temp1c.ts (of which it is included) is the following command for the final file:

Quote:

ffmpeg -y -f concat -i final-file-list.txt -c:a libmp3lame -b:v 35000k -qp 14 -c:v libx264 "output.mp4"
Thanks for your help

notKlaatu 08-13-2014 11:13 PM

Up the bitrate. You are starting out with 200MBps. So in theory you could even try v:b 199000k and see what happens.

MsSimilian 06-16-2023 06:36 AM

Faced the same issue while working with audio files. For me the best option is to convert audio files first to lossless .wav, do all things that I need to do and then covert them back to .mp3 or other lossy formats. This is the way that is used in audio editing apps and the most gentle way to work with audio or video files


All times are GMT -5. The time now is 03:45 AM.