VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. hello,
    as some probably agree you can't go the above and beyond AviSynth filter and super slow x264 encoding way for all the stuff you are watching. So for specific cases where speed and simplicity (nothing batter than just moving your video into a cmd) is a priority over quality I wrote simple
    ffmpeg batches to do the job. Here is a special case which gives me headaches.

    I want to convert this interlaced 59.94 which was sourced from a proper NTSC-Video VHS (but sadly set to a variable Frame rate mode for the encode)
    to progressive 29,97 and apply some deblocking to go with that because my stand alone player is not able to deinterlace this content (probably because of it being weirdly encoded)

    My ffmpeg cmd for this would be
    Code:
    "%FFMPEG%" -i %INPUTFILE% -filter:v "bwdif=mode=0:parity=0,fps=30000/1001",gradfun=3.5:8 -codec:v "libx264" -crf "18" -preset:v "veryfast" -fps_mode:v "cfr" -pix_fmt:v "yuv420p" -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" -map 0 -c:a copy -f matroska %1%.mkv
    sample: https://workupload.com/file/8EW8FGRrB7g

    the problem is that I'm getting an output with a super weird variable framerate no matter what I do. I already set it correct with fps_mode:v "cfr"
    . I tried adding -r 30000/1001 into the fold which also didn't help.
    Is this a case of impossible or is there a way in the simple cmd/batch universe to solve this?

    thanks in advance
    regards
    Quote Quote  
  2. Try to set fps before bwdif.
    Fps_mode should be unnecessary.
    Quote Quote  
  3. This produces constant 29.97fps progressive here of this poor source:
    Code:
    ffmpeg -i "%~1" -c:a:0 copy -c:v:0 libx264 -preset fast -crf 18 -filter:v:0 "bwdif=mode=0, format=yuv420p, setsar=1/1" "%~1_bwdif.mp4"
    Quote Quote  
  4. Originally Posted by skh View Post
    Fix the original framerate first,
    Code:
    FFmpeg.exe -y -r 30000/1001  -i "ECW 1-3-001.mkv" -c copy -bsf:v setts=ts=STARTPTS+N/TB_OUT/29.97 "ECW 1-3-001_fixed_FPS_29.97.mkv"
    then repeat your commandline.
    Quote Quote  
  5. Originally Posted by prowo View Post
    fix the original framerate first,
    Code:
    ffmpeg.exe -y -r 30000/1001  -i "ecw 1-3-001.mkv" -c copy -bsf:v setts=ts=startpts+n/tb_out/29.97 "ecw 1-3-001_fixed_fps_29.97.mkv"
    then repeat your commandline.
    thanks, is that only possible when I do 2 jobs or is there a way to combine that with my other command line? I tried but got an error

    [setts @ 000001c87d7450c0] [Eval @ 0000004fab3fe970] Undefined constant or missing '(' in 'startpts+n/tb_out/29.97'
    [setts @ 000001c87d7450c0] Error while parsing ts expression 'startpts+n/tb_out/29.97'
    [vost#0:0/libx264 @ 000001c87dd704c0] Error initializing bitstream filter: setts
    [vost#0:0/libx264 @ 000001c87dd704c0] Error initializing output stream:

    Originally Posted by sharc View Post
    this produces constant 29.97fps progressive here of this poor source:
    Code:
    ffmpeg -i "%~1" -c:a:0 copy -c:v:0 libx264 -preset fast -crf 18 -filter:v:0 "bwdif=mode=0, format=yuv420p, setsar=1/1" "%~1_bwdif.mp4"
    This shows that I have a framerate of 59940/1000 in media info but still declares the framerate mode as variable.
    60i should still work tho if it would be constant but kind of strange the bwdif mode=0 doesn't reduce it to 29,97. For PAL it works like that and outputs 25p instead of 50 interlaced for deinterlacing standard VHS so kind of weird.
    Quote Quote  
  6. Originally Posted by skh View Post
    Originally Posted by prowo View Post
    fix the original framerate first,
    Code:
    ffmpeg.exe -y -r 30000/1001  -i "ecw 1-3-001.mkv" -c copy -bsf:v setts=ts=startpts+n/tb_out/29.97 "ecw 1-3-001_fixed_fps_29.97.mkv"
    then repeat your commandline.
    thanks, is that only possible when I do 2 jobs or is there a way to combine that with my other command line? I tried but got an error

    [setts @ 000001c87d7450c0] [Eval @ 0000004fab3fe970] Undefined constant or missing '(' in 'startpts+n/tb_out/29.97'
    [setts @ 000001c87d7450c0] Error while parsing ts expression 'startpts+n/tb_out/29.97'
    [vost#0:0/libx264 @ 000001c87dd704c0] Error initializing bitstream filter: setts
    [vost#0:0/libx264 @ 000001c87dd704c0] Error initializing output stream:.
    Copy and past my commandline, adjust the paths.
    Quote Quote  
  7. The result of my commandline:
    Frame rate mode : Constant
    Frame rate : 29.970 (30000/1001) FPS
    Image Attached Files
    Quote Quote  
  8. Originally Posted by skh View Post
    Originally Posted by sharc View Post
    this produces constant 29.97fps progressive here of this poor source:
    Code:
    ffmpeg -i "%~1" -c:a:0 copy -c:v:0 libx264 -preset slow -crf 18 -filter:v:0 "bwdif=mode=0, format=yuv420p, setsar=1/1" "%~1_bwdif.mp4"
    This shows that I have a framerate of 59940/1000 in media info but still declares the framerate mode as variable.
    60i should still work tho if it would be constant but kind of strange the bwdif mode=0 doesn't reduce it to 29,97. For PAL it works like that and outputs 25p instead of 50 interlaced for deinterlacing standard VHS so kind of weird.
    Strange. This is what MediaInfo returned from my commandline
    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L3.1
    Format settings : CABAC / 5 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 5 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 13 min 2 s
    Bit rate : 8 965 kb/s
    Width : 1 280 pixels
    Height : 720 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 29.970 (30000/1001) FPS

    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.325
    Stream size : 836 MiB (97%)
    Writing library : x264 core 164 r3191 4613ac3
    ..........
    Quote Quote  
  9. found the bug. I used "mkv" as an output container. Once I switched to mp4 (which was in your suggestion anyways) it worked. So its probably a bug of mkv tags or whatsoever not beeing displayed right in mpc.
    and for prowo it probably was that he used clever FFmpeg-GUI which corrects it instead of just moving stuff in batches.
    Quote Quote  
  10. It tends to be MP4 more than MKV for which MediaInfo incorrectly reports a variable frame rate, but maybe it's dependent on the program/encoder and the timecodes created. For MKV the frame durations are usually a whole number of milliseconds, but at 29.97fps the frame duration is actually 33.3667ms so there's a pattern of 33ms and 34ms frames. Like this:

    0
    33
    67
    100
    133
    167
    200
    234

    As an experiment, try remuxing the MP4s and MKVs ffmpeg created with MKVToolNixGUI. Do it twice. Once using the defaults for MKVToolNix, and then remux them again while adding the following to the "Additional Options" section under the Output tab.
    --disable-track-statistics-tags
    That'll create MKVs without the tags for MediaInfo to read so it'll have to work out the frame rate for itself. I don't know if ffmpeg writes those tags, but with them MediaInfo might report something different.

    And if in doubt you can always add Info() to the end of the Avisynth script as it includes the frame rate, if that's your input video. If Avisynth reports 30000/1001 the script's frame rate is okay and you shouldn't have to worry about the frame rate MediaInfo reports. By the way, if you are using Avisynth for that video, it's possible to make the chroma slightly less horrible. I only had a quick play with it.

    BWDIF(field=-1)
    CropResize(0,720, 160,10,-168,-14)

    Image
    [Attachment 80179 - Click to enlarge]


    ShiftUVMod(uy=-4, vy=-4)
    BWDIF(field=-1)
    MergeChroma(Awarpsharp2(Depth=30))
    CropResize(0,720, 160,10,-168,-14)

    Image
    [Attachment 80180 - Click to enlarge]
    Quote Quote  
  11. thanks for the input on avs hello_hello, always appreciated. However in this case of crappy quality sport shows I try to keep things as simple as possible by just doing a a drag and drop on ffmpeg cmd without any indexing or avs post processing
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!