VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    I need some help with the FFmpeg command line to do the conversion shown in the Title of this post (and also embed .srt subtitles, if possible). I am very "green" when it comes to FFmpeg, so any advice would be appreciated.

    I am trying to transcode some .MP4 videos from 1080p/H.264/AAC to a format that will play via the USB port on a television which I suspect will only accept H.263/MP3. The manual is a bit vague on what will actually play on the set. It says it can play files utilizing "MPEG4 ASP or Compatible codecs" and the sound section implies the audio codec must be MP3. It sounds like the TV is only particular about resolution when the target is other than .MP4, however, advice on how to change that would be handy (just in case).

    The television is a Model 29FU6TS-CW62D and was purchased in Colombia a while back.

    The manual for the television is MFL42505203-sp (Spanish) and MFL42505203-en (English). I've attached the English version for reference.
    On page 10 of the English Manual, it says:

    • Movie (AVI)file compatibility with this player is limited as follows :
    -Available resolution of AVI file is under 720x480 (576)pixel.
    -If video codec is not supportable, "UNSUPPORTED FORMAT"OSD will be displayed in the file list menu.
    -If sound codec is not supportable, Video may display but "UNSUPPORTED FORMAT" OSD will be displayed with no sound.
    -If sound has no data stream,"NO SOUND" OSD will be displayed on the screen.
    -If the number of the screen frame is over 30 per 1 second, this device may not operate normally.
    • Supportable Subtitle format: srt, sri, smi, txt, ssa, ass, sub, psb
    • Supportable movie file extension: “.DAT”, “.AVI”, “.MP4”, “.MPG”
    • Supportable video codecs: MPEG1(VCD 1.0, 1.1, 2.0, SVCD), MPEG4 ASP or Compatible codecs
    Image Attached Files
    Quote Quote  
  2. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    "MPEG4 ASP or Compatible codecs" ... that will probably include DivX and Xvid. In case if Xvid, you have a choice of either H.263 parametric or MPEG matrix quantization; but I am not sure how to select them with a codec-specific parameter for "-codec:v libxvid". Several Xvid options are probably exposed as direct ffmpeg options. You may have to test which FourCC is recognized (XVID, FMP4, etc.)

    For the audio conversion, you will probably prefer "-codec:a libmp3lame" and some LAME specific options to control the bitrate. VBR should be supported in the MP4 container, you will just have to test if the TV set supports it without going async.

    Here is an additional MPEG-4 encoding guide for ffmpeg, but it might be a bit old already...
    Quote Quote  
  3. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Thanks, "LigH.de";
    I don't have the TV here, so I'm trying to gather the info for when I'm abroad at my friends place. I'll bring the videos with me and the software plus any notes I can gather on how to do the conversion. So; the info and references you noted will be very helpful. Will read the guide to see what I need to do in the way of a commandline.

    (If anyone else has any more info, I'm always open to receiving it.Interpreting the manual noted in the previous post is a bit confusing.)
    Quote Quote  
  4. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Well... I'm still having some issues getting things to transcode. I think that there must be some limits to the combinations of parameters one can use. Is there a list somewhere that shows what the typical combination of video and audio parameters would have been be for a very "traditional" or "commercially available" MPEG4 ASP encoded video that would have played on a television via a USB 2.0 key some years ago? Even an example file would be helpful. I realize that this is somewhat vague, but I'm not sure exactly sure what the LG TV manufacturer might have been assuming one would supply as input.
    Quote Quote  
  5. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Try FFmpeg's own mpeg4 coder with options
    Code:
    -profile:v 15 -level 7
    for Advanced Simple Profile at Level 3b, which is widely supported. (Yes, the value is hideously arbitrary and undocumented. There is a list in this source.)
    Quote Quote  
  6. Try something like:
    Code:
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=720:ih-mod(ih\,2) -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 1 -an -f avi NUL
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=720:ih-mod(ih\,2) -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 2 -c:a libmp3lame -b:a 128k "output.avi"
    Last edited by sneaker; 18th Dec 2016 at 14:49.
    Quote Quote  
  7. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Sneaker;
    Would the container need to be a ".avi"? I was under the impression that I could change to MPEG-4 ASP video and MP3 audio and still use a .MP4 container.
    Does the resolution need to be 720p for MPEG-4 ASP video or is that just a guess at what the television would handle?
    Quote Quote  
  8. 720 width is not 720p. You asked for a typical encode running on old players. That's what my post is supposed to show. Is this the best for your player? I do not know.
    Quote Quote  
  9. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Hi Sneaker;
    Sorry; I didn't quite get what you were doing until I re-read the manual. The TV does 720x480 when it is playing a ".AVI" file. Heaven knows what it will do with an ".MP4" file no matter what it contains. It doesn't say. So It sounds like 720x480 would be the one to try.
    Quote Quote  
  10. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Just a note to say that I'm having some luck with the conversions. I tried the Avanti Gui for FFmpeg to set the suggested parameters and found that it made it much easier to do the conversion (and far less prone to getting illegal combinations of parameters. I hope to post again after New Years, once I know how the converted filed functioned on the target TV.
    Quote Quote  
  11. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Sneaker:
    Could I ask for a bit of help in getting some of your suggested settings set up in AVANTI GUI? Some of the ffmpeg tags are a bit foreign to me and I might not recognize the corresponding field name in the AVANTI GUI. I've included a screenshot of what I've tried for a test run. It seems to work, but I do find the aspect ratio is a bit off (the picture looks a bit compressed in the horizontal direction, but I'm not sure how to correct it even if I know the original files aspect ratio).
    Image Attached Thumbnails Click image for larger version

Name:	Avanti settings used for MP4 to AVI conversion.jpg
Views:	391
Size:	163.2 KB
ID:	39976  

    Quote Quote  
  12. My command does not always resize to 720x480. It uses 720x480 as a "box" and tries to fit the picture into it while still retaining square pixels (and mod2 dimensions).

    Example: input is 1920x1080, i.e. 16:9. But 720x480 is 3:2. Then result with my script will be 720x404. If you resize to 720x480 without setting any AR flag to compensate the image will look "compressed" as you say. Actually, I think my script will only work correctly with square pixel input and would need to be further modded in some cases.

    Avanti does not fully run on my Win 7 system but it seems to have a scale/crop setting. In the top there are several icons, it is the 4th from the left. Try to setup the picture there.
    Or maybe you can enter "-vf scale=in_color_matrix=auto:out_color_matrix=bt601: w=720:h=480:force_original_aspect_ratio=decrease,c rop=720:ih-mod(ih\,2)" into the "User VIDEO options" while setting "frame size" to "Source". (Again: I cannot test this.)
    Quote Quote  
  13. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Well, if you are going to encode MPEG-2 video with 16:9 DAR flag for an NTSC DVD Video, directly scaling 1920x1080 to 720x480 might not even be the worst idea. But in AVI or MP4, a 1:1 SAR might be more or less expected (although anamorphic content is possible).
    Quote Quote  
  14. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Sneaker:

    When I tried the first of the following two ffmpeg commands you suggested, I got numerous errors:

    Code:
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=720:ih-mod(ih\,2) -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 1 -an -f avi NUL
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=720:ih-mod(ih\,2) -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 2 -c:a libmp3lame -b:a 128k "output.avi"
    I've attached the initial portion of the output log as a txt file.
    Could you help me understand what is happening?
    My efforts with AVANTI GUI were Ok, but I'd like to see if I can do better by using ffmpeg directly.
    Image Attached Files
    Quote Quote  
  15. Code:
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=iw-mod(iw\,2):ih-mod(ih\,2),setsar=1/1 -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 1 -an -f avi NUL
    ffmpeg -y -i "input.mp4" -vf scale=in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=iw-mod(iw\,2):ih-mod(ih\,2),setsar=1/1 -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 2 -c:a libmp3lame -b:a 128k "output.avi"
    edit: Use that for now. I wanted to add support for anamorphic input but it is more complicated than I thought it would be.
    Last edited by sneaker; 22nd Dec 2016 at 12:37.
    Quote Quote  
  16. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Sneaker:
    Thank you, so much!
    The revised commands worked well.
    The aspect ratio of the converted file is perfect.
    I notice that it is much faster than when using ffmpeg via Avanti.
    The sharpness of the image is a little bit less than expected, but still quite decent.
    By chance, is there a setting to try to increase the sharpness slightly?
    Quote Quote  
  17. I'm not sure. Maybe:
    1. use sharper scale algorithm
    2. use sharpening filter
    3. use higher resolution (anamorphic might be required but not supported by every player)

    This should work for 1. but I haven tested (idk what default is):
    Code:
    ffmpeg -y -i "input.mp4" -vf scale=flags=lanczos:in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=iw-mod(iw\,2):ih-mod(ih\,2),setsar=1/1 -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 1 -an -f avi NUL
    ffmpeg -y -i "input.mp4" -vf scale=flags=lanczos:in_color_matrix=auto:out_color_matrix=bt601:w=720:h=480:force_original_aspect_ratio=decrease,crop=iw-mod(iw\,2):ih-mod(ih\,2),setsar=1/1 -c:v libxvid -vtag xvid -b:v 3000k -maxrate 4800k -bufsize 3100k -pass 2 -c:a libmp3lame -b:a 128k "output.avi"
    https://ffmpeg.org/ffmpeg-filters.html
    Quote Quote  
  18. Member
    Join Date
    Dec 2016
    Location
    Alberta, Canada
    Search Comp PM
    Sneaker:
    Thanks. That seemed to make it a bit better.
    Will go with those settings for now.
    Quote Quote  
  19. whatever happened to axxo and jaybob? anyway, as far as xvid is concerned, I'd stay away from average bitrate/2-pass. try making a video with tv noise (tv channel signed off/snow) followed by a still picture. encode that with your usual decent birate... ugly. it's as if the tv noise frames bled into the still image. now try encoding that with an insanely large bitrate (i dont know like 20 mbps)... guess what, for a few seconds, that noise still "bleeds" to the following still image frames. try quantizer 4 or 5 instead.
    Quote Quote  



Similar Threads