I am using FFMPEG with GPU h264_nvenc codec to upscale MPEG2 interlaced files.
h264_nvenc generate h264 with the store method: Separate fields (in mediaInfo) instead of the store method: Interleaved fields. These files with separate fields seems to be incompatible with tools like GVG Edius. How to change this store method?
with ffmpeg version N-92103-gebc3d04b8d Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20180813
Command FFMPEG:
-ss 00:14:45 -hwaccel cuda -c:v mpeg2_cuvid -i "input.mpg" -t 00:00:10 -vf "scale=if(gt(dar\,1.6)\,1920\,1460):1080:flags=lanczos:interl=1" -c:v h264_nvenc -pix_fmt nv12 -flags +ilme+ildct -b:v 16M -maxrate:v 22M -bufsize:v 8M -profile:v high -level:v 4.1 -rc:v vbr -coder:v cabac -f mp4 -y "inputUpscaled_GPU.MP4"
mediainfo testUpscale_GPU.MP4:
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High#L4.1
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 10 s 0 ms
Bit rate mode : Variable
Bit rate : 17.8 Mb/s
Maximum bit rate : 22.0 Mb/s
Width : 1 460 pixels
Height : 1 080 pixels
Display aspect ratio : 4:3
Frame rate mode : Constant
Frame rate : 25.000 FPS
Original frame rate : 50.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan type, store method : Separated fields
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.451
Stream size : 21.2 MiB (99%)
Codec configuration box : avcC
Related
I'm trying to create a TC Burn-In that correctly displays the source video's TC.
My current FFMPEG filter line is:
-filter_complex "[0:1][0:2] amerge" -preset ultrafast -vf scale=960:540:in_range=tv:out_range=pc,"drawtext=\timecode='00\:00\:00\:00':timecode_rate=25:x=(w-tw)/2:y=h-(2*lh):fontcolor=white#1:fontsize=30:box=1:boxcolor=black#0.6" -c:v libx264 -pix_fmt yuv420p -crf 27 -c:a aac -ar 48000 -b:a 128k
This of course starts the Burn-In at 00:00:00:00, but I'd rather insert the file's TC (in this case, it starts at 10:00:00:00) -- data taken from MediaInfo:
Other #1
ID : 1-Material
Type : Time code
Format : MXF TC
Frame rate : 25.000 FPS
Time code of first frame : 10:00:00:00
Time code of last frame : 10:02:34:20
Time code settings : Material Package
Time code, stripped : Yes
Title : Timecode
Other #2
ID : 0-Source
Type : Time code
Format : MXF TC
Frame rate : 25.000 FPS
Time code of first frame : 10:00:00:00
Time code of last frame : 10:02:34:20
Time code settings : Source Package
Time code, stripped : Yes
Other #3
Type : Time code
Format : SMPTE TC
Muxing mode : SDTI
Frame rate : 25.000 FPS
Time code of first frame : 10:00:00:00
I have not found a way to make FFMPEG read the TC and use it for the Burn-In. Do any of you guys know how to accomplish this?
Thanks
Christian
Just in case anyone ever has the same issue: ffmpeg by itself is not able to read the file's TC and use it to burn in TC (as of January 2023).
There is a workflow tool for encoding that I use (FFAStrans -- it's free and it's awesome) that can achieve this: https://ffastrans.com/frm/forum/viewtopic.php?f=5&t=1442
I'm encoding some 4K 10-bit YUV test sequences using NVENC HEVC encoder. For an example sequence and configuration, I use the following command.
ffmpeg -hide_banner -benchmark -loglevel debug -y -f rawvideo -s:v 3840x2160 -r 50 -pix_fmt yuv420p10le -i ParkRunning3_3840x2160_50fps_10bit_420.yuv -c:v hevc_nvenc -preset hp -rc cbr -profile:v main10 -b:v 10M output.mp4
My goal is to achieve as low latency as possible; therefore I set the preset to low-latency high-performance. However, I only get around 15 fps encoding speed with this command. A logfile from the ffmpeg output from the above command is here.
I also tried with different presets and different sequences. The results are similar for all the 10-bit sequences I encoded. For 1920x1080 10-bit sequences, I get around 50-60 fps with HEVC encoder. But for 8-bit sequences I'm getting a much higher throughput of around 450-500 fps with similar preset and rate control modes. In the example, I'm using CBR as rate-control mode but I also tested and obtained similar results (in terms of encoding throughput) with VBR and constant QP modes.
Is there anything I'm missing in my command for 10-bit HEVC encoding? I understand that with 10-bit, because of the increased bit-depth, the encoding will take longer. But a reduction in throughput on this scale makes me think that I'm doing something wrong. It seems that FFmpeg is inserting an auto_scaler before the encoder which converts from yuv420p10le (my input format) to p010le (the 10-bit format accepted by NVENC). Could this scaling module reduce the encoder speed so drastically?
I am having a problem converting a wmv file to mp4. I am using x264.exe this command to get the video stream
x264 --output temporal.264 --fps 25 --preset slow --bitrate 2048 --vbv-maxrate 2048 --vbv-bufsize 9600 --min-keyint 48 --keyint 48 --scenecut 0 --no-scenecut --pass 1 --video-filter "resize:width=640,height=480" Original.wmv
Then I use ffmpeg.exe to extract the audio stream with this line:
ffmpeg -i .wmv -acodec libfdk_aac -b:a 32000 temporal.aac
finally I use MP4Box to merges each stream with this line:
MP4Box -add temporal.264 Final.mp4
MP4Box -add temporal.aac Final.mp4
The problem is that the final.mp4 audio is out of sync. It starts good but with time it goes out of sync with time.
I run this command:
MP4Box -info 010004470063PE-10022017083824-2_MultiMedia--1.mp4
and I discover that the estimated time of both streams are different:
output of command
* Movie Info *
Timescale 600 - 2 tracks
Computed Duration 01:00:03.643 - Indicated Duration 01:00:03.643
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom - version 1
Compatible brands: isom avc1
Created: GMT Wed Jun 27 16:31:44 2018
Modified: GMT Wed Jun 27 16:31:44 2018
File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: AVC/H264 Profile (0x7f)
Audio PL: AAC Profile # Level 2 (0x29)
No streams included in root OD
Track # 1 Info - TrackID 1 - TimeScale 25000
Media Duration 00:59:57.520 - Indicated Duration 00:59:57.520
Track has 1 edit lists: track duration is 00:59:57.320
Media Info: Language "Undetermined (und)" - Type "vide:avc1" - 89938 samples
Visual Track layout: x=0 y=0 width=640 height=480
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 640 x 480
AVC Info: 1 SPS - 1 PPS - Profile Main # Level 3
NAL Unit length bits: 32
Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8
SPS#1 hash: 41EE779BEF2AA71A7131EAFD3C77C7E3BC95FD8E
PPS#1 hash: 086E1D72A40A0E8CF35D102F34A9DF6CD44D6CEF
Self-synchronized
RFC6381 Codec Parameters: avc1.4D401E
Average GOP length: 250 samples
Track # 2 Info - TrackID 2 - TimeScale 44100
Media Duration 01:00:03.644 - Indicated Duration 01:00:03.644
Media Info: Language "Undetermined (und)" - Type "soun:mp4a" - 155196 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Synchronized on stream 1
RFC6381 Codec Parameters: mp4a.40.2
All samples are sync
I am not shore why this is happening, becar the original wmv is perfectly synchronize. Any help?
.aac is a raw container having no timestamps, if there are PTS gaps in the source audio, they will be lost.
You have two workarounds:
a) extract to a timed samples container
ffmpeg -i .wmv -acodec libfdk_aac -b:a 32000 -vn temporal.m4a
b) fill in the gaps and extract
ffmpeg -i .wmv -af aresample=async=1 -acodec libfdk_aac -b:a 32000 temporal.aac
Base on the response of Gyan I use ffmpeg to transcode the wmv file to an mp4, separating the audio and video sequences was a bad idea. At the end I use the following command for transcoding:
ffmpeg -i <input>.wmv -c:v libx264 -preset slow -crf 23 -c:a aac -r 25 -b:a 48k -strict -2 -max_muxing_queue_size 4000 <output>.mp4
I am trying to convert a 4K HEVC MKV file of 70GB into another HECV file but with less size. I am using FFmpeg with Nvidia acceleration but when I execute the following command an error appears:
ffmpeg -y -vsync 0 -hwaccel_device 0 -hwaccel cuvid -c:v hevc_cuvid -i input.mkv -c:a copy -c:v hevc_nvenc -preset slow -b:v 10M -bufsize 10M -maxrate 15M -qmin 0 -g 250 -bf 2 -temporal-aq 1 -rc-lookahead 20 -i_qfactor 0.75 -b_qfactor 1.1 output.mkv
The error is:
[hevc_nvenc # 0000021036b0d000] Provided device doesn't support required NVENC features
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
The video file has these details:
It seems that FFmpeg cannot recognize my GPU as a supported device to decode but I have read that Nvidia has support for my card with NVDEC.
I am running Windows 10 64 bits with i7 4790 and GTX 1080
NVENC doesn't support encoding B-frames, so
-bf 0 and drop -b_qfactor 1.1.
I am able to encoded YUV file to mp4 using HEVC:
ffmpeg.exe -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i input.yuv -c:v hevc -r 30 -x265-params crf=27 -vframes 300 -an -y test.mp4
Here is the mp4box -info test.mp4 shows:
* Movie Info *
Timescale 1000 - Duration 00:00:10.000
1 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom - version 512
Created: UNKNOWN DATE Modified: UNKNOWN DATE File has no MPEG4 IOD/OD
iTunes Info:
Encoder Software: Lavf56.11.100
Track # 1 Info - TrackID 1 - TimeScale 15360 - Media Duration 00:00:10.000 Track has 1 edit lists: track duration is 00:00:10.000 Media Info: Language "Undetermined" - Type "vide:hev1" - 300 samples Visual Track layout: x=0 y=0 width=1920 height=1080 MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x23 HEVC Video - Visual Size 1920 x 1080
HEVC Info: Profile Main # Level 5 - Chroma Format 1
NAL Unit length bits: 32 - general profile compatibility 0x60000000
Parameter Sets: 1 VPS 1 SPS 1 PPS
SPS resolution 1920x1080
Bit Depth luma 8 - Chroma 8 - 1 temporal layers
But how can I get the decodeble bit stream? I tried
mp4box -raw 1 test.mp4 -out out.bin
It gives:
Extracting MPEG-H HEVC stream to hevc
But the out.bin couldn't be decoded by HM or elecard.
Thanks
Use
ffmpeg -i input.mp4 -c:v hevc -f hevc out.bin
to generate an Annex B bytestream. This can be fed to another decoder.