VideoHelp Forum




+ Reply to Thread
Results 1 to 28 of 28
  1. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Hi , I am using Hauppauge WinTV and my schedule recordings having the .ts format.

    Image
    [Attachment 65249 - Click to enlarge]



    WinTV has the option by converting all recordings using ffmpeg

    by default the ffmpeg command for the conversion of the recorded .ts files to.mp4 is as follows:



    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset ultrafast -profile:v main -acodec aac "[DEST_FILE].mp4"



    Image
    [Attachment 65247 - Click to enlarge]



    Image
    [Attachment 65248 - Click to enlarge]



    How to modify the above command in order to set ffmpeg to always converting huge .ts files in size to .mp4 format but the .mp4 file to be much smaller in size?


    please advise,
    Thanks
    Last edited by neroman00; 7th Jun 2022 at 14:46.
    Quote Quote  
  2. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    File size is directly linked to bitrate. WinTv records (or atleast it does with mine) as mpeg2 @ 6000+ kbps

    h264 will typically have lower bitrate so the files will be smaller. But you need to do a conversion to see if the result is satisfactory for you since there are mnay other quality factors making a simple answer to your question not really practical.
    Quote Quote  
  3. Use clever FFmpeg-GUI.
    It's designed for just that purpose. You can, for example, re-encode only the video track (to make it smaller) and mux one or more audio tracks unchanged from the ts file into a new container (e.g. mp4, mkv etc), or you can also change each audio track as you like.
    Quote Quote  
  4. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Thanks!

    I've tried it but no option to convert .ts files to .mp4. By default videos conversion encoder is x264 (avc) that gives the result to .mkv output target file.
    Quote Quote  
  5. Originally Posted by neroman00 View Post
    Thanks!
    I've tried it but no option to convert .ts files to .mp4. By default videos conversion encoder is x264 (avc) that gives the result to .mkv output target file.
    The new created videostream is per default enbedded in a mkv container. Mux it with the desired audiostreams to mp4.
    Image
    [Attachment 65285 - Click to enlarge]
    Quote Quote  
  6. Changing the preset from ultrafast to veryfast will cut the file size to about 1/2, maybe 1/3. The conversion will take a little longer though. Specifying a higher crf value can make it even smaller (but lower quality). The default is 23.

    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4"
    Quote Quote  
  7. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Many thanks!

    Is there a way to modify the above command by the task to auto clear the unnecessary .ts files after the completion of ffmpeg job? Actually this will be useful to save space by keeping only the converted .mp4 files.

    Please advise!
    Thanks again
    Quote Quote  
  8. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Many thanks for your advise!

    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4"

    Any suggestions if is possible to modify the above command by adding a task to auto clear the unnecessary .ts files after the completion of ffmpeg job? Actually this will be useful to save space by keeping only the converted .mp4 files.

    Please advise!
    Thanks again
    Quote Quote  
  9. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    I doubt it. But ther are so many options that, maybe, one exists for this.

    Yet, but if you logically think about this, why would you want this ?


    Your original source has been converteted. Delete that at first conversion may be fine. But review the conversion even a little while down the road and a complete original may not be available to you. Better to have the original available. You will probably have the avail of direct ffmpeg switches but there are still other options that enable you to experiment since, as I already stated and just to clarify, what may work for one recording may not be optimal for another.
    Quote Quote  
  10. Originally Posted by neroman00 View Post
    Many thanks for your advise!

    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4"

    Any suggestions if is possible to modify the above command by adding a task to auto clear the unnecessary .ts files after the completion of ffmpeg job?
    Sure, just add a second command to the batch file:

    Code:
    ffmpeg -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4" 
    del "[SOURCE_FILE]"
    It's also possible to check the errorcode returned by ffmpeg and only delete if there's no error:

    Code:
    ffmpeg -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4" 
    if errorlevel 1 goto DONTDELETE
    del "[SOURCE_FILE]"
    goto end
    :DONTDELETE
    echo didn't delete
    :END
    Last edited by jagabo; 10th Jun 2022 at 11:49.
    Quote Quote  
  11. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Great job!

    Thanks a million!
    Quote Quote  
  12. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Hi again,

    The following command is working fine:

    ffmpeg -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4"



    I added your new batch file command without line brakes in order to be recognized to my software's settings as following:


    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4" if errorlevel 1 goto DONTDELETE del "[SOURCE_FILE]" goto end ONTDELETE echo didn't delete :END


    Image
    [Attachment 65383 - Click to enlarge]





    After this there is not any result!

    Image
    [Attachment 65382 - Click to enlarge]




    Please advise!
    Thanks
    Quote Quote  
  13. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Jagabo posted a batch (.bat) file which requires each command to be on a separate line. It appears that WinTv10 has a single line command so that can not be incorporated in to the program

    I only use WinTv7 and that actually does have an advance option to delete the original file after conversion. However since it only supports mpeg2.ts to mpeg2.ps I do leave that option ticked.


    You could contact user supprt at Hauppauge for them to tell you where that command is stored just to see if it can be externally modified.


    Otherwise if you insist on this you would have to do it manually using the .bat file (or another program such as posted earlier - there are many others) except that "[SOURCE_FILE]" and "[DEST_FILE]" would have to be modified because, as it stands, they only apply to the command line in Wintv10
    Quote Quote  
  14. Yes, I thought you were using a batch file. It may be possible in your program to change the Auto Convert Tool Location to use C:\Windows\System32\CMD.EXE, then set the Auto Convert Tool Command Line to point to a batch file and provide the filename:

    Code:
    /c c:\batch\convert.bat "[SOURCE_FILE]"
    The batch file would have to look something like:

    Code:
    "c:\path\to\ffmpeg.exe" -i "%~dpnx1" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "%~dpn1.mp4"
    if errorlevel 1 goto DONTDELETE
    del "%~dpnx1"
    goto end
    :DONTDELETE
    echo didn't delete
    :END
    Last edited by jagabo; 14th Jun 2022 at 07:17.
    Quote Quote  
  15. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Thanks but unfortunately a (.bat) batch file requires each command to be on a separate line and Auto Convert Tool Command Line DO NOT accepts separate command lines but only a single command line.
    Quote Quote  
  16. Originally Posted by neroman00 View Post
    Thanks but unfortunately a (.bat) batch file requires each command to be on a separate line and Auto Convert Tool Command Line DO NOT accepts separate command lines but only a single command line.
    The program calls a single command line:
    Code:
    cmd /c c:\batch\convert.bat "[SOURCE_FILE]"
    It has no idea what that command line is doing or how many lines are in the batch file. Just like it has no idea what ffmpeg really is doing.
    Quote Quote  
  17. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Image
    [Attachment 65464 - Click to enlarge]






    Here is the result after i typed on CMD your command cmd /c C:\convert.bat "[SOURCE_FILE]" just to test it. I put the convert.bat batch file under my C drive.



    C:\WINDOWS\system32>cmd /c C:\convert.bat "[SOURCE_FILE]"

    C:\WINDOWS\system32>"C:\ffmpeg\bin\ffmpeg.exe" -i "C:\Windows\System32\[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "C:\Windows\System32\[SOURCE_FILE].mp4"
    ffmpeg version 2021-04-28-git-1ab74bc193-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
    built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
    configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
    libavutil 57. 0.100 / 57. 0.100
    libavcodec 59. 0.100 / 59. 0.100
    libavformat 59. 0.100 / 59. 0.100
    libavdevice 59. 0.100 / 59. 0.100
    libavfilter 8. 0.100 / 8. 0.100
    libswscale 6. 0.100 / 6. 0.100
    libswresample 4. 0.100 / 4. 0.100
    libpostproc 56. 0.100 / 56. 0.100
    C:\Windows\System32\[SOURCE_FILE]: No such file or directory

    C:\WINDOWS\system32>if errorlevel 1 goto DONTDELETE

    C:\WINDOWS\system32>echo didn't delete
    didn't delete

    C:\WINDOWS\system32>
    Last edited by neroman00; 17th Jun 2022 at 16:39.
    Quote Quote  
  18. The tool location should not point to ffmpeg. It should point to c:\windows\system32\cmd.exe. The command line should not include the initial cmd. Just the part from /c to the end.
    Quote Quote  
  19. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    With the greatest respect to jagabo (who knows more about these things in his left thumb than I do in my whole body) he can not test his suggestion simply because Hauppauge WinTv10 will only work with a Hauppauge capture device.

    The error msg suggests that it looks for the "[SOURCE_FILE]" in the system32 folder (and without any reference to the true location and filename) and I would not even begin to suggest you use that to record your videos.


    Neither am I inclined to install that for my own Hauppauge device (even if it is supported)


    Maybe jagabo can suggest another way but here is my own........


    Just how long does it take to manually delete the source after conversion ? There must be a good reason why Hauppauge removed that direct option in later versions of their program.
    Quote Quote  
  20. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Well according to the Hauppauge store I can install WinTv 10 and it should work with my device.

    However, since it requires a paid-for activation code this is a non starter for me (obviously you had the program with your device)
    Quote Quote  
  21. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    Originally Posted by jagabo View Post
    The tool location should not point to ffmpeg. It should point to c:\windows\system32\cmd.exe. The command line should not include the initial cmd. Just the part from /c to the end.
    Dear jagabo


    I tried do that. Tool location point as you said but when I do the change and press ok for this change, then by going back to recheck the amendment then the tool location rolling back to point to ffmpeg.
    Image Attached Files
    Last edited by neroman00; 19th Jun 2022 at 02:05.
    Quote Quote  
  22. Well, it looks like the program is working really hard to stop you from doing what you want.
    Quote Quote  
  23. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Or it is doing something quite 'simple'

    1. Point to the installed version of ffmpeg
    2. Use that version to convert the source using the rest of the command line.


    (So the two boxes work in tandem. The second one, in particular, will npt respond if it sees switches that ffmpeg does not understand)


    From what I read that works. What does not work is to expand the command to do ancilliarly things such as delete the original source. And, as mentioned and for whatever reason, that has been removed.


    Stop wasting your time. Use the original (or jagabo's modified) command. And manually delete the source. Or show me a single conversion tool that can delete a source as part of the conversion process.


    Oh, yes. You can do it. jagabo's .bat file showed how it can be done. But not as part of the initial recording pricess. So unless that is modified for any .ts file in the appropiate folder surely it is just as simple to manually delete the .ts file after the event.
    Quote Quote  
  24. I suspect it can be done but you'll have to find a way of tricking the program into doing it.
    Quote Quote  
  25. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    That's true!

    Hence, jagabo's (modified) command as follows works fine:

    -i "[SOURCE_FILE]" -f mp4 -vcodec libx264 -preset veryfast -crf 25 -profile:v main -acodec aac "[DEST_FILE].mp4"

    I have a minor issue regarding the above command. The outcome aspect radio after the rendered .mp4 file is 4:3 instead of 16:9.

    Is there a way to modify the above command to force the aspect ratio (DAR) of the .mp4 files to 16:9 ?

    Thanks
    Quote Quote  
  26. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Post a mediainfo report (text mode) of the original recording and the converted version.

    I suspect that you are not even seeing 4:3 and the command line will require more than a simple modification.
    Quote Quote  
  27. Member
    Join Date
    Dec 2009
    Location
    Cyprus
    Search Comp PM
    please find the attached .txt file
    Image Attached Files
    • File Type: txt 1.txt (3.6 KB, 68 views)
    Quote Quote  
  28. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    As I suspected, you are not viewing 4:3 but 720*576 (which would have been the original file as well) which, if your player does not respect the DAR flag, which is actually 16:9 in your sample, will display as 5:4 and distorted.

    So you must use a player that respects the flag or force playback to 16:9
    Quote Quote  



Similar Threads

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